Skip to content

Inconsistent experience when access root of psdrive #6773

Closed

Description

cd /Users/steve/test
mkdir Users
New-PSDrive -PSProvider FileSystem -Root /Users/steve/test -Name steve
cd steve:
cd /Users

What should happen? Today, if the path starts with a directory separator on Unix systems, we always treat it as a filesystem path so you would end up in /Users instead of steve:/Users. Workaround if you're in the PSDrive is to use ./Users (on Unix, on Windows the workaround isn't needed since every drive starts with a drive letter so there's no ambiguity, but cross-platform scripts would need to be aware of this).

Doesn't seem like much we can do here as assuming a root path means filesystem makes sense. However, as more PSProviders become availble (since SHiPS makes it much easier now to author them), this experience may or may not cause confusion.

For example, if Azure:/myfolder exists and you try cd /myfolder while in the Azure: drive, but /myfolder doesn't exist in the filesystem, you'll get an error. We don't try (and shouldn't) to find it in the psdrive if we don't find it it the filesystem. Instead, you get a cd : Cannot find path '/myfolder' because it does not exist error message (again, on Unix only).

Seeing if anyone in the community has any ideas on how to potentially improve this experience.

Activity

  1. added
    Issue-Discussion
    WG-Engine-Providers
    on Apr 28, 2018
  2. mklement0 commented on Apr 29, 2018

    @mklement0
    Contributor

    How about allowing an initial : to represent the current location's drive, without having to name it in full?

    # While the current location is on drive steve:, this would be the 
    # equivalent of Set-Location steve:/Users
    Set-Location :/Users   

    In other words: start a path with :/ rather than just / if you want it to refer to the root of the current drive.


    The small caveat is that on Unix-like platforms it would take away the ability to directly target a subdir. literally named :, which currently works:

    PS> mkdir -p ':/Users'; Set-Location -LiteralPath ':/Users'; $pwd.Path
    /Users/jdoe/:/Users

    To truly target a subdir. named : in this case, prefixing with ./ would then be required (Set-Location ./:/Users)

    I don't think that's a real-world concern, however, especially given that this is already a problem with files / subdirs. whose names look like they start with a drive spec; e.g.:

    PS> mkdir -p 'ab:cd'; Set-Location -LiteralPath 'ab:cd'
    Set-Location : Cannot find drive. A drive with the name 'ab' does not exist.

    In this scenario prefixing with ./ already is a requirement.


    Given the rarity of : in filenames, I think introducing support for :/ is an acceptable solution.

    (Note that : serves as the entry separator in $env:PATH on Unix-like platforms, even though : is a legal filename character in the typical Linux / macOS filesystems.
    On a side note: classic Mac OS used : as the path separator, and that heritage is still reflected in Finder, which translates : in filenames into /(!) in its GUI.)

  3. microsoft-github-policy-service commented on Nov 16, 2023

    @microsoft-github-policy-service
    Contributor

    This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.

  4. microsoft-github-policy-service commented on Nov 16, 2023

    @microsoft-github-policy-service
    Contributor

    This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.

  5. microsoft-github-policy-service commented on Nov 16, 2023

    @microsoft-github-policy-service
    Contributor

    This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.

  6. added
    Resolution-No Activity
    on Nov 16, 2023
  7. microsoft-github-policy-service commented on Nov 23, 2023

    @microsoft-github-policy-service
    Contributor

    This issue has been marked as "No Activity" as there has been no activity for 6 months. It has been closed for housekeeping purposes.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-DiscussionResolution-No ActivityWG-Engine-Providers

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions