This guide contains step-by-step instructions for building and running Hazel.
If you are unfamiliar with ocaml or opam or get stuck, we recommend you
follow these instructions instead of the shorter instructions in
README.md.
-
If you are on Windows, install the Windows Subsystem for Linux (WSL).
-
If you are on MacOS, you probably want to have Homebrew installed.
-
Make sure
gcc,git,make,nodejs, andm4are installed.-
If you are on Ubuntu or WSL + Ubuntu, you can do this by running the following commands:
sudo apt update sudo apt install gcc git make m4 nodejs pkg-config
-
If you are on MacOS, we recommend using the built-in
m4(i.e., not the one from Homebrew).You can install the remaining programs (i.e.,
gcc,git,node, andmake) by running the following commands:brew update brew install gcc git make node pkg-config
-
-
Install the most recent version of
opam(which must be at least 2.0):-
If you are on Ubuntu Linux 19.04 (disco) or later, you can do this by running the following commands:
sudo apt update sudo apt install opam
-
If you are on MacOS, you can do this by running the following commands:
brew update brew install opam
-
-
Check that you have the correct version of
opamby running the following command:opam --version
This should report version 2.0 or greater. If it does not, the following instructions may not work.
-
Initialize
opam, by running:-
If you are on WSL:
opam init github git+https://github.com/ocaml/opam-repository.git
-
If you are on Linux or MacOS:
opam init
-
-
Enable
opamfor the current shell with the following:eval $(opam env)
-
You may want to put that line into your
~/.zshrcfile (default on recent Macs) and~/.bashrc(used by the VS Code shell) so you don't have to run it again every time you open a new shell.
You can use either a global opam switch or a switch local to the Hazel source directory.
-
Update the list of available
opampackages:opam update
-
Install OCaml 5.2.0 (see the "Current version" section of
Updating.mdfor why we may not use the newest version of OCaml).opam switch create 5.2.0 ocaml-base-compiler.5.2.0
-
Update the current switch (OCaml environment):
opam switch 5.2.0 eval $(opam env)
If you are working on multiple OCaml projects, it may be helpful to set up a local Opam switch. You can do so as follows:
opam update
opam switch create ./ 5.2.0
eval $(opam env)
make deps-
Pick a directory that you want to be the parent of the directory that contains the Hazel source code and use the
cdcommand to change to that directory. -
Clone a copy of the source code.
You should first make sure you have GitHub SSH keys setup. Then you can run the following command to clone Hazel:
git clone git@github.com:hazelgrove/hazel.gitNOTE: We do not recommend cloning using https, because this will not allow you to contribute back to Hazel without going through some even more awkward hoops. If you want to quickly get Hazel cloned without setting up SSH keys, we recommend using the GitHub Desktop application or the Visual Studio Code command "Git Clone", which will set things up for you in the background.
-
Use the
cdcommand to change to the directory containing the Hazel source code. If you just ran thegit clonecommand, you can do this by running the following command:cd hazel -
Run the following to install the necessary OCaml library dependencies:
make deps
It is a good idea to run
make depswhenever you pull new versions of the code from GitHub so you can be sure that you have the latest dependencies installed.
You can now go back to README.md and follow the instructions there to build and run Hazel.