Fix PATH changes not triggering REPL reconfiguration (#2015)#10817
Merged
mergify[bot] merged 1 commit intomasterfrom May 24, 2025
Merged
Fix PATH changes not triggering REPL reconfiguration (#2015)#10817mergify[bot] merged 1 commit intomasterfrom
mergify[bot] merged 1 commit intomasterfrom
Conversation
530f1f8 to
faff622
Compare
faff622 to
9fd36c6
Compare
Member
|
Is this ready for review? If so, could you please add the label? |
Collaborator
Author
|
Any reviewers? @ulysses4ever ? 1 week without movement, so I am happy to just merge it if no-one wishes to review. |
Collaborator
|
Sorry for slow progress here: everyone was busy with the release. I'll try to take a look today. I don't think it's possible to merge anything without reviews. Unless you're going to change repository settings, which is a big change for the project and should be discussed on a meeting. |
ulysses4ever
approved these changes
Apr 10, 2025
Collaborator
ulysses4ever
left a comment
There was a problem hiding this comment.
I'd suggest that you mention in the commit message why adding a new field, seemingly unused anywhere, changes the behaviour (it's because of the Generic business afaiu).
geekosaur
approved these changes
Apr 10, 2025
Member
|
@mpickering: would you like to respond and then set the merge label maybe? |
906f0f6 to
9efbc01
Compare
When a user's PATH environment variable changes between Cabal commands, the environment in the REPL becomes incorrect. This occurs because during initial package configuration, the current PATH is captured via `programSearchPathAsPATHVar` and then stored in the `programOverrideEnv` field of a ConfiguredProgram. These `ConfiguredProgram`s are subsequently serialized into the setup-config file, effectively baking in the PATH environment from the time of configuration. The issue manifests when `PATH` is updated after initial configuration. Although the solver re-runs when detecting `PATH` changes, the `dryRunLocalPkg` function examines `ElaboratedConfiguredPackage` and incorrectly determines that nothing has changed that would require reconfiguration. This decision is incorrect because `setup-config` now contains a stale reference to the original `PATH` value, which no longer matches the current environment. To fix this problem, we need to store the `ConfiguredProgram`s directly in `ElaboratedConfiguredPackage`. This approach will ensure that when `PATH` changes, the `ConfiguredProgram`s will also change, properly triggering reconfiguration. While this solution will cause more recompilations when `PATH` changes, it guarantees that the correct environment is always used during builds and REPL sessions. An alternative approach would be to stop baking the `PATH` variable into the environment of programs, but this would require more substantial changes to how Cabal manages environment variables. Fixes #2015
9efbc01 to
cf4083b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When a user's PATH environment variable changes between Cabal commands, the environment in the REPL becomes incorrect. This occurs because during initial package configuration, the current PATH is captured via
programSearchPathAsPATHVarand then stored in theprogramOverrideEnvfield of a ConfiguredProgram. TheseConfiguredPrograms are subsequently serialized into the setup-config file, effectively baking in the PATH environment from the time of configuration.The issue manifests when
PATHis updated after initial configuration. Although the solver re-runs when detectingPATHchanges, thedryRunLocalPkgfunction examinesElaboratedConfiguredPackageand incorrectly determines that nothing has changed that would require reconfiguration. This decision is incorrect becausesetup-confignow contains a stale reference to the originalPATHvalue, which no longer matches the current environment.To fix this problem, we need to store the
ConfiguredPrograms directly inElaboratedConfiguredPackage. This approach will ensure that whenPATHchanges, theConfiguredPrograms will also change, properly triggering reconfiguration. While this solution will cause more recompilations whenPATHchanges, it guarantees that the correct environment is always used during builds and REPL sessions.An alternative approach would be to stop baking the
PATHvariable into the environment of programs, but this would require more substantial changes to how Cabal manages environment variables.Fixes #2015
Please read Github PR Conventions and then fill in one of these two templates.
Template Α: This PR modifies behaviour or interface
Include the following checklist in your PR:
significance: significantin the changelog file.