Skip to content

nushell is not compatible with lowercase path on windows #12676

Closed

Description

@mokeyish

Describe the bug

Some software installations seem to change Path into lowercase path, causing this BUG

How to reproduce

  1. Go to RegEditor
  2. HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment
  3. Rename Path as path
  4. Go to nushell, run which which

Expected behavior

Make nushell compatible with lowercase path.

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:37 +00:00
build_rust_channel release
allocator mimalloc
features default, sqlite, trash, which
installed_plugins

Additional context

No response

Activity

  1. added
    status:needs-triage
    on Apr 26, 2024
  2. fdncred commented on Apr 26, 2024

    @fdncred
    Contributor

    If either of these commands returns path vs Path on Windows, then that is a problem. I've seen it before.

    registry query --hklm 'SYSTEM\CurrentControlSet\Control\Session Manager\Environment'
    registry query --hkcu environment

    I've been told a few times that Windows Path isn't case-sensitive but case-preserving. So, if some crazy program makes it PaTh in those locations, Windows would probably use it. Seems like a bad idea to me to have anything except Path on Windows.

    We do have 2 PRs that try and make env vars case-insensitive, but they've bit-rotted a bit. It would be good if someone resurrected one of them and close these type of issues once and for all.

  3. added
    platform:windows
    A:environment
    on May 3, 2024
  4. yizhepku commented on May 10, 2024

    @yizhepku
    Contributor

    Now that #12701 has landed, what do we think of this? Do we want to support this specific use case?

    Currently, $env.path works, but the which command doesn't work because it uses nu_engine::env::path_str(), which fetches Path or PATH but not path.

  5. fdncred commented on May 10, 2024

    @fdncred
    Contributor

    @yizhepku ideally, in my perfect world, any case spelling of path would work everywhere throughout all nushell commands and custom command as well as across all operating systems that we support.

  6. fdncred commented on Nov 14, 2024

    @fdncred
    Contributor

    The problem I've seen recently is that HKCU will say path and HKLM will say Path. Having those two named different cause problems. I'm not sure how Windows works itself when they're different.

  7. ChrisDenton commented on Nov 14, 2024

    @ChrisDenton
    Contributor
  8. fdncred commented on Nov 14, 2024

    @fdncred
    Contributor

    If Windows doesn't care, we must have a bug in Nushell then. I thought we fixed that making it case insensitive but if the HKLM and HKCU are different it makes for problems. I guess it could be the rust implementation because I don't think we query any registry keys directly to get the path.

  9. ChrisDenton commented on Nov 14, 2024

    @ChrisDenton
    Contributor

    From my reading, Nushell didn't make it case insensitive, it just added a fallback for Path. So any other case will fail.

    /// On non-Windows: It will fetch PATH
    /// On Windows: It will try to fetch Path first but if not present, try PATH

  10. fdncred commented on Nov 14, 2024

    @fdncred
    Contributor

    Good point. We must of only made it that way in the repl and scripts because this works fine.

    ❯ $env.PaTh
    ╭────┬──────────────────────────────────────────────────────────────────────────────────╮
    │  0 │ C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\Llvm\x64\bin   │
    │  1 │ C:\Apps\carapace                                                                 │
    │  2 │ C:\Apps\Just                                                                     │
    │  3 │ C:\Program Files\PowerShell\7                                                    │
    │  4 │ C:\Program Files\Alacritty\                                                      │
    │  5 │ C:\Program Files\Microsoft\jdk-11.0.25.9-hotspot\bin                             │
    │  6 │ C:\Program Files\Common Files\Oracle\Java\javapath                               │
  11. added this to the v0.101.0 milestone on Dec 4, 2024
  12. added a commit that references this issue on Dec 4, 2024
    a332712
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:environmentplatform:windowsstatus:needs-triage

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions