cabal repl: Change in PATH environment variable not reflected

Created on 25 Jul 2014  路  8Comments  路  Source: haskell/cabal

Description

A change in the PATH environment variable is not visible in cabal repl.

Versions

Confirmed in versions:

  • Linux,
    cabal-install version 1.20.0.3,
    using version 1.20.0.1 of the Cabal library,
    ghc 7.6.3,
  • OS X 10.9,
    cabal-install version 1.18.0.5,
    ghc 7.8.3

Steps to reproduce

$ echo $PATH
/home/jakobro/.opam/4.01.0/bin:/home/jakobro/.cabal/bin:/home/jakobro/bin:/home/jakobro/.cabal/bin:/home/jakobro/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
$ export PATH=$PATH:/tmp
$ cabal repl
Prelude> :m Control.Monad System.Environment
Prelude Control.Monad System.Environment> liftM (lookup "PATH") getEnvironment 
Just "/home/jakobro/.opam/4.01.0/bin:/home/jakobro/.cabal/bin:/home/jakobro/bin:/home/jakobro/.cabal/bin:/home/jakobro/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"

The environment when accessed from cabal repl-based ghci does not reflect the change in the PATH variable.

It does work with newly created environment variables, though.

GHCI

In pure GHCI everything works fine:

$ echo $PATH
/home/jakobro/.opam/4.01.0/bin:/home/jakobro/.cabal/bin:/home/jakobro/bin:/home/jakobro/.cabal/bin:/home/jakobro/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/tmp
$ ghci
GHCi, version 7.6.3: http://www.haskell.org/ghc/  :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Prelude> :m System.Environment Control.Monad
Prelude System.Environment Control.Monad> liftM (lookup "PATH") getEnvironment 
Just "/home/jakobro/.opam/4.01.0/bin:/home/jakobro/.cabal/bin:/home/jakobro/bin:/home/jakobro/.cabal/bin:/home/jakobro/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/tmp"
cmrepl cabal-install 2.0 bug

Most helpful comment

A simple workaround is to run cabal configure again.

All 8 comments

Does this work in ghci for you?

Yes, it works within ghci. (see changes in first post)

A simple workaround is to run cabal configure again.

I can repro by calling repl directly on Setup script, so it must be a Cabal library bug.

This seems a more general issue that seemingly running cabal configure captures the $PATH and reuses it for subsequent steps. That's causing lots of surprise, e.g. https://gitlab.com/tim-m89/clr-haskell/issues/21

I just lost an hour trying to figure out why the getEnv "PATH" in my ghci is different than from the shell.

Looks like I am hitting the same issue with cabal 3.0.0.0.
I tried cabal configure workaround but it doesn't work.

Any other workarounds?

rm -rf dist-newstyle
...
Was this page helpful?
0 / 5 - 0 ratings