0

I cannot seem to get the $PATH variable sourced in via /Users/chris/.ghcup/env so that I can directly use the ghc or ghci binary in zsh.

I installed ghc & cabal-install via ghcup: curl https://get-ghcup.haskell.org -sSf | sh as described on https://www.haskell.org/platform/mac.html / https://www.haskell.org/ghcup/

Hint during installation process:

It will add the 'cabal', 'ghc', and 'ghcup' executables to bin directory located at:

/Users/chris/.ghcup/bin

and create the environment file /Users/chris/.ghcup/env which you should source in your ~/.bashrc or similar to get the required PATH components.

...

In order to run ghc and cabal, you need to adjust your PATH variable. You may want to source '/Users/chris/.ghcup/env' in your shell configuration to do so (e.g. ~/.bashrc).

I can get the binaries to run after adding export PATH=/Users/chris/.ghcup/bin:$PATH to ~/.zshrc. However, from the hints during installation I am assuming that I should rather use the $PATH information automatically provided in /Users/chris/.ghcup/env.

Content of cat /Users/chris/.ghcup/env:

export PATH="$HOME/.cabal/bin:${GHCUP_INSTALL_BASE_PREFIX:=$HOME}/.ghcup/bin:$PATH"

How do I incorporate that into my .zshrc?

  • 1
    Just . /Users/chris/.ghcup/env? However, if you're on macOS, it would be slightly easier to install ghc via Homebrew, especially if you're already using Homebrew for other packages. – Kusalananda Nov 9 '19 at 16:44
  • @Kusalananda: Just add . /Users/chris/.ghcup/env it to .zshrc? Like this?: % cat .zshrc . /Users/chris/.ghcup/env – Chris Graf Nov 9 '19 at 16:53
  • That would source the file as part of sourcing .zshrc whenever an interactive zsh shell start, yes. – Kusalananda Nov 9 '19 at 16:56
  • @Kusalananda: thanks that flxed it. You can post that as an answer if you want to also get the credit for helping. Also, I was trying to get around Homebrew as I read that versions are not always up-to-date and there might be other differences. – Chris Graf Nov 9 '19 at 16:57
  • The most recent version of GHC is 8.8.1 (25 August 2019). This is also the version available through Homebrew on macOS. The GHC people themselves mentions installing the software via Homebrew (see here). They don't seem to recommend it, but there is no reasoning mentioned. – Kusalananda Nov 9 '19 at 17:17
1

You want to source the file /Users/chris/.ghcup/env from your ~/.zshrc file. This can be done by using the dot (.) utility in your ~/.zshrc file like so:

. /Users/chris/.ghcup/env

If /Users/chris is your home directory, then this may be shortened to

. ~/.ghcup/env
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.