@opam//here[:cmd]

Commands for controlling "here" switch, installed in <projroot>/.opam.

case 0: help

Action: @opam//here
$ bazel run @opam//here
...
Usage: bazel run @opam//here/init -- [args]
	args:
		-c	compiler version
		-s	switch name
		-x	dry-run
		-d	debug
		-v	verbose
	Default: uses compiler version listed in .obazl.d/here.compiler
        if found; otherwise prompts user.

case 1: fresh install from current switch

Initial conditions: no ./.obazl.d, ./.opam
$ ls .obazl.d
=> No such file or directory
$ ls .opam => No such file or directory
Action: init with currently active switch ($ opam switch show)
$ bazel run @opam//here/init
...
Current OPAM switch name is '4.13.0', configured with compiler version 4.13.0
Configure here-switch with compiler version 4.13.0? [Yn] Y
Begining OPAM processor output:
No configuration file found, using built-in defaults.

<><> Fetching repository information ><><><><><><><><><><><><><><><><><><><>  🐫
Processing  1/1: [default: http]
...
∗ installed ocaml.4.13.0
Done.
Postcondition status
<projroot> $ bazel run @opam//here/status
...
Postconditions
$ tree .obazl.d
.opam       (1)
├─ ...
...
├── here    (2)
...
└── repo
$ tree .opam
.opam       ##  OPAM installation
├─ ...
...
├── here    ##  "here" switch
...
└── repo

case 2: fresh install from other switch

Initial conditions: no ./.obazl.d, ./.opam; installed OPAM switches
$ bazel run @opam//here/status
...
@opam//here/status
	root:   .opam
	switch: here
Project-local OPAM root '.opam' not found.

$ opam switch
#  switch                    compiler                     description
   4.05.0                    ocaml-base-compiler.4.05.0   4.05.0
   4.06.0                    ocaml-base-compiler.4.06.0   4.06.0
   4.07.0                    ocaml-base-compiler.4.07.0   4.07.0
   4.07.1                    ocaml-base-compiler.4.07.1   4.07.1
   4.10                      ocaml-base-compiler.4.10.2   4.10
   4.11.1                    ocaml-base-compiler.4.11.1   4.11.1
   4.12.0                    ocaml-base-compiler.4.12.0   4.12.0
   4.13.0                    ocaml-base-compiler.4.13.0   4.13.0
→  4.13.1                    ocaml-base-compiler.4.13.1   4.13.1
   5.00.0+trunk              ocaml-variants.5.00.0+trunk  5.00.0+trunk
   _coq-platform_.2021.02.1  ocaml-base-compiler.4.07.1   _coq-platform_.2021.02.1
   myswitch                  ocaml-variants.4.14.1+trunk  myswitch

$ opam switch show
4.13.1
Action: init from other switch
$ bazel run @opam//here/init -- -s myswitch
Postcondition status
<projroot> $ bazel run @opam//here/status
...

case 3: fresh install specifying compiler version

Initial conditions: no ./.obazl.d, ./.opam
$ opam switch list-available
# Listing available compilers from repositories: default
# Name                                 # Version        # Synopsis
ocaml-option-32bit                     1                Set OCaml to be compiled in 32-bit mode for 64-bit Linux and OS X hosts
ocaml-option-afl                       1                Set OCaml to be compiled with afl-fuzz instrumentation
ocaml-option-bytecode-only             1                Compile OCaml without the native-code compiler
...
ocaml-base-compiler                    4.14.0           Official release 4.14.0
ocaml-variants                         4.14.0+options   Official release of OCaml 4.14.0
ocaml-variants                         4.14.1+trunk     Latest 4.14.1 development
ocaml-variants                         5.0.0+trunk      Current trunk
Action: init with specified compiler version
$ bazel run @opam//here/init -- -c 4.14.1+trunk
...
Begining OPAM processor output:
No configuration file found, using built-in defaults.

<><> Fetching repository information ><><><><><><><><><><><><><><><><><><><>  🐫
[default] Initialised
Begining OPAM processor output:

<><> Installing new switch packages <><><><><><><><><><><><><><><><><><><><>  🐫
Switch invariant: ["ocaml-variants" {= "4.14.1+trunk"}]

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><>  🐫
∗ installed base-bigarray.base
∗ installed base-threads.base
∗ installed base-unix.base
⬇ retrieved ocaml-variants.4.14.1+trunk  (https://github.com/ocaml/ocaml/archive/4.14.tar.gz)
∗ installed ocaml-variants.4.14.1+trunk
∗ installed ocaml-config.2
∗ installed ocaml.4.14.1
Done.
Postcondition status
$ bazel run @opam//here/status
@opam//here/status
	root:   .opam
	switch: here
Begining OPAM processor output:
prefix   <projroot>/.opam/here
lib      <projroot>/.opam/here/lib
bin      <projroot>/.opam/here/bin
sbin     <projroot>/.opam/here/sbin
share    <projroot>/.opam/here/share
doc      <projroot>/.opam/here/doc
etc      <projroot>/.opam/here/etc
man      <projroot>/.opam/here/man
toplevel <projroot>/.opam/here/lib/toplevel
stublibs <projroot>/.opam/here/lib/stublibs
user     <user id>
group    <grp name>
Begining OPAM processor output:
# Packages matching: installed
# Name         # Version
base-bigarray  base
base-threads   base
base-unix      base
ocaml          4.14.1
ocaml-config   2
ocaml-variants 4.14.1+trunk
...

case 4: prior installation

Initial conditions
<projroot> $ bazel run @opam//here/status
...
@opam//here/status
	root:   .opam
	switch: here
Begining OPAM processor output:
prefix   <projroot>/.opam/here
lib      <projroot>/.opam/here/lib
bin      <projroot>/.opam/here/bin
sbin     <projroot>/.opam/here/sbin
share    <projroot>/.opam/here/share
doc      <projroot>/.opam/here/doc
etc      <projroot>/.opam/here/etc
man      <projroot>/.opam/here/man
toplevel <projroot>/.opam/here/lib/toplevel
stublibs <projroot>/.opam/here/lib/stublibs
user     <user id>
group    <grp name>
Begining OPAM processor output:
# Packages matching: installed
# Name                # Version
base-bigarray         base
base-threads          base
base-unix             base
ocaml                 4.13.0
ocaml-base-compiler   4.13.0
...
Action: $ bazel run @opam//here/init
<projroot> $ bazel run @opam//here/init
OPAM here-switch already configured at root ./.opam, switch 'here', compiler: '4.13.0'.
Replace? [yN] N
cancelling here-switch init

<projroot> $ bazel run @opam//here/init
OPAM here-switch already configured at root ./.opam, switch 'here', compiler: '4.13.0'.
Replace? [yN] y
removing ./.opam
Your here switch is configured to use compiler version: 4.13.0 (specified in .obazl.d/opam/here.compiler)
Reconfigure using with same version? (if no, you will be prompted for a different version)
[Yn] n
Current OPAM switch name is '4.13.0', configured with compiler version 4.13.0
Configure here-switch with compiler version 4.13.0? [Yn] n
Which compiler version do you want to install? (<enter> to cancel) 4.11.0
Begining OPAM processor output:
No configuration file found, using built-in defaults.

<><> Fetching repository information ><><><><><><><><><><><><><><><><><><><>
[default] Initialised
Begining OPAM processor output:

<><> Installing new switch packages <><><><><><><><><><><><><><><><><><><><>  🐫
Switch invariant: ["ocaml-base-compiler" {= "4.11.0"} | "ocaml-system" {= "4.11.0"}]

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><>  🐫
∗ installed base-bigarray.base
∗ installed base-threads.base
∗ installed base-unix.base
⬇ retrieved ocaml-base-compiler.4.11.0  (https://opam.ocaml.org/cache)
∗ installed ocaml-base-compiler.4.11.0
∗ installed ocaml-config.1
∗ installed ocaml.4.11.0
Done.
Postcondition status
$ bazel run @opam//here/status
...
@opam//here/status
	root:   .opam
	switch: here
Begining OPAM processor output:
prefix   <projroot>/.opam/here
lib      <projroot>/.opam/here/lib
bin      <projroot>/.opam/here/bin
sbin     <projroot>/.opam/here/sbin
share    <projroot>/.opam/here/share
doc      <projroot>/.opam/here/doc
etc      <projroot>/.opam/here/etc
man      <projroot>/.opam/here/man
toplevel <projroot>/.opam/here/lib/toplevel
stublibs <projroot>/.opam/here/lib/stublibs
user     <user id>
group    <grp name>
Begining OPAM processor output:
# Packages matching: installed
# Name              # Version
base-bigarray       base
base-threads        base
base-unix           base
ocaml               4.11.0
ocaml-base-compiler 4.11.0
ocaml-config        1