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

Capricious solver on my machine #5911

Open
xvw opened this issue Apr 8, 2024 · 3 comments
Open

Capricious solver on my machine #5911

xvw opened this issue Apr 8, 2024 · 3 comments

Comments

@xvw
Copy link

xvw commented Apr 8, 2024

Trying to use merlin (in preview for 5.2.0), to work on merlin, I was forced to do a bit of manual installation:

When I try to install merlin on a local-switch on 5.2.0+beta1 with OPAM 2.2.0~beta1 I face to:

<><> Updating package repositories ><><><><><><><><><><><><><><><><><><><><><><>
[default] synchronised from https://opam.ocaml.org
Now run 'opam upgrade' to apply any package updates.
 xvw@xvw-thinkpad-x1  ~/Projects/tarides/merlin   handle-destruct-in-function-arg  ocaml --version
The OCaml toplevel, version 5.2.0~beta1
 xvw@xvw-thinkpad-x1  ~/Projects/tarides/merlin   handle-destruct-in-function-arg  opam install merlin
The following actions will be performed:
=== downgrade 3 packages
  ↘ ocaml               5.2.0 to 5.1.1       [required by merlin]
  ↘ ocaml-base-compiler 5.2.0~beta1 to 5.1.1 [required by ocaml]
  ↘ ocaml-compiler-libs v0.17.0 to v0.12.4   [uses ocaml]
=== recompile 37 packages
  ↻ base-bytes          base                 [uses ocaml]
  ↻ base-domains        base                 [uses ocaml]
  ↻ base-nnp            base                 [uses base-domains]
  ↻ cppo                1.6.9                [uses ocaml]
  ↻ csexp               1.5.2                [uses ocaml]
  ↻ dune                3.14.2               [uses ocaml]
  ↻ dune-configurator   3.14.2               [uses ocaml]
  ↻ lambda-term         3.3.2                [uses ocaml]
  ↻ logs                0.7.0                [uses ocaml]
  ↻ lwt                 5.7.0                [uses ocaml]
  ↻ lwt_react           1.2.0                [uses ocaml]
  ↻ menhir              20201216 (pinned)    [uses ocaml]
  ↻ menhirLib           20201216             [uses ocaml]
  ↻ menhirSdk           20201216             [uses ocaml]
  ↻ mew                 0.1.0                [uses ocaml]
  ↻ mew_vi              0.5.0                [uses ocaml]
  ↻ ocaml-config        3                    [uses ocaml-base-compiler]
  ↻ ocamlbuild          0.14.3               [uses ocaml]
  ↻ ocamlfind           1.9.6                [uses ocaml]
  ↻ ocplib-endian       1.2                  [uses ocaml]
  ↻ ppx_derivers        1.2.1                [uses ocaml]
  ↻ ppxlib              0.32.1~5.2preview    [uses ocaml]
  ↻ react               1.2.2                [uses ocaml]
  ↻ result              1.5                  [uses ocaml]
  ↻ seq                 base                 [uses ocaml]
  ↻ sexplib0            v0.16.0              [uses ocaml]
  ↻ stdlib-shims        0.3.0                [uses ocaml]
  ↻ topkg               1.0.7                [uses ocaml]
  ↻ trie                1.0.0                [uses ocaml]
  ↻ uchar               0.0.2                [uses ocaml]
  ↻ utop                2.14.0               [uses ocaml]
  ↻ uucp                15.1.0               [uses ocaml]
  ↻ uuseg               15.1.0               [uses ocaml]
  ↻ uutf                1.0.3                [uses ocaml]
  ↻ xdg                 3.14.2               [uses ocaml]
  ↻ yojson              2.1.2                [uses ocaml]
  ↻ zed                 3.2.3                [uses ocaml]
=== install 3 packages
  ∗ dot-merlin-reader   4.9                  [required by merlin]
  ∗ merlin              4.14-501
  ∗ merlin-lib          4.14-501             [required by merlin]

Proceed with ↘ 3 downgrades, ↻ 37 recompilations and ∗ 3 installations? [y/n] y

If I try to be more explicit:

opam install merlin.4.14-502~preview

I face to

 xvw@xvw-thinkpad-x1  ~/Projects/tarides/merlin   handle-destruct-in-function-arg  opam install merlin.4.14-502~preview
The following actions will be performed:
=== install 3 packages
  ∗ dot-merlin-reader 4.9              [required by merlin]
  ∗ merlin            4.14-502~preview
  ∗ merlin-lib        4.14-502~preview [required by merlin]

Proceed with ∗ 3 installations? [y/n] y

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
⬇ retrieved dot-merlin-reader.4.9  (cached)
⬇ retrieved merlin.4.14-502~preview, merlin-lib.4.14-502~preview  (https://opam.ocaml.org/cache)
∗ installed merlin-lib.4.14-502~preview
[ERROR] The compilation of dot-merlin-reader.4.9 failed at "dune build -p dot-merlin-reader -j 7".

#=== ERROR while compiling dot-merlin-reader.4.9 ==============================#
# context     2.2.0~beta1 | linux/x86_64 | ocaml.5.2.0 | https://opam.ocaml.org#f5e16063
# path        ~/Projects/tarides/merlin/_opam/.opam-switch/build/dot-merlin-reader.4.9
# command     ~/.opam/opam-init/hooks/sandbox.sh build dune build -p dot-merlin-reader -j 7
# exit-code   1
# env-file    ~/.opam/log/dot-merlin-reader-519987-d9efa9.env
# output-file ~/.opam/log/dot-merlin-reader-519987-d9efa9.out
### output ###
# Error: This expression has type
# [...]
#          list"
#        Type
#          "Merlin_dot_protocol.Directive.include_path" =
#            "[ `B of string
#            | `CMI of string
#            | `CMT of string
#            | `H of string
#            | `S of string ]"
#        is not compatible with type
#          "[< `B of string | `CMI of string | `CMT of string | `S of string ]"
#        The second variant type does not allow tag(s) "`H"



<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
┌─ The following actions failed
│ λ build dot-merlin-reader 4.9
└─
┌─ The following changes have been performed (the rest was aborted)
│ ∗ install merlin-lib 4.14-502~preview
└─

The former state can be restored with:
    /usr/bin/opam switch import "/home/xvw/Projects/tarides/merlin/_opam/.opam-switch/backup/state-20240408104518.export"

And @kit-ty-kate suggested I run this command, which works:

opam install merlin.4.14-502~preview dot-merlin-reader.4.14-502~preview

But as the solver seems capricious, he offered to fill in a ticket. If I can provide any further information, please don't hesitate!

OPAM report

# opam config report
# opam-version         2.2.0~beta1
# self-upgrade         no
# system               arch=x86_64 os=linux os-distribution=manjaro os-version=23.1.4
# solver               builtin-mccs+glpk
# install-criteria     -removed,-count[avoid-version,changed],-count[version-lag,request],-count[version-lag,changed],-count[missing-depexts,changed],-changed
# upgrade-criteria     -removed,-count[avoid-version,changed],-count[version-lag,solution],-count[missing-depexts,changed],-new
# jobs                 7
# repositories         1 (http), 2 (version-controlled) (default repo at f5e16063)
# pinned               1 (version)
# current-switch       /home/xvw/Projects/tarides/merlin
# invariant            ocaml >= 4.05.0
# compiler-packages    ocaml-base-compiler.5.2.0~beta1, ocaml-options-vanilla.1
# ocaml:native         true
# ocaml:native-tools   true
# ocaml:native-dynlink true
# ocaml:stubsdir       /home/xvw/Projects/tarides/merlin/_opam/lib/ocaml/stublibs:/home/xvw/Projects/tarides/merlin/_opam/lib/ocaml
# ocaml:preinstalled   false
# ocaml:compiler       5.2.0~beta1
@kit-ty-kate
Copy link
Member

I believe part of the problem is your invariant is too open. You currently have:

ocaml >= 4.05.0

which allows your current switch to be downgraded if the solver wants it to.

My guess as to why it happens is that opam doesn't currently work very well when there is a combination of such an open invariant and a compiler package that has the avoid-version flag. I'll have a closer look at it after the release of opam 2.2.0

@kit-ty-kate
Copy link
Member

We discussed this issue during today's dev meeting. We have discussed of several possible fixes and will have a go at it once we have more time after the release of 2.2.0.

@xvw
Copy link
Author

xvw commented Apr 8, 2024

Perfect, you where perfectly right about my invariant so it is not blocking!

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

No branches or pull requests

2 participants