You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix PATH changes not triggering REPL reconfiguration (#2015)
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
0 commit comments