Skip to content

Changes to PATH quietly ignored #6497

@hamishmack

Description

@hamishmack

Describe the bug
cabal v2-build caches the PATH environment variable and does not always pass on changes (perhaps unless they impact program selection). Other environment variable changes are passed on. This is confusing for tools like ghcjs-hsc2hs that wrap other executables and issue errors when they are not in the PATH. Updating the PATH and rerunning cabal v2-build does not work without a rm -rf dist-newstyle because cabal v2-build continues to use the old PATH.

To Reproduce
Steps to reproduce the behavior:

Here is an example of the new PATH value being ignored (while NOTPATH is not). Adding a bug to the source makes sure cabal prints the environment instead of just skipping the step that does that.

~/haskell$ cabal unpack hello
Unpacking to hello-1.0.0.2/
~/haskell$ cd hello-1.0.0.2
~/haskell/hello-1.0.0.2$ echo bug >> src/hello.hs 
~/haskell/hello-1.0.0.2$ cabal v2-build --verbose=3 2>&1 | grep HELLO
~/haskell/hello-1.0.0.2$ PATH=HELLO:$PATH cabal new-build --verbose=3 2>&1 | grep HELLO
~/haskell/hello-1.0.0.2$ NOTPATH=HELLO cabal new-build --verbose=3 2>&1 | grep HELLO
Environment: [[dump of the environment including HELLO]]

Expected behavior
I would have expected the Environment: to include HELLO in both cases, but it only does when the NOTPATH variable is set. Changes in PATH should be passed on to child processes even if they do not impact cabal's program selection.

System information

~/haskell/hello-1.0.0.2$ cabal --version
cabal-install version 3.0.0.0
compiled using version 3.0.0.0 of the Cabal library 
~/haskell/hello-1.0.0.2$ uname -a
Darwin MacBook-Pro-4.local 18.7.0 Darwin Kernel Version 18.7.0: Tue Aug 20 16:57:14 PDT 2019; root:xnu-4903.271.2~2/RELEASE_X86_64 x86_64
~/haskell/hello-1.0.0.2$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 8.6.5

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions