4

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?

Community
  • 1
  • 1
hugomg
  • 68,213
  • 24
  • 160
  • 246
  • 7
    Changing PATH so that `/.cabal/bin` is looked first is the best option. As os specific package manager usually puts up packages in `/usr/bin` so you shouldn't fiddle with it directly. – Satvik Aug 27 '13 at 03:43
  • @Satvik: Ive had people telling me that you shouldnt put your stuff before /bin and /usr/bin on the PATH variable. Are you sure? – hugomg Aug 27 '13 at 03:48
  • 1
    You shouldn't have installed alex in `/usr/bin` in the first place. The best way which I find is to install ghc and then install rest of the things using cabal. I know it came with the haskell platform but it also binds you to wait for the next release to update packages. I dont see any harm in the case for putting `.cabal/bin` before `/usr/bin`. – Satvik Aug 27 '13 at 04:26
  • 2
    @missingno The reason you're not supposed to do that, as far as I can see, is if you accidentally create an executable called e.g. `vim` in one of the other directories you are a little screwed, but then you can always explicitly refer to `/usr/bin/vim` if you need to when you fix it. – kqr Aug 27 '13 at 04:33

2 Answers2

3

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.

Toxaris
  • 7,156
  • 1
  • 21
  • 37
1

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.

hugomg
  • 68,213
  • 24
  • 160
  • 246