简体   繁体   中英

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

edit: I ended up upgrading to macOS Catalina yesterday and replacing bash with zsh. One thing that should be noted is that the stack command 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 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"\ . "$HOME/.ghcup/env"\ echo '. $HOME/.ghcup/env' >> "$HOME/.zshrc" 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 s how me what their path variables look like? Thanks!

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.

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM