Install inconsistency ghcup and stack

I am just starting to learn Haskell.

On Linux I installed using ghcup. I then installed stack as the ghcup install page for the generic Linux instructions (https://www.haskell.org/platform/linux.html#linux-generic) suggest. One inconsistency is that the ghcup install page itself (https://www.haskell.org/ghcup/) makes no mention of stack.

ghcup was done as an ordinary user (as the web page says) but for stack I had to use sudo which surprised me (and requires more trust). Anyway, I installed stack but then got a warning:

WARNING: '/home/mark/.local/bin' is not on your PATH.
    For best results, please add it to the beginning of PATH in your profile.

This made no sense because although ~/.local/bin isn’t on my PATH, stack was installed to /usr/local/bin/stack and /usr/local/bin is on my PATH. (Or course, I’d have rather it didn’t need sudo and was actually installed in ~/.local/bin.)

The instructions for getting a generic Linux Haskell development environment set up are confusing to me. In particular this section:

The recommended way to install the components of the generic platform is using ghcup to install ghc and cabal-install, and following the instructions at haskellstack.org to install stack.

It seems like it’s saying: “First install ghcup, then install Stack.” However I think what it means is: “You should either install ghcup, or install Stack.” In general, Stack manages your GHC installation, so you don’t need to use ghcup to do that if you’re going to use Stack.

As for the PATH thing, Stack is warning you about executables installed with Stack, not the stack executable itself. If you run stack install pandoc, Stack will build Pandoc and put the executable in ~/.local/bin. Since that isn’t on your PATH, you won’t be able to run pandoc in your shell without giving it the fully qualified path, like /home/mark/.local/bin/pandoc.

5 Likes

As a complete noob to Haskell, I would have to agree that start up leaves a bit of a bad taste. I followed the instructions to install ghcup. Then I installed Haskelly into VS Code and discovered I was missing “slack”. Looking back that directions I too saw “and install stack” so I went and did it and as I was doing stack setup it asked to download GHC again!

Preparing to install GHC to an isolated location.
This will not interfere with any system-level installation.
ghc-8.8.3: 24.97 MiB / 259.72 MiB ( 9.61%) downloaded…

Why stack are you not using my system-level installation I installed with gshup? Am I going to install another version of GHC each time I make a new project? Enquiring minds want to know. Should I remove the .gshup folder? Will there be conflicts? Sigh…

Update. Good news it is smart enough:

tim@Tims-MBP hello % stack setup
stack will use a sandboxed GHC it installed

2 Likes