-
Notifications
You must be signed in to change notification settings - Fork 841
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
How to use the original $PATH environment variable inside a stack execution #5055
Comments
@jneira maybe I'm missing here but it looks to me like your problem is caused by the following: |
@qrilka yeah, you have delimited it neatly, thanks. Only note that the problem is not in the |
But that's sounds to be against how Stack is working: with
|
Well, i agree that the most common use cases needs the actual behaviour. But i think the exposed one is reasonable too:
I think whatever script that want to manage external executables in a greceful way could hit this issue. So i would add it only as a cli option (and no global config) cause it only makes sense for very concrete stack exections. |
I think this whole idea of a "script that want to manage external executables" is very suspicious. If you want an external executable then you should not use/pollute implicit snapshot you're using otherwise this executable is not external anymore but something managed by Stack so it makes perfect sense that it's use is governed by Stack itself. So logically imho you shouldn't use the same implicit snapshot when installing |
Yeah, that could be a solution.
is no there a way to make snapshots isolated to avoid that situation? There is a |
Sorry for a very later reply. |
@qrilka No worries and thanks to take time to think about this somewhat edge case.
I see, thanks for point it out
Then could it be doable? I am afraid that i dont know stack internals enough to give it a try in a reasonable amount of time. 😟 |
Hi, our use case does not exist anymore (we dont handle cabal inside a stack execution anymore) and it seems that the use case was pretty uncommon so i think we can close this. @qrilka thanks for taking care of this and for your time |
@jneira just out of curiosity - what do you use now to install |
we simply are separating cabal and stack executions of the script and make users install cabal themselves (he): haskell/haskell-ide-engine#1557 |
Thanks |
Hi! I recently discovered that
stack
is modifying the$PATH
variable when you ran any command. More precisely it prepends to it{local-install-root}/bin
and{snapshot-install-root}/bin
.It is interfering with an actual use case in
haskell-ide-engine
. We are using a script to perform the installation of the tool and one of the commands installs the appropiate version ofcabal
inlocal-bin-dir
(that hopefully is in$PATH
).The issue is once you have installed it the first time,
stack
put it in{snapshot-install-root}/bin
and all subsequent calls to the script usingstack
use that cached version ofcabal
and no the original executable in user$PATH
(wherever it is).That behaviour causes:
cabal
executable in$PATH
after installing it with the script, another invocation doesn't copy again thecabal
executable, cause the version cached by stack is found (usingDirectory.findExecutable
).cabal
use that cached version and no the original one, so f.e. if you upgrade manually yourcabal
in$PATH
to3.0.0.0
the script will continue using the cached version, (currently2.4.1.0
)The unique workaround i've got is to manually remove those paths from
$PATH
and run allcabal
executions andDirectory.findExecutable
without them:Clearly it is an ugly and brittle hack so do you know another better way to accomplish it?
In case there is no one, could be added some way to optionally bypass the
stack
modifications of the$PATH
variable?(NOTE: i am aware that the modification of the
$PATH
variable is absolutely required to not break stack builds, optionally bypassing it only would make sense insidestack run script.hs
or maybestack exec whatever
. A possible improvement could be save the original path to another environment variable with a specific name)Stack version
Method of installation
The text was updated successfully, but these errors were encountered: