What is the correct way to upgrade the versions of Haskell programs installed on /usr/bin?

415 views Asked by At

I have the 3.0.1 version of Alex installed on my /usr/bin. I think the Haskell Platform originally put it there (although I'm not 100% sure...).

Unfortunately, version 3.0.1 is bugged so I need to upgrade it to 3.0.5. I tried using cabal to install the latest version of Alex but cabal install alex-3.0.5 it installed the executable on .cabal/bin over on my home folder instead of on /usr/bin

Do I just manually copy the executable to /usr/bin? (that sound like a lot of trouble to do all the time)

Do I change my PATH environment variable so that .cabal/bin comes before /usr/bin? (I'm afraid that an "ls" executable or similar over on the cabal folder might end up messing up my system)

Or is there a simpler way to go at it in general?

2

There are 2 answers

0
hugomg On BEST ANSWER

On second though, putting /.cabal/bin in front of /usr/bin in the PATH is simpler and is what most people do already.

Its also not a big deal since only cabal will put files in .cabal/bin so it should be predictable and with little risk of overwriting stuff.

1
Toxaris On

I want to first point out the layout that works well for me, and then suggest how you might proceed in your particular situation.

What works well for me

In general, I think that a better layout is to have the following search path:

  1. directories with important non-Haskell related binaries
  2. directory that cabal install installs to
  3. directory that binaries from the Haskell platform are in

This way, you can use cabal install to update binaries from the Haskell platform, but they cannot accidently shadow some non-Haskell related binary.

(On my Windows machine, this layout is easy to achieve, because the binaries from the Haskell platform are installed in a separate directory by default. So I just manually adapt the search path and that's it. I don't know how to achieve it on other platforms).

Suggestion for your particular situation

In your specific situation with the Haskell platform binaries already installed together with the non-Haskell related binaries, maybe you can use the following layout for the search path:

  1. directory containing links to some of the binaries in 3
  2. directory with important non-Haskell related binaries and Haskell platform binaries
  3. directory that cabal install installs to.

This way, binaries from cabal install cannot accidently shadow the important stuff in 2. But if you decide you want to shadow something form the Haskell platform, you can manually add a link to 1. If it's a soft link, I think you only have to do that once per program name, and then you can call cabal install for that program to update it. You could even look up what executables are bundled with the Haskell platform and do that once and for all.