Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Opam 2.0.8 doesn't pick new compiler variants when updating a repo #4558

Open
MisterDA opened this issue Feb 23, 2021 · 4 comments
Open

Opam 2.0.8 doesn't pick new compiler variants when updating a repo #4558

MisterDA opened this issue Feb 23, 2021 · 4 comments

Comments

@MisterDA
Copy link
Contributor

Hello,
I wanted to add an ocaml-variant with a patched compiler, so I forked opam-repository, added my variant, and added the repo to my opam install.
However, it seems that opam doesn't pick the new ocaml-variants from the repository. Worse: if I delete the default repo and re-add it, all the variants are lost and it becomes impossible to create new switches.
opam init --reinit doesn't fix the problem.

As suggested by @AltGr, selecting a repo when creating a switch works: opam switch create --repos=....

@kit-ty-kate noticed that opam 2.1 has the "expected" behaviour.

@AltGr
Copy link
Member

AltGr commented Feb 23, 2021

My guess is that the trouble comes from the slightly tricky interface of the added the repo to my opam install part; opam should warn you, but it's easy to miss the small-print: if you just run

$ opam repo add local /tmp/repo                  
[local] synchronised from file:///tmp/repo

<><> Upgrading repositories from older opam format ><><><><><><><><><><><><><><>
Upgrading repository "local"...
[NOTE] Repository local has been added to the selections of switch 4.05.0 only.
       Run `opam repository add local --all-switches|--set-default' to use it in all existing switches, or in newly created switches, respectively.

Where 4.05.0 was my currently selected switch. So this new repository will be ignored for new switches creation unless you add with --set-default ; that is why mentionning it in the switch create command through the --repos flag is probably better, unless you want it selected for all switches you are going to create in the future.

As I mentionned before, I agree that this interface gets confusing and should be improved, but I am not sure of how.

As for removing the default repository:

$ opam repo rem default        
Repositories removed from the selections of switch 4.05.0. Use '--all' to forget about them altogether.

Assuming you did use the --all flag, you would end up with no repository selected by default, hence the impossibility to create a new switch; we should probably add a message to be more helpful at this point, providing hints for the 2 solutions: either re-add a repository with --set-default, or use switch create --repositories=...

The above was all on 2.1 so I don't think there has been big changes since 2.0 ?

@AltGr
Copy link
Member

AltGr commented Feb 23, 2021

The most confusing part is probably that notion of "default selection" for repositories. Best if we could remove that altogether and:

  • if there is just one repository configured, use that
  • otherwise, make the --repos argument mandatory ?

As a more backwards-compatible mid-ground, we could make the default undefined initially, triggering the above behaviour, but still allow to define it explicitely. But ugh yet more complexity...

Additional note: opam repo addshould at least advise switch create --repos and not just more flags for repository add.

@rjbou
Copy link
Collaborator

rjbou commented Feb 23, 2021

related #4381

@dra27
Copy link
Member

dra27 commented Jul 2, 2021

It looks as though there's nothing different here between 2.0 and 2.1. Discussed today: possible iteration on @AltGr's suggestion might be to have a single default repository and no longer have a list of default repositories. So you can always add repositories to the global list, but to select anything other than one default repository when creating a switch you must use --repos.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants