I want to try multicore ocaml with opam 2.0. I can’t use the default multicore opam repo because the update from 1.2.x goes wrong (ussue on github) and I can’t see the switch in the available list. So I tried to create a 2.0 repo myself but without much success: a new switch still not available.
Where is the manual about adding a new compiler to opam 2.0?
That looks correct to me! That has been reverted since, but at some point it was required to issue opam switch list-available --all to include available variants: are you using the last beta ?
You could check that the package is available (not considering its compiler status) using opam list, too. If it appears there, you can force its use as compiler with opam switch create my-multicore-switch --packages=ocaml-variants.4.02.2+multicore
Thanks, I managed to install compiler. But new opam interface is … weird.
Are you trying to say that while creating new switches opam by default looks only into default repo?
With repositories configurable per-switch, we keep a selection of repos for each switch, plus one for the defaults when creating new switches. All can be set independently, but the default for opam repo add is to add only to the current switch (in the first version I had it add to current and default, but it wasn’t better).
I am not sure how to make it more intuitive. Maybe the default should be to update all switches + default on opam repo add, and have a different command for fine-tuning (opam switch repo add … ?)
OTOH, in this example, you probably didn’t want to add the repo globally, so the last command really was what you were after.
Another, more verbose but more self-explanatory way could be to add no selections on opam repo add, requiring them to be explicit:
$ opam repo add foo https://...
Repository `foo` was added.
NOTE: no switch is yet configured to use this repository. Use
`opam repo add foo --this-switch|--switch SW|--all|--set-default`
to select it, or create a new switch using it with
`opam switch create --repositories=foo,{current default}`
My idea was to make it as simple as possible in the simpler case (just one switch), but at least the above would have saved you the confusion.
I think that adding to all switches by default is not a good idea and will lead to surprises with local switches (which I guess opam may not know about when you add).
However I do think that opam repo as it exists is quite confusing. I tried to make a few suggestions here.
It may be simpler to use ; but I am fairly sure this isn’t actually what you want in general, so in the best case you are adding repositories with packages that you won’t use and are harmless — like in your case. In the worst case you want to try out something in a test switch, and add weird package alternatives to your main dev switches, which might lead to confusing behaviour.
The idea is that, with local switches and all, we are trying to have more isolation between switches: having a default that could affect them all when you might have just wanted to test something in your test switch seems dangerous.
Do you think that it is a good idea to add a mesage in the end of opam switch list-available saying The listed switches are from the repo blah. You can specify other repos using switch --bla-bla ?