How to install ocaml on Mac

help

#1

I have been trying to download ocaml on my Mac for about two hours, but I have failed. None of the guides I follow work for me, I must be doing something wrong. I’m very savvy when it comes to tech but I am really struggling right now. If anyone could help that would be great, thanks in advance.


#2

The OCaml installation page at OCaml.org gives commands for three package managers: Homebrew, Fink, MacPorts. Are you using one of those? If so, what happens when you try the commands listed on the page? (I have been using Homebrew for a few years now, personally, and have had little to no trouble installing OCaml.)


#3

Yes, I have been following those guides. Usually terminal just takes a long time to compute the commands and then once I get to certain steps it stops loading at all.


#4

What commands do you type and what does the output look like exactly?


#5

I’ll try again and come back with some screenshots of what’s going on.


#6

FWIW, cut/paste of command lines is better than screenshots, so other people can try the same commands.


#7

I’m using HomeBrew right now to install it, and so far the process is going much smoother.


#8



Where do I go from here?


#9

Using brew is usually pretty reliable for me.

brew install opam
opam init
eval `opam config env`
opam switch 4.06.1

I just received a work laptop which is a Mac running OSX and the above worked for me.


#10

Okay, running that now.


#11

#12

I would go ahead and check out the documentation for opam. The switch command will give you a sandboxed version of the ocaml compiler, and you can also use opam to install packages that you need later on.


#13

Your first call to brew install opam install opam was malformed. It needs to be just brew install opam. Then you should be able to follow the remainder of the steps:

opam init
eval `opam config env`
opam switch 4.06.1

#14


This is where I have ended up after using the above commands:

brew install opam

then

opam init
eval opam config env
opam switch 4.06.1


#15

From your gif it looks like you are entering multiple commands on the same line. Each line above denotes one command. Try to execute each command individually.


#16

i.e.

opam init <ENTER>
eval opam config env <ENTER>
opam switch 4.06.1 <ENTER>

#17

Okay, currently running the last command.


#18

This is where I am now, after running those commands.


#19

Looks to me like you are done!


#20

So I can code straight into terminal now, or is there an application I should be looking for at this point? Thanks for the help.