-
Notifications
You must be signed in to change notification settings - Fork 710
Fix environment variable handling when running executables #10827
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
Conversation
b9f0466
to
5a21af6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, thanks for doing this.
30abd04
to
31a5c4d
Compare
Let me take the liberty of assuming this is ready for review and marking it so. |
We badly need the second review for this one. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, and a special thank you for the test.
31a5c4d
to
aec71cc
Compare
This fixes a bug where environment variables were duplicated when running executables. ``` overrideEnv <- fromMaybe [] <$> getEffectiveEnvironment ([("PATH", Just newPath)] ++ envOverrides) let shellEnv = overrideEnv ++ existingEnv ``` Since getEffectiveEnvironment already calls getEnvironment internally, if any overrides are passed then the result is a complete environment. Appending it to the already existing environment results in duplicated environment variables. The fix: * Added getFullEnvironment function to handle the common pattern correctly * Updated code in Bench, Test/ExeV10, Test/LibV09, and Client/Run to use this function In the future it would be good to generalise `getFullEnvironment` further so it can also handle the `addLibraryPath` case, which modifies an environment variable, rather than merely setting or unsetting it. Fixes #10718
Adds a simple test case that identifies and reports duplicate environment variables in the Cabal environment. For issue (#10718)
aec71cc
to
6e54b23
Compare
Am I right this should be backported to 3.14? Let me set the label tentatively. |
@mergify backport 3.14 |
✅ Backports have been created
|
…tables (#10887) * Fix environment variable handling when running executables This fixes a bug where environment variables were duplicated when running executables. ``` overrideEnv <- fromMaybe [] <$> getEffectiveEnvironment ([("PATH", Just newPath)] ++ envOverrides) let shellEnv = overrideEnv ++ existingEnv ``` Since getEffectiveEnvironment already calls getEnvironment internally, if any overrides are passed then the result is a complete environment. Appending it to the already existing environment results in duplicated environment variables. The fix: * Added getFullEnvironment function to handle the common pattern correctly * Updated code in Bench, Test/ExeV10, Test/LibV09, and Client/Run to use this function In the future it would be good to generalise `getFullEnvironment` further so it can also handle the `addLibraryPath` case, which modifies an environment variable, rather than merely setting or unsetting it. Fixes #10718 (cherry picked from commit 4375dd5) * Add test for duplicate environment variables when invoking testsuite Adds a simple test case that identifies and reports duplicate environment variables in the Cabal environment. For issue (#10718) (cherry picked from commit 6e54b23) --------- Co-authored-by: Matthew Pickering <[email protected]>
This fixes a bug where environment variables were duplicated when running executables.
Since getEffectiveEnvironment already calls getEnvironment internally, if any overrides
are passed then the result is a complete environment. Appending it to
the already existing environment results in duplicated environment variables.
The fix:
In the future it would be good to generalise
getFullEnvironment
further so it can also handle the
addLibraryPath
case, which modifiesan environment variable, rather than merely setting or unsetting it.
Fixes #10718.
Template Α: This PR modifies behaviour or interface
Include the following checklist in your PR:
significance: significant
in the changelog file.Template B: This PR does not modify behaviour or interface
E.g. the PR only touches documentation or tests, does refactorings, etc.
Include the following checklist in your PR: