Skip to content
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

cabal repl: Change in PATH environment variable not reflected #2015

Open
arj opened this issue Jul 25, 2014 · 11 comments
Open

cabal repl: Change in PATH environment variable not reflected #2015

arj opened this issue Jul 25, 2014 · 11 comments
Labels
Cabal: cmd/repl can-workaround There is a (maybe partial) workaround for the issue or missing feature type: bug

Comments

@arj
Copy link

arj commented Jul 25, 2014

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"
@23Skidoo
Copy link
Member

Does this work in ghci for you?

@arj
Copy link
Author

arj commented Jul 25, 2014

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

@23Skidoo 23Skidoo added the repl label Aug 2, 2014
@ttuegel ttuegel added this to the cabal-install-1.24 milestone Apr 24, 2015
@23Skidoo 23Skidoo modified the milestones: cabal-install 1.24, cabal-install 1.26 Feb 21, 2016
@expipiplus1
Copy link

A simple workaround is to run cabal configure again.

@ezyang
Copy link
Contributor

ezyang commented Aug 16, 2016

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

@ndmitchell
Copy link

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

@nh2
Copy link
Member

nh2 commented May 18, 2017

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

@AlexeyRaga
Copy link

AlexeyRaga commented Apr 17, 2020

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?

@phadej
Copy link
Collaborator

phadej commented Apr 17, 2020

rm -rf dist-newstyle
...

@jneira jneira added can-workaround There is a (maybe partial) workaround for the issue or missing feature and removed old-milestone: cabal-install 2.0 labels Jul 10, 2022
@jneira
Copy link
Member

jneira commented Jul 10, 2022

... or cabal clean 😉
This continue being reproduced with v2 build (well no one has fixed it, but just in case)

This seems a more general issue that seemingly running cabal configure captures the $PATH and reuses it for subsequent steps.

I am not able to reproduce with cabal run or exec, only with cabal repl, so it may be a bug related with

@Profpatsch
Copy link

Wow. Wow.

@LightAndLight
Copy link

I ran into this issue today. I'm curious why this behaviour is even possible. Like, it's probably the consequence of a well-meaning feature. Anyone know?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Cabal: cmd/repl can-workaround There is a (maybe partial) workaround for the issue or missing feature type: bug
Projects
None yet
Development

No branches or pull requests