caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Chet Murthy <murthy.chet@gmail.com>
To: caml-list <caml-list@inria.fr>
Subject: [Caml-list] Getting started with opam and "opam switch" (or: use "opam switch", you won't regret it)
Date: Thu, 21 Feb 2019 22:13:08 -0800	[thread overview]
Message-ID: <CA++P_gfxKBybb+51icACLB5AaOb1uMvsR5bErpkHWf=q8fZkVQ@mail.gmail.com> (raw)

[-- 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 --]

                 reply	other threads:[~2019-02-22  6:13 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CA++P_gfxKBybb+51icACLB5AaOb1uMvsR5bErpkHWf=q8fZkVQ@mail.gmail.com' \
    --to=murthy.chet@gmail.com \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).