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

Failure to remove the last repository in a switch #4381

Closed
craigfe opened this issue Oct 7, 2020 · 2 comments · Fixed by #4435
Closed

Failure to remove the last repository in a switch #4381

craigfe opened this issue Oct 7, 2020 · 2 comments · Fixed by #4435

Comments

@craigfe
Copy link

craigfe commented Oct 7, 2020

On 2.1.0~alpha3, it's not possible to remove the only repository in a switch, but the user messages and exit codes do not suggest as such.

❭ mkdir /tmp/opam-no-remove-default
❭ cd /tmp/opam-no-remove-default
❭ opam switch create ./ --empty
❭ opam repo
[NOTE] These are the repositories in use by the current switch. Use '--all' to see all configured repositories.

<><> Repository configuration for switch /tmp/opam-no-remove-default ><><><><><>
 1 default https://opam.ocaml.org

❭ opam repo remove default
Repositories removed from the selections of switch /tmp/opam-no-remove-default. Use '--all' to forget about them altogether.

❭ opam repo
[NOTE] These are the repositories in use by the current switch. Use '--all' to see all configured repositories.

<><> Repository configuration for switch /tmp/opam-no-remove-default ><><><><><>
 1 default https://opam.ocaml.org

I'd expect opam repo remove default to either fail with an appropriate error message or to actually remove the default repository from the switch.

@rjbou
Copy link
Collaborator

rjbou commented Oct 7, 2020

It is the normal opam behaviour, the opam repo remove documentation should be more precise on this one.
In fact, opam won't let switch with no repository (if there is a default one defined). So when the switch unique repository is removed, it sets the global config default one. In this case, you deleted the default and it has been replaced by the default.

@AltGr
Copy link
Member

AltGr commented Jan 15, 2021

The behaviour seems to be a remnant from the code that was used to migrate from older opam roots without switch-specific repositories; I see no reason to forbid repository-less switches (although they probably won't be useful). But least surprise, etc.

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

Successfully merging a pull request may close this issue.

4 participants