Skip to content

Set-Location \\wsl$\Ubuntu throws an error #10360

Closed

Description

Steps to reproduce

  • execute when wsl2 is up and running
    Set-Location \\wsl$\Ubuntu

Expected behavior

  • successfully changes directory
PS Microsoft.PowerShell.Core\FileSystem::\\wsl$\Ubuntu>

Actual behavior

  • throws an error
Set-Location : Cannot process argument because the value of argument "path" is not valid. Change the value of the "path" argument and run the operation again.                                                                                  At line:1 char:1
+ Set-Location \\wsl$\Ubuntu
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : InvalidArgument: (:) [Set-Location], PSArgumentException
+ FullyQualifiedErrorId : Argument,Microsoft.PowerShell.Commands.SetLocationCommand

Environment data

Name                           Value
----                           -----
PSVersion                      6.2.2
PSEdition                      Core
GitCommitId                    6.2.2
OS                             Microsoft Windows 10.0.18956
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Note: Same behavior on 7.0.0-preview.2, but everything is working on Windows Powershell 5.1

Activity

  1. rkeithhill commented on Aug 15, 2019

    @rkeithhill
    Collaborator

    Because $ is used to denote a variable in PowerShell, try Set-Location '\\wsl$\Ubuntu' or Set-Location \\wsl`$\Ubuntu or Set-Location --% \\wsl$\Ubuntu.

  2. archilkarchava commented on Aug 15, 2019

    @archilkarchava
    Author

    image
    Didn't work unfortunately.

  3. archilkarchava commented on Aug 15, 2019

    @archilkarchava
    Author

    Set-Location "\wsl$\Ubuntu" also doesn't work

  4. rkeithhill commented on Aug 15, 2019

    @rkeithhill
    Collaborator

    First one should work, I typo'd were the ' should be but I updated/fixed it above. The second one is interesting - would have expected that to work. Retracted the third one, --% is primarily for native exes.

  5. archilkarchava commented on Aug 15, 2019

    @archilkarchava
    Author

    image
    Still throws an error.

  6. rkeithhill commented on Aug 15, 2019

    @rkeithhill
    Collaborator

    Well, perhaps a real issue then. If you bring up cmd.exe, I assume you can cd to this dir, right?

  7. rkeithhill commented on Aug 15, 2019

    @rkeithhill
    Collaborator

    It also seems that PowerShell is smart about not interpreting $ as the start of a variable if the next character is invalid in a variable name.

  8. archilkarchava commented on Aug 15, 2019

    @archilkarchava
    Author

    Cmd doesn't support UNC paths as far as i know. But powershell.exe (5.1) works.

  9. added
    WG-Engine-Providers
    Issue-Bug
    on Aug 17, 2019
  10. iSazonov commented on Aug 17, 2019

    @iSazonov
    Collaborator

    Look like we can not parse UNC path if a computer name ends with $

  11. vexx32 commented on Aug 17, 2019

    @vexx32
    Collaborator

    Is it a computername, or is it a drive name? That syntax is usually UNC syntax for a drive... maybe try \\localhost\wsl$\... instead?

  12. archilkarchava commented on Aug 19, 2019

    @archilkarchava
    Author

    Is it a computername, or is it a drive name? That syntax is usually UNC syntax for a drive... maybe try \\localhost\wsl$\... instead?

    image

  13. archilkarchava commented on Aug 21, 2019

    @archilkarchava
    Author

    I just checked and it can't Set-Location into directory, but Get-ChildItem works.

  14. lucyllewy commented on Sep 24, 2019

    @lucyllewy

    The same behaviour occurs if you try to set the path as a PSDrive (in Powershell Core 6.2.3):

    PS C:\Users\yabea> New-PSDrive -Name WSL -PSProvider "FileSystem" -Root "\\wsl$\Ubuntu-18.04"
    
    Name           Used (GB)     Free (GB) Provider      Root                                               CurrentLocation
    ----           ---------     --------- --------      ----                                               ---------------
    WSL                                    FileSystem    \\wsl$\Ubuntu-18.04                                                                                                                                                                        
    
    PS C:\Users\yabea> cd WSL:
    cd : Cannot process argument because the value of argument "path" is not valid. Change the value of the "path" argument At line:1 char:1
    + cd WSL:
    + ~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Set-Location], PSArgumentException
    + FullyQualifiedErrorId : Argument,Microsoft.PowerShell.Commands.SetLocationCommand
    
    PS C:\Users\yabea> $PSVersionTable
    
    Name                           Value
    ----                           -----
    PSVersion                      6.2.3
    PSEdition                      Core
    GitCommitId                    6.2.3
    OS                             Microsoft Windows 10.0.18985
    Platform                       Win32NT
    PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
    PSRemotingProtocolVersion      2.3
    SerializationVersion           1.1.0.1
    WSManStackVersion              3.0

    While it works as expected in Powershell as part of Windows Insider Preview build 18985.1:

    C:\Users\yabea> New-PSDrive -Name WSL -PSProvider "FileSystem" -Root "\\wsl$\Ubuntu-18.04"
    
    Name           Used (GB)     Free (GB) Provider      Root                                               CurrentLocation
    ----           ---------     --------- --------      ----                                               ---------------
    WSL                                    FileSystem    \\wsl$\Ubuntu-18.04
    
    C:\Users\yabea> cd WSL:
    WSL:\> ls
    
        Directory: \\wsl$\Ubuntu-18.04
    
    ----                 -------------         ------ ----
    d-----        17/09/2019     09:34                home
    d-----        21/05/2019     15:39                srv
    d-----        24/09/2019     22:49                etc
    d-----        21/05/2019     15:39                opt
    d-----        23/09/2019     00:00                root
    d-----        18/09/2019     14:36                lib
    d-----        18/09/2019     13:34                mnt
    d-----        21/05/2019     15:39                usr
    d-----        24/09/2019     22:49                media
    d-----        21/05/2019     15:39                lib64
    d-----        24/09/2019     22:49                sys
    d-----        24/09/2019     22:49                dev
    d-----        17/09/2019     14:36                sbin
    d-----        21/05/2019     15:42                boot
    d-----        17/09/2019     14:36                bin
    d-----        24/09/2019     22:49                run
    d-----        24/09/2019     22:49                proc
    d-----        23/09/2019     23:02                snap
    d-----        24/09/2019     22:49                tmp
    d-----        21/05/2019     15:42                var
    d-----        10/04/2019     17:35                lost+found
    ------        01/01/1970     00:00              0 init
    
    WSL:\> $PSVersionTable
    
    Name                           Value
    ----                           -----
    PSVersion                      5.1.18985.1
    PSEdition                      Desktop
    PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
    BuildVersion                   10.0.18985.1
    CLRVersion                     4.0.30319.42000
    WSManStackVersion              3.0
    PSRemotingProtocolVersion      2.3
    SerializationVersion           1.1.0.1
  15. jazzdelightsme commented on Sep 27, 2019

    @jazzdelightsme
    Contributor

    I just checked and it can't Set-Location into directory, but Get-ChildItem works.

    Get-ChildItem does not work for me, on 7.0.0-preview.2 or 7.0.0-preview.3.

    It does work for me on 6.2.1, however (and 5.1, as described by others).

    IMO this is a painful regression because it prevents you from using pwsh with the fancy new WSL2 feature that everybody wants to try out. We should really get it fixed for PSv7.

    It's very easy to set up a repro for this--if you search for WSL2, there are lots of people talking about it and sharing the instructions to set it up. Here are the official instructions.

  16. iSazonov commented on Sep 27, 2019

    @iSazonov
    Collaborator

    /cc Steve Lee (@SteveL-MSFT) for information.

  17. SteveL-MSFT commented on Sep 28, 2019

    @SteveL-MSFT
    Member

    I'm trying to repro this. Got WSL setup following the instructions by Dan Thompson (@jazzdelightsme), although the switches for wsl.exe have changed. Installed Ubuntu. \\wsl$\ubuntu doesn't work in WinPS 5.1. Need a working example in WinPS 5.1 to debug why it's not working in PS7.

  18. iSazonov commented on Sep 29, 2019

    @iSazonov
    Collaborator

    I am very wonder why the format \\wsl$\ubuntu is used. It looks like \servername\share but naming convention does not allow "$" in DNS names and allow in NetBIOS names. https://support.microsoft.com/en-gb/help/909264/naming-conventions-in-active-directory-for-computers-domains-sites-and
    It seems NetBIOS deprecated. Steve Lee (@SteveL-MSFT) Can you ask WSL team about the strange name format?

    Also the format assumes that PoweerShell will use remoting?

  19. lucyllewy commented on Sep 30, 2019

    @lucyllewy

    I believe the $ is specifically so that the name does not conform to netbios conventions. The wsl filesystem handler is not SMB and so trying to look up the name via netbios will cause issues. The wsl filesystem is internally routed through a 9p server handled by the init processes. There is no network-accessible name as everything is within a single PC.

  20. SteveL-MSFT commented on Oct 1, 2019

    @SteveL-MSFT
    Member

    Still waiting on a repro where that path works.

  21. SteveL-MSFT commented on Oct 1, 2019

    @SteveL-MSFT
    Member

    Looks like my version of Windows isn't new enough. Upgrading to newer version.

  22. SteveL-MSFT commented on Oct 1, 2019

    @SteveL-MSFT
    Member

    Ok, can repro this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Issue-BugResolution-FixedWG-Engine-Providers

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions