Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run Haskell on OSX El Capitan

Tags:

macos

haskell

I just upgraded to Mac OSX El Capitan yesterday, finding that the method I used to run Haskell on terminal do not work anymore.

I used to run Haskell on terminal by typingcd (the path where my .hs file is in), then type ghci, and finally type :l (.hs file name)

But it told me that -bash: ghci: command not found when typing ghci.

So how could I run Haskell on El Capitan? I am not familiar with computer and am just learning some algorithms occasionally for fun, so please avoid technical terms and give me some clear steps to follow.

(I don't know wether it helps or not, I found this links, it suggests there is no need to reinstall the whole platform, but I don't know how to download and run the executable file it attached from github.)

like image 278
CYC Avatar asked Oct 03 '15 08:10

CYC


2 Answers

Haskell used to install itself to /usr/bin, which is incompatible with the new security features in El Capitan. Thus the El Capitan installer simply removed everything in /usr/bin that doesn't belong there.

The new Haskell installer in your link provides an alternative that correctly installs to the normal /usr/local/bin path. You can use it. Here are the instructions:

  1. Download the installer.
  2. Right-click and select "Open".
  3. Select "Open" again in the dialog box.

If you don't want to reinstall the whole Haskell platform, you can simply run the script from the same post, e.g. with the following command:

curl -fsSL https://raw.githubusercontent.com/mzero/haskell-platform/master/hptool/os-extras/osx/bin/activate-hs | sh
like image 123
emlai Avatar answered Oct 07 '22 17:10

emlai


If you had Haskell installed before the upgrade, you don't need to reinstall it.

For some reason the activate-hs script mentioned in the other solutions tries to create the symlinks in /usr/bin and /usr/share, which will fail because of SIP (I can't understand why the script does this).

However this script can easily be amended to create the symlinks in /usr/local/ instead. I have put an edited version of the script here (see lines 283 to 289).

If you are lazy and blindly trust me, you can just run the following:

curl -fsSL https://gist.githubusercontent.com/johnjcamilleri/1ed5db5eb4bd26a97afb/raw/654eda72af4cdb6f47f4fad3c7d7823449716007/activate-hs | sudo sh
like image 33
John J. Camilleri Avatar answered Oct 07 '22 18:10

John J. Camilleri