ocaml / opam

opam is a source-based package manager. It supports multiple simultaneous compiler installations, flexible package constraints, and a Git-friendly development workflow.
https://opam.ocaml.org
Other
1.23k stars 351 forks source link

opam's solver strange results with version constraints #465

Closed smondet closed 11 years ago

smondet commented 11 years ago

With the cannonical opam-repo (at 0fbd60c762a81f4f0c53c6fe12f1c3f583fa3d8b), opam 0.9.2, and after a fresh switch to 4.00.1:

core 109.09.00 seems available

$ opam info core
...
  available-versions: 108.00.02, 108.07.00, 108.07.01, 109.07.00, 109.09.00

 $ cat packages/core.109.09.00/opam | grep ocaml-version
ocaml-version: [>= "4.00.1"]

but

 $ opam install core

wants to install 109.08.00.

but forcing seems to work:

 $ opam install core.109.09.00
.... <works> ...
 $ opam list -i | grep core
core           109.09.00  Industrial strength...

but then the solver wants to downgrade:

  $ opam upgrade
The following actions will be performed:
 - recompile base-unix.base [upstream changes]
 - recompile base-bigarray.base [upstream changes]
 - downgrade type_conv.109.09.00 to 109.08.00 [required by core]
 - recompile base-threads.base [upstream changes]
 - downgrade bin_prot.109.09.00 to 109.08.00 [required by core]
 - downgrade comparelib.109.09.00 to 109.08.00 [required by core]
 - downgrade fieldslib.109.09.00 to 109.08.00 [required by core]
 - downgrade pa_ounit.109.09.00 to 109.08.00 [required by core]
 - downgrade pipebang.109.09.00 to 109.08.00 [required by core]
 - downgrade sexplib.109.09.00 to 109.08.00 [required by core]
 - downgrade variantslib.109.09.00 to 109.08.00 [required by core]
 - downgrade core.109.09.00 to 109.08.00
0 to install | 3 to reinstall | 0 to upgrade | 9 to downgrade | 0 to remove
Do you want to continue ? [Y/n] n

or the solver gets lost and timeouts (and this time it wants to downgrade to yet an older version of the core family):

 $ opam install core_extended
....................... brute-force exploration timed-out [11646 states, 5s].
You might need to add explicit version constraints to your request to get a better answer.
The following actions will be performed:
 - install pcre-ocaml.6.2.5 [required by core_extended]
 - downgrade type_conv.109.09.00 to 108.07.01 [required by core_extended]
 - downgrade bin_prot.109.09.00 to 108.07.01 [required by core_extended]
 - downgrade comparelib.109.09.00 to 108.07.01 [required by core_extended]
 - downgrade fieldslib.109.09.00 to 108.07.01 [required by core_extended]
 - downgrade pa_ounit.109.09.00 to 108.07.01 [required by core_extended]
 - downgrade pipebang.109.09.00 to 108.07.01 [required by core_extended]
 - downgrade sexplib.109.09.00 to 108.07.01 [required by core_extended]
 - downgrade variantslib.109.09.00 to 108.07.01 [required by core_extended]
 - downgrade core.109.09.00 to 108.07.01 [required by core_extended]
 - install core_extended.108.07.01
2 to install | 0 to reinstall | 0 to upgrade | 9 to downgrade | 0 to remove
Do you want to continue ? [Y/n] n

PS: This error message can be quite misleading:

 $ opam install core.109.09
Version 109.09 of "core" is incompatible with your compiler or your OS.
samoht commented 11 years ago

HEAD's solver should give much better results. Could you try to see if there are some improvements ?

Also, the error message should also see fixed (see #463).

smondet commented 11 years ago

Is HEAD supposed to work with 0.9.2 ~/.opam/ trees?

 $ opam switch list
'opam switch' failed.
Fatal error: exception File "src/client/opamSwitchCommand.ml", line 30, characters 20-26: Assertion failed

Apart from that, yes the initial issue seems solved.

opam upgrade got all the 109.09.00 packages, and also uninstalling everything, and installing core and core_extended again gets the expected packages

But I had to restart the re-installations because of ocamlfind install errors

First time:

$ opam install core
...
### stderr ###
ocamlfind: Conflict with another package: Library dllcore_stubs.so is already installed

then the second time it works (had to restart also for failures in dependencies like pipebang, and ounit too)

samoht commented 11 years ago

It seems that you have installed OCaml with OPAM (or you don't have ocaml in your PATH). Is the contents of your CAML_LD_LIBRARY_PATH seems to be the one you'd expect ?

samoht commented 11 years ago

(I've pushed a fix for you first error)

samoht commented 11 years ago

Or you have a very old ~/.opam tree (with a bad /.opam/compilers/system.comp). Mine looks like:

opam-version: "1"
name: "system"
version: "4.00.1"
packages: ["base-unix" "base-bigarray" "base-threads"]
env: [
  [CAML_LD_LIBRARY_PATH = "%{lib}%/stublibs:/usr/local/lib/ocaml/stublibs"]
]
preinstalled: true
smondet commented 11 years ago

Indeed, I had removed the system compiler. I will try again later with a fresh .opam/.

PS: I always do: install ocaml in /tmp, compile opam with it, then opam switch <another one> and opam switch remove system and delete the initial ocaml installation.

smondet commented 11 years ago

Hi, I still get the first error (with tag 0.9.3):

I just did

opam init
opam switch --yes 4.00.1
opam switch remove system
opam upgrade --yes

and now:

opam switch
'opam switch' failed.
Fatal error: exception File "src/client/opamSwitchCommand.ml", line 30, characters 20-26: Assertion failed
smondet commented 11 years ago

If I put back an ocaml compiler in the $PATH, then it works again:

 $ opam switch
4.00.1  C 4.00.1                     Official 4.00.1 release
--     -- 3.11.2                     Official 3.11.2 release
--     -- 3.12.1                     Official 3.12.1 release
.... etc. ....
--     -- 4.01.0dev+trunk            latest trunk snapshot
--     -- system                     System compiler (4.00.1)
samoht commented 11 years ago

The Fatal error: exception File "src/client/opamSwitchCommand.ml", line 30, characters 20-26: Assertion failed has unfortunately shipped with 0.9.3 but it is fixed in 0.9.4. So closing the issue (btw, 0.9.4 also containts some solver heuristics improvements).