-
Notifications
You must be signed in to change notification settings - Fork 379
Document how opam chooses the default compiler during opam init and opam switch create #6778
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -437,3 +437,31 @@ We don't recommend using it in day-to-day use of opam in the shell, because | |||||||||||||||||||||||||||||||||
| you'll be typing more and you won't get to notice exciting new features! If the | ||||||||||||||||||||||||||||||||||
| behaviour of a command or option is altered, and you write something which in no | ||||||||||||||||||||||||||||||||||
| longer valid, opam will try to tell you what the new command should look like. | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| --- | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| #### 🐫 How does `opam init` and `opam switch create <version>` know which compiler package to choose? | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| Since opam 2.4, `opam init` will choose `ocaml-base-compiler` as default | ||||||||||||||||||||||||||||||||||
| compiler for the `default` switch, and let the solver choose the latest | ||||||||||||||||||||||||||||||||||
| version. Of course this default can always be changed using `--compiler` | ||||||||||||||||||||||||||||||||||
| or by skipping the creation of the `default` switch all-together with | ||||||||||||||||||||||||||||||||||
| `--bare`. | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| For example if you would rather use the OCaml compiler that you have | ||||||||||||||||||||||||||||||||||
| installed by other means, you can use the `ocaml-system` package as follows: | ||||||||||||||||||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
? |
||||||||||||||||||||||||||||||||||
| `opam init --compiler=ocaml-system`. Be careful though, system-wide compilers | ||||||||||||||||||||||||||||||||||
| can be setup in a way that the default opam-repository doesn't expect, | ||||||||||||||||||||||||||||||||||
| so failures may occur. Thus this option should only be used if you know | ||||||||||||||||||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
? |
||||||||||||||||||||||||||||||||||
| what you're doing. | ||||||||||||||||||||||||||||||||||
|
Comment on lines
+451
to
+456
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| `opam switch create <version>` on the other hand, works slightly differently. | ||||||||||||||||||||||||||||||||||
| Since the only unknown is: which package is going to be used. | ||||||||||||||||||||||||||||||||||
|
Comment on lines
+458
to
+459
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||||||
| Opam decides this by looking at all the packages that have been tagged as | ||||||||||||||||||||||||||||||||||
| `compiler`, filter which ones have the right version, and then let the solver | ||||||||||||||||||||||||||||||||||
| decide. For example calling `opam switch create 5.4 5.4.0` will create a | ||||||||||||||||||||||||||||||||||
| switch named `5.4` and look for compiler packages with versions `5.4.0` which | ||||||||||||||||||||||||||||||||||
| by default, with [opam-repository](https://github.com/ocaml/opam-repository/), | ||||||||||||||||||||||||||||||||||
| will get back with `ocaml-base-compiler.5.4.0` and `ocaml-system.5.4.0`. | ||||||||||||||||||||||||||||||||||
| Since 2025, `ocaml-system` is tagged as `avoid-version` so the solver will | ||||||||||||||||||||||||||||||||||
| choose `ocaml-base-compiler.5.4.0`. | ||||||||||||||||||||||||||||||||||
|
Comment on lines
+460
to
+467
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
(although I can't remember for certain why ocaml-base-compiler.5.4.0 is guaranteed to be selected, given that it actually has more dependencies than ocaml-variants.5.4.0+options) |
||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.