fu7mu4’s diary

はてなダイアリーから移転しました。

macport ユーザーの OCaml のインストールあれこれ

twitterで Real World OCamlOcaml始めたら、OCamlだよ、Ocamlではないよと
そくつっこまれました。

とりあえず、Real World OCamlのインストール

sudo port install ocaml
sudo port install opam
opam init

とりあえず、fで回答

In normal operation, OPAM only alters files within ~/.opam.

During this initialisation, you can allow OPAM to add information to two
other files for best results. You can also make these additions manually
if you wish.

If you agree, OPAM will modify:

- ~/.bash_profile (or a file you specify) to set the right environment
variables and to load the auto-completion scripts for your shell (bash)
on startup. Specifically, it checks for and appends the following line:

. /Users/fu7mu4/.opam/opam-init/init.sh > /dev/null 2> /dev/null || true


- ~/.ocamlinit to ensure that non-system installations of `ocamlfind`
(i.e. those installed by OPAM) will work correctly when running the
OCaml toplevel. It does this by adding $OCAML_TOPLEVEL_PATH to the list
of include directories.

If you choose to not configure your system now, you can either configure
OPAM manually (instructions will be displayed) or launch the automatic setup
later by running:

opam config setup -a


Do you want OPAM to modify ~/.bash_profile and ~/.ocamlinit?
(default is 'no', use 'f' to name a file other than ~/.bash_profile)
[N/y/f]

Global configuration:
Updating ~/.opam/opam-init/init.sh
Updating ~/.opam/opam-init/init.zsh
Updating ~/.opam/opam-init/init.csh
Updating ~/.opam/opam-init/init.fish

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

1. To configure OPAM in the current shell session, you need to run:

eval `opam config env`

2. To correctly configure OPAM for subsequent use, add the following
line to your profile file (for instance ~/.bash_profile):

. /Users/fu7mu4/.opam/opam-init/init.sh > /dev/null 2> /dev/null || true

3. To avoid issues related to non-system installations of `ocamlfind`
add the following lines to ~/.ocamlinit (create it if necessary):

let () =
try Topdirs.dir_directory (Sys.getenv "OCAML_TOPLEVEL_PATH")
with Not_found -> ()
;;

eval `opam config env`

これですぐに使えるって

おっとしまった、そこからOCamlを opam switchで更新しないと

opam switch

で一覧を出して最新に切り替えよう。(2017年2月で 4.04.0 が最新のもよう)

opam switch 4.04.0

それから、

eval `opam config env`

して、おく。

それから Real World OCamlの実行環境用に core と utopをインストールするらしい。

opam install core utop