-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
augmentPathMap assumes uppercase PATH on windows #234
Comments
That's a good catch, and I'm surprised it (apparently) hasn't tripped anyone up yet. Is this a defensive issue, or has this popped up somewhere? I think some of the assumptions here may be incorrect. For example, env vars on Windows are fully case insensitive. To wit:
Note that the The main issue here seems to be that we're using |
Only in one of my PRs, trying to expose msys2 paths for calling a process: commercialhaskell/stack@ca7c249#diff-68447e366b1d0973dd0cffdc20410a4fadc6e575fe8aeb460375d1f2676946fdR663
Alright, sounds like you're agreeing to have a normalization function simply fold over the env var map. I can prepare a PR. |
Overall sounds right thanks! |
On windows, env vars are generally case-insensitive. Due to 'type EnvVars = Map Text Text' augmentPathMap assumes full uppercase "PATH" variable, which may lead to surprising behavior on if the current map has a variable such as "Path". This patch folds over the map and inserts any path key as "PATH" on windows. That also means: if there are multiple, the "last" one wins. There generally isn't a sane solution if the input map already has multiple path keys (how should they be merged, which order?). Fixes commercialhaskell#234
On windows, env vars are generally case-insensitive. Due to 'type EnvVars = Map Text Text' augmentPathMap assumes full uppercase "PATH" variable, which may lead to surprising behavior if the current map has a variable such as "Path". This patch folds over the map and inserts any path key as "PATH" on windows. That also means: if there are multiple, the "last" one wins. There generally isn't a sane solution if the input map already has multiple path keys (how should they be merged, which order?). Fixes commercialhaskell#234
On windows, env vars are generally case-insensitive. Due to 'type EnvVars = Map Text Text' augmentPathMap assumes full uppercase "PATH" variable, which may lead to surprising behavior if the current map has a variable such as "Path". This patch folds over the map and inserts any path key as "PATH" on windows. That also means: if there are multiple, the "last" one wins. There generally isn't a sane solution if the input map already has multiple path keys (how should they be merged, which order?). Fixes commercialhaskell#234
Copying comment from #235: Now I understand. This isn't the intended workflow when using |
Well, if it's just a documentation issue, then I'm confused why the existing stack code is affected by this bug.
|
Because that code should be modified. |
Well, that's known code... what about proprietary code we cannot fix? It's subtly broken. |
Please try to be more direct. This feels like word games currently. You've pointed out that a function in this library is used incorrectly in Stack. It's taken many comments to get to that point. Now the question is whether the function should be modified to be less efficient in all cases, or if the documentation should be updated to indicate correct usage of the function. It's a fairly standard engineering trade-off. Adding in that the situation is "confusing" just encourages time wastage around explanations, which I don't feel like engaging in. So: should the function be changed or not? I'm ambivalent. One final comment on this issue/PR situation. I clearly spelled out above what I thought would be an acceptable PR. It involved upper casing the keys. It turns out that (1) that already happens in the library and (2) your PR did nothing close to what I'd mentioned, and instead did the thing you'd already described. I'm giving one last chance for a productive dialogue here, otherwise I'm moving on. |
Projects (potentially proprietary ones we cannot fix with patches) may use the function in said "incorrect" way already. I'm pretty sure they don't regularly re-read the RIO documentation. The bug will go unnoticed. Documentation doesn't cause compile errors, doesn't show up in changelogs. How do we make sure codebases become aware of this? Updating documentation won't be enough. As such, I think the options are:
|
I've given it a bit more thought. I'm on board with your initial recommendation. Would you be able to reopen the PR and include a ChangeLog entry/minor version bump? |
On windows, env vars are generally case-insensitive. Due to 'type EnvVars = Map Text Text' augmentPathMap assumes full uppercase "PATH" variable, which may lead to surprising behavior if the current map has a variable such as "Path". This patch folds over the map and inserts any path key as "PATH" on windows. That also means: if there are multiple, the "last" one wins. There generally isn't a sane solution if the input map already has multiple path keys (how should they be merged, which order?). Fixes commercialhaskell#234
On windows, env vars are generally case-insensitive. Due to 'type EnvVars = Map Text Text' augmentPathMap assumes full uppercase "PATH" variable, which may lead to surprising behavior if the current map has a variable such as "Path". This patch folds over the map and inserts any path key as "PATH" on windows. That also means: if there are multiple, the "last" one wins. There generally isn't a sane solution if the input map already has multiple path keys (how should they be merged, which order?). Fixes commercialhaskell#234
On windows, env vars are generally case-insensitive. Due to 'type EnvVars = Map Text Text' augmentPathMap assumes full uppercase "PATH" variable, which may lead to surprising behavior if the current map has a variable such as "Path". This patch folds over the map and inserts any path key as "PATH" on windows. That also means: if there are multiple, the "last" one wins. There generally isn't a sane solution if the input map already has multiple path keys (how should they be merged, which order?). Fixes commercialhaskell#234
On windows, the Path variable may not be uppercase
PATH
, butPath
and is frequently returned as such by e.g.getEnvironment
and friends. Using it withaugmentPathMap
may then lead to confusing behavior, where a new key is added and gets ignored.To make this more robust, on windows, it should:
If there are multiple PATH keys, we're screwed. There could be a
normalizePathKeys :: EnvVars -> EnvVars
function that forces it to be upper-case and merges duplicate PATHs?Sth. like:
The text was updated successfully, but these errors were encountered: