-bash: ghci: command not found (Haskell interactive shell, Haskell installation )
Asked Answered
T

3

6

edit : I ended up upgrading to macOS Catalina yesterday and replacing bash with zsh. One thing that should be noted is that the stackcommand worked previously, but despite all the tinkering not ghci After deleting all the files that had anything to do with Haskell, I retried running curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh This second time there was an error with the command line tools so I had to install them manually with xcode-select --install. After rerunning the curl, I added the path to the environmental file to my zsh profile manually with : . "$HOME/.ghcup/env"\ echo '. $HOME/.ghcup/env' >> "$HOME/.zshrc" Here is the content of the env file :export PATH="$HOME/.cabal/bin:/Users/agnel/.ghcup/bin:$PATH" Now everything seems to be working (I never reinstalled stack, but I think I might leave that to the side while I learn the basics of the language).

I installed the Haskell Platform yesterday but am having a hard time getting it to work correctly.

The firsts steps I did are:

  1. curl -sSL https://get.haskellstack.org/ | sh
  2. curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh

On step 1. the instructions said to append /Users/.../.local/bin the PATH variable (which I did in /etc/paths. On step 2, the script was supposed to pop up a dialog box (and didn't) when installing the necessary command line tools. It also said to rerun the script once complete (which I did). The script also said I should adjust my PATH variable, and source /Users/.../.ghcup/env in my shell configuration. It asked to this automatically but failed having not found the ~/.bashrc File. (I read that on Mac in contrary to linux, only .bash_profile is loaded upon opening of a terminal window so I adjusted the path variable there manually. I've spent forever messing around with the path variables and every time I try and run "$ ghci" I get the same -bash: ghci: command not found error message. If anyone has a solution to this problem I would be very grateful for an answer. If not, could someone with a working distribution of Haskell on their computer show me what their path variables look like? Thanks!

Tandem answered 19/8, 2020 at 8:22 Comment(2)
Have you tried to just do export PATH=$PATH:/dir/to/ghci ? if you echo $PATH and type which ghci (prior to the other steps) does it work?Akan
Can you edit your question to add the value of $PATH and show us the changes you've made to your config files?Halvorsen
T
8

A simple solution would just be to restart your terminal and you are good to go.

Trilemma answered 14/6, 2021 at 17:45 Comment(0)
F
7

After installing the Haskell platform for the first time on a new mac with Catalina, I also got

~> ghci
zsh: command not found: ghci

What worked in my case was to use, instead of the plain ghci,

stack ghci

To get back the familiar behaviour, I created in my homedirectory a file named .zshrc containing

alias ghci='stack ghci'

If you open a new terminal, this file will automatically be executed.

I'd be interested to know if there is another solution.

Fluter answered 22/8, 2020 at 4:11 Comment(0)
S
1

Check if the ghcup command is working or not.

  1. If not, make sure the .zshrc file has command for execution of ghcup. It should look something like this -

[ -f "/Users/myusername/.ghcup/env" ] && source "/Users/myusername/.ghcup/env" # ghcup-env

  • If the file exists, simply restarting terminal will work.
  • If it is still not working, set GHC as default using ghcup - follow this
Swiss answered 15/12, 2021 at 16:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.