Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

-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 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!

like image 574
Richard Feynman Avatar asked Aug 19 '20 08:08

Richard Feynman


People also ask

How do I run Haskell with GHCi?

Open a command window and navigate to the directory where you want to keep your Haskell source files. Run Haskell by typing ghci or ghci MyFile. hs. (The "i" in "GHCi" stands for "interactive", as opposed to compiling and producing an executable file.)

How do I install Haskell on Windows?

To set up Haskell environment on your Windows computer, go to their official website https://www.haskell.org/platform/windows.html and download the Installer according to your customizable architecture. Check out your system's architecture and download the corresponding setup file and run it.


3 Answers

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.

like image 138
Alexander Kurz Avatar answered Oct 19 '22 21:10

Alexander Kurz


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

like image 22
Amar Prakash Pandey Avatar answered Oct 19 '22 21:10

Amar Prakash Pandey


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
like image 42
ash Avatar answered Oct 19 '22 21:10

ash