There were approx. 10 compilers installed and related packages in the opam repository of a host.
It has been “broken” for unknown reason so the following message appeared:
$ opam switch list
[ERROR] Opam has not been initialised, please run `opam init'
The suggested command installed a new compiler:
$ opam init
No configuration file found, using built-in defaults.
...
<><> Creating initial switch 'default' (invariant ["ocaml" {>= "4.05.0"}] - initially with ocaml-base-compiler)
… but all the previous configuration became invisible before it was even completely installed:
$ opam switch list
# switch compiler description
default default
[NOTE] No switch is currently set, you should use 'opam switch <switch>' to set an active switch
Luckily, the previous ‘~/.opam’ directory was saved as '~/.opam ’ (with one trailing space - weird naming…).
How can I get my previous configuration back?
Can I safely delete the new dir and rename the old one from '~/.opam ’ to ‘~/.opam’?
I’m impressed by the size of the ~/.opam directory (120 GB for approx. 10 compilers&packages).
Are packages shared between theses configurations or duplicated?..
Side question: I’m tired of entering CLI opam commands with sometimes weird messages and surprising behaviors. Is there an OCaml API that makes possible to do opam management via a program?