Skip to content

glob not working with windows paths #13249

Closed as duplicate
Closed as duplicate

Description

@TCROC

Describe the bug

Copying from Discord:

Found another issue. + simple but verbose workaround:

glob C:\some\folder\path/to/another/folder/*.zip

doesn't work. glob doesn't seem to like the C: and \ on Windows machines. However, this does work:

glob /C/some/folder/path/to/another/folder/*.zip

This error gets easily encountered when using environment variables that expand to C:\ such as $env.PWD.

glob $"($env.PWD)/to/another/folder/*.zip"

Workaround:

glob $"($env.PWD | str trim --left --char 'C' | str trim --left --char ':' | str replace --all "\\" "/")/to/another/folder/*.zip"

This one was simple enough to reproduce and describe so I'll go open a github issue for it now

How to reproduce

  1. Be on windows device
  2. run glob $"($env.PWD)/to/another/folder/*.zip
  3. See that you get an error about being unable to parse the path

Expected behavior

glob should support paths in windows format C:\path\to\folder\*.zip

Screenshots

No response

Configuration

key value
version 0.92.2
branch
commit_hash 2a08a18
build_os windows-x86_64
build_target x86_64-pc-windows-msvc
rust_version rustc 1.77.2 (25ef9e3d8 2024-04-09)
rust_channel 1.77.2-x86_64-pc-windows-msvc
cargo_version cargo 1.77.2 (e52e36006 2024-03-26)
build_time 2024-04-10 21:24:51 +00:00
build_rust_channel release
allocator mimalloc
features default, sqlite, trash, which
installed_plugins

Additional context

Thanks for the awesome tool! :)

Edit:

As pointed out by @sholderbach here, I posted the wrong version info. I reproduced this issue on my windows machine but submitted the issue report from my Linux machine. I'll correct this with the proper version info when I get around to booting up my Windows machine.

Edit:

The table / version info has been updated :)

Activity

  1. added
    status:needs-triage
    on Jun 27, 2024
  2. added
    deprecated:platform-specific
    A:glob
    on Jul 11, 2024
  3. sholderbach commented on Jul 11, 2024

    @sholderbach
    Member

    Do I see it correctly based on your version output that you are running on Linux but working on Windows paths there? I think we have several places where we make the assumption that you would only work with the system specific path separation rules (e.g. path split) could be that this is also true for glob

  4. TCROC commented on Jul 11, 2024

    @TCROC
    Author

    @sholderbach that is a mistake. I reproduced on my windows machine but submitted the bug from my linux machine. Hence I grabbed incorrect version info. But the error report still stands. I'll edit the original issue.

  5. TCROC commented on Jul 11, 2024

    @TCROC
    Author

    Thank you for catching that! :)

  6. sholderbach commented on Jul 11, 2024

    @sholderbach
    Member

    Ah OK, had hoped for one of those weird ones. Sounds like we need to get the basics right first :D

  7. added
    platform:windows
    on Jul 11, 2024
  8. TCROC commented on Jul 11, 2024

    @TCROC
    Author

    @sholderbach I updated the version info :) Thanks again! :)

  9. a-usr commented on May 15, 2026

    @a-usr

    For anyone looking at this, nushell now treats drive letters correctly in globs, but backwards-facing slashes still have to be replaced with forward-facing ones:

    let somePath = "C:\Some\absolute\or\relative\path";
    glob ($somePath | path expand | path join "*.txt" | str replace --all '\' '/');
    glob ($env.PWD | path join "*.txt" | str replace -a '\' '/')
  10. kronberger-droid commented on Nov 14, 2026

    @kronberger-droid
    Contributor

    The current glob is being replaced by the dc-glob backend, which is tracked in #18101.
    Backslashes as separators in patterns are part of that.

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

    A:globdeprecated:platform-specificplatform:windowsstatus:needs-triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions