News
I recently had to set up a fresh installation of OCaml, using OPAM, in my home directory on a Linux machine. I followed the hints given at https://ocaml.org/docs/install.html for installing OPAM, and used a simple OPAM command to execute to install OCaml.
Here is the summary of my installation, in case you want to do the same by yourself. Note that this procedure:
- does not require special rights (no root, no sudo)
- assumes that you have a directory named $HOME/bin (if not, create it using the command
mkdir $HOME/bin
)
1. Make sure there is no command named ocamlc in your PATH variable
Execute, in a terminal window:
type -p ocamlc
If there is no output, go on. If something is printer, then you need to set your PATH variable to a list of directories excluding the directory printed above. For instance:
export PATH=$HOME/bin:/bin:/usr/bin
2. Fetch the binary for OPAM and install it in $HOME/bin
wget https://raw.github.com/ocaml/opam/master/shell/opam_installer.sh -O - | sh -s $HOME/bin
If this does not work:
- find the correct binary at https://github.com/ocaml/opam/releases/tag/1.2.2
- download it into $HOME/bin
- make it executable (chmod a+x)
- and rename (or link) it as opam
3. Then, initialize your OPAM environment and install the (for instance) 4.04.0 OCaml release
$HOME/bin/opam init --comp=4.04.0
4. Install other OCaml packages
For instance:
$HOME/bin/opam install merlin tuareg ocp-indent
5. Check your shell environment
OPAM has asked for the right to modify your shell startup file (typically .bashrc). Your .bashrc file should now contain something like:
eval $(opam config env)
This is important: the OCaml commands are now located into $HOME/.opam/4.04.0/bin, and this directory should now occur in your PATH variable/.
To are now ready to use OCaml in a new shell terminal. Enjoy!
News feed: