From ec3961ea6ca0ccf1b85c799f85ba779ab8e618ef Mon Sep 17 00:00:00 2001 From: Thomas Gazagnaire Date: Mon, 18 Mar 2024 14:06:24 +0100 Subject: [PATCH 1/2] Do not load the switch state to get the current OCaml version --- cli/pull.ml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/cli/pull.ml b/cli/pull.ml index 83719833a..b0bae11e8 100644 --- a/cli/pull.ml +++ b/cli/pull.ml @@ -75,16 +75,15 @@ let run (`Yes yes) (`Root root) (`Lockfile explicit_lockfile) D.Lockfile.ocaml_version lockfile |> Base.Result.of_option ~error:(`Msg "OCaml compiler not in lockfile") in - OpamSwitchState.with_ `Lock_none global_state @@ fun switch_state -> - let switch_ocaml_version = - OpamSwitchState.get_package switch_state D.Config.compiler_package_name - |> OpamPackage.version - in let* pulled = D.Pull.duniverse ~global_state ~root ~full ~preserve_symlinks:keep_symlinked_dir ~trim_clone:(not keep_git_dir) duniverse in + let* switch_ocaml_version = + let+ version = D.Exec.ocaml_version () in + OpamPackage.Version.of_string (Ocaml_version.to_string version) + in (match D.Opam.version_is_at_least locked_ocaml_version switch_ocaml_version with From 805d547924b63c4054a8b9989eb2e3167c772004 Mon Sep 17 00:00:00 2001 From: Thomas Gazagnaire Date: Mon, 18 Mar 2024 15:32:43 +0100 Subject: [PATCH 2/2] Add a CHANGE entry --- CHANGES.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 67dd18aa8..987cf0c07 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -10,6 +10,10 @@ - Fix support for pinned packages. In that case, it is not necessary to add dev-repo conflicts as `opam-monorepo` will always use the pinned repository. (#398, #353, @samoht, @reynir, reported by @emillon) +- Improve the speed of `opam monorepo pull`. Loading an switch state might take + a few seconds -- replace it with a call to `ocamlc --version` to check if the + lockfile is compatible with the currently available OCaml compiler + (#403, @samoht) ### Removed