ocaml / setup-ocaml

GitHub Action for the OCaml programming language
https://ocaml.org/
MIT License
198 stars 38 forks source link

OCaml versions are not set correctly #50

Closed tmattio closed 3 years ago

tmattio commented 3 years ago

It seems that setup-ocaml is always using the latest version of OCaml, no matter which version is passed in ocaml-version. See this run for instance: https://github.com/rgrinberg/opium/runs/1465857399

The OCaml version setup by the setup-ocaml is 4.10.1, but the next step, which prints the version of the compiler with opam exec -- ocaml --version, tell us that we're still using 4.11.1.

I don't think I'm doing anything special, apart from caching the ~/opam directory, but the key is set to v1-${{ runner.os }}-opam-${{ matrix.ocaml-version }}-, so it should not have an impact on the OCaml version.

EDIT: I disabled the cache, and the OCaml version is set correctly, so it seems related to caching ~/opam. Since the key depends on the ocaml version, the only difference I see is the use of opam switch set ... vs opam switch create .... Is it possible the former does not set the environment correctly for the next steps?

tmattio commented 3 years ago

Turns out, I used --unlock-base to install the dependencies from the lock file with different OCaml version, but this caused opam to upgrade the ocaml-compiler in the switch. Using --ignore-constraints-on=ocaml instead solves the issue.