caml-list - the Caml user's mailing list
 help / Atom feed
* [Caml-list] Getting started with opam and "opam switch" (or: use "opam switch", you won't regret it)
@ 2019-02-22  6:13 Chet Murthy
  0 siblings, 0 replies; 1+ messages in thread
From: Chet Murthy @ 2019-02-22  6:13 UTC (permalink / raw)
  To: caml-list

[-- Attachment #1: Type: text/plain, Size: 2457 bytes --]

I've been using Ocaml (and before that, cam-light) for .... decades.  I've
always built the compiler+runtime from sources, and have a "BUILD-INSTALL"
script, lovingly maintained and updated over the years, to
download-and-install ocaml, findlib, oasis, other libraries, and recently,
opam too.  I've seen opam's "switch" command, but never used it.  It wasn't
obvious to me how to use it, so I just stuck to my old way of doing this
sort of setup, every time a new ocaml version came out.

Until today.  Today I decided to figure out how to use "opam switch". And
just in case there are other people who are reluctant, I figured I'd
document my experience, so others could cut-and-paste.  I'm sure inveterate
opam users will just skip past, but I figured, there might be some who
still haven't taken the plunge, so hey, here's a crib-sheet.

(1) install "opam" on Ubuntu

  % sudo apt-get install opam

(2) install Ocaml 4.07.1
--------------------------------------------------------------------------------
export VERSION=4.07.1

export OPAMROOT=$HOME/Hack/Ocaml/$VERSION

mkdir -p $OPAMROOT
echo "export OPAMROOT=$OPAMROOT" >> $OPAMROOT/dot.bashrc

opam init --dot-profile=$OPAMROOT/dot.bashrc \
    -j 32 \
    --yes \
    --bare \
    --inplace-build \
    --enable-completion \
    --enable-shell-hook \
    --shell-setup

eval $(opam env)

opam switch create ocaml-base-compiler.$VERSION
--repositories=default,beta=git+
https://github.com/ocaml/ocaml-beta-repository.git
--------------------------------------------------------------------------------
(2) install the latest beta (4.08.0+beta1)
--------------------------------------------------------------------------------
export VERSION=4.08.0+beta1

export OPAMROOT=$HOME/Hack/Ocaml/$VERSION

mkdir -p $OPAMROOT
echo "export OPAMROOT=$OPAMROOT" >> $OPAMROOT/dot.bashrc

opam init --dot-profile=$OPAMROOT/dot.bashrc \
    -j 32 \
    --yes \
    --bare \
    --inplace-build \
    --enable-completion \
    --enable-shell-hook \
    --shell-setup

eval $(opam env)

opam switch create ocaml-variants.$VERSION --repositories=default,beta=git+
https://github.com/ocaml/ocaml-beta-repository.git
--------------------------------------------------------------------------------

And to set up the environment in a shell for each of these installs, just
source the dot.bashrc in $OPAMROOT/dot.bashrc

I must say, this is ... *much* easier than "ocamlbrew", and that was
already pretty fricken' easy.

[-- Attachment #2: Type: text/html, Size: 3598 bytes --]

^ permalink raw reply	[flat|nested] 1+ messages in thread

only message in thread, back to index

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-22  6:13 [Caml-list] Getting started with opam and "opam switch" (or: use "opam switch", you won't regret it) Chet Murthy

caml-list - the Caml user's mailing list

Archives are clonable: git clone --mirror https://inbox.ocaml.org/caml-list

AGPL code for this site: git clone https://public-inbox.org/ public-inbox