Repository navigation
Conversation
The Windows getenv/putenv functions are case-insensitive, so when built for Windows nushell should also act this way to avoid many complicated conflicts. Fixes nushell#11154
|
I kind of like this idea. You could still make cross-platform scripts by always using upper-case, and it would still work on Windows. The only concern is that it is a breaking change, and makes Nushell behave differently on different platforms. But one principle of Nushell is to make it feel native on each platform, which doesn't necessarily mean uniform. So, for me, having case-insensitive env vars on Windows and case-sensitive on Unix if fine. Wasn't there a case on Windows that you could have either Path or PATH (or both) defined somehow? I wonder if that would break now. |
|
I added this one #11268 a while back and forgot about it. It makes |
|
I'm not a fan of this PR because it doesn't allow cross-platform case insensitivity. We could have |
|
On Unix, everything is expected case-sensitive. I wouldn't expect But clearly, this is something we need to discuss in the core team. |
Only across *nix OSes. We know PATH is not valid on Windows. Although I would agree that generally speaking, uppercase env vars is the default with the one exception, path. Why does Windows have to be so stupid. It's really aggravating sometimes. |
|
@fdncred it's important to look at the bug this fixes; I think you're over-focused on PATH here, but there are far more side effects of this problem. An excerpt from the reproduction in #11154:
These results are unpredictable, spurious and problematic. There's no portable solution to this problem in the general case - we have to make the behavior predictable in some manner otherwise it's just broken. Again, this isn't just about PATH. The unpredictability here comes from the HashDOS resistant HashMap backing these variables, and it means the behavior isn't even consistent across repeated runs. |
Windows 11 defaults have a variable named In a managed environment it's not uncommon to see the user ones replaced with a value defined as Similarly if you run |
|
I'll hold off fixing CI here until there's a decision on how to proceed. I'd run it locally inside WSL but didn't spot those issues, they look trivial to fix anyway. |
Yes, I meant env vars in general, not PATH, poorly worded. Maybe in addition to handling env vars on Windows case-insensitively, we could also special-case PATH/Path on Windows to ensure that only Path exists, i.e., Path is always passed to external programs spawned from Nushell even if you set |
|
My goal with all of this is to allow the user to not care about case sensitivity for env vars. I just started with path because it's the biggest problem. I'd really like to get away from Windows users having to know how their registry is configured for Path. I've seen many times that Windows isn't case-sensitive but case-preserving. So, if it's called PaTh in the two registry entries, that's what it'll be on your system, unfortunately. So, I'm up for whatever makes it easiest for all users across all platforms and I think that solution is to not care about the spelling case of env vars, and path in particular. |
|
In both of the last two comments there appears to be a suggestion that somehow nu will produce a canonical casing for
The point is that canonicalization is not particularly important, but may get in the way if a user is launching a program with specific (bad) expectations. Problems will not arise with general windows software using the Windows CRT, but problems do come up at times with non-native runtimes (python, ruby, node, go, etc). Most of those runtimes canonicalize to The only common canonicalization is My recommendation is:
|
|
So we're on board with it. Just to make it clear, the env vars on Windows should be case-preserving, meaning that This makes me think: What would happen on Windows if you set It would be great if you could add tests covering these cases (case-preserving and case-indiference on Windows). |
Windows environment variables are "case insensitive but case preserving". The above hits the "case preserving" part. If you start with |
|
Ah, yes, that makes sense. I'm fine with it, but as you can see, it's not immediately obvious, we should definitely put this into our documentation. |
|
Yup, as @ChrisDenton described. Thanks for taking the time to review the proposal @kubouch. I see there's a wait-until-after-release label - makes sense. When is the next release scheduled? (no urgency here, I'm just curious) I will get the PR updated ensuring that the bits CI caught are covered too. I'll look in devdocs/ and see if there's a sensible place to add some additional docs in this repo as well. |
9th of January - Just a few days from now |
|
Where are we at on this PR? |
|
@raggi did you run out of free time to help with this? |
|
any updates here? |
|
@raggi are you able to get back to this and fix it up as suggested above? |
|
Sorry @fdncred. I worked around the case that was continually causing me problems and inadvertently deprioritized coming back to this as a result - my bad. I can try to pick this up again one evening this week, or if someone else wants to do so I'm not in any way precious about my incomplete patch - I'd love to have this working. |
|
No worries at all @raggi. We understand that life happens. I just personally wanted something like this too so I'm hoping someone can push it over the finish line. I think it would be a great QoL add for nushell. |
|
closed in favor of #12701 |
|
Sorry for not making it, but thank you for finishing off this bug, very welcome change! |
The Windows
getenv/putenvfunctions are case-insensitive, so when built for Windows nushell should also act this way to avoid many complicated conflicts. A full description of the problem is in #11154.Fixes #11154
User-Facing Changes
On Windows systems, environment variable names are now case-insensitive. Reading from / writing to
PATHandPathandpathare the same.Tests + Formatting
Old special case implementation switcheroo from
PathandPATHis removed, but the test cases are not and still pass.New tests should likely be added, but sending the PR as-is for initial evaluation.
After Submitting
Path.