haskell / cabal

Official upstream development repository for Cabal and cabal-install
https://haskell.org/cabal
Other
1.62k stars 697 forks source link

Help with $PATH masking troubles #3121

Open dcoutts opened 8 years ago

dcoutts commented 8 years ago

Very often users have cabal at /usr/bin and then they install a new one and are confused as to why the version apparently has not changed. We do warn if the installed exe is not on the $PATH at all (iirc) but we don't warn about masking. We should.

Also, in the specific case of cabal-install perhaps we should consider some trick to re-exec the right version. That is, if the user runs /usr/bin/cabal then it could simply re-exec ~/bin/cabal, possibly with a $PATH warning. This would not be too hard to do (though of course it relies on the system version not being too old), but we'd want to work out when it's right to do it, vs when the user really did mean to run the system version.

ezyang commented 8 years ago

On a somewhat related note, you get a spurious warning when PATH refers to a symlinked version of the directory in question; that should probably also be fixed.

23Skidoo commented 8 years ago

Sometimes it's useful to have several different versions of cabal-install in PATH, e.g. cabal-1.22, cabal-1.18, cabal-1.16. Automagic re-exec is unhelpful in this case.

dcoutts commented 8 years ago

@23Skidoo ok, but those cases can be detected because they're invoked with different names. There's no masking going on there. If we wanted to do this we'd need to work out what the policy we want is, and if we have enough information available to implement int.