Skip to content

Warn when creating switched without a default repository #6816

@reynir

Description

@reynir

Today I was trying to create a switch, and it failed with to me confusing error messages:

$ opam switch create . --deps-only -t

<><> Installing new switch packages <><><><><><><><><><><><><><><><><><><><><><>
Switch invariant: ["ocaml" {>= "4.05.0"}]
[ERROR] Could not determine which packages to install for this switch:
  * Missing dependency:
    - (invariant) -> ocaml
    unknown package

Switch initialisation failed: clean up? ('n' will leave the switch partially installed) [y/n] y
$ opam switch create . 4.14.2 --deps-only -t
[ERROR] No compiler matching `4.14.2' found, use `opam switch list-available' to see what is
        available, or use `--packages' to select packages explicitly.
$ opam switch list-available
# Listing available compilers from repositories: 
# No matches found

In the end it turned out that I had removed the default repository and added my own repository (using opam-mirror). I had used --all but not --set-default when adding the local repository. This then results in new switches to defaulting to no repositories and it makes sense it can't find ocaml when there are no package repositories. Only the last command really gave a hint of the cause, but it is somewhat ambiguous because it's not clear that it's an empty list and not just "here are the compilers I found:" colon.

I think it is very rare that it is desirable to create a switch without repositories - at least when the switch variant isn't [] - so I think it could improve the user experience to tell me that I probably made a mistake.

Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions