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

Update old package definitions on system switches when opam detects the compiler has been upgraded #4031

Open
kit-ty-kate opened this issue Nov 25, 2019 · 2 comments
Assignees

Comments

@kit-ty-kate
Copy link
Member

With the following setup:

[has OCaml 4.08 installed system wide]
$ opam init
$ opam install ocamlfind.1.8.0
[upgrades OCaml to 4.09]
[optionally call opam update, but it doesn't matter]
$ opam install menhir # or whichever other package
# this will alert opam that ocaml has been upgraded
# and opam will first try to reinstall ocamlfind
# but will fail during uninstall because ocamlfind.1.8.0
# is not compatible with OCaml 4.09 and the remove field
# will call the configure script which calls ocaml -vthread
# which doesn't exist anymore in ocaml 4.09

Opam will fail because of two things: first it stores package definitions locally and doesn't update constraints of already installed packages and second, it doesn't actually check for dependencies constraints during uninstall (I tried with a custom package using opam pin edit and opam install --ignore-constraints-on=ocaml and the remove field was called despite being incompatible with the current version of the compiler)

To mitigate this issue, I propose we do two things:

  1. Urge the user to call opam update first (or even call opam update anyway) when in a system switch and opam is detecting a new OCaml compiler.

  2. Update the constraints on the ocaml package in the locally stored packages definitions (used to uninstall packages). If one of the installed packages is not compatible with the new OCaml compiler (and doesn't have the light-uninstall flag), then skip the remove phase entirely.

@AltGr
Copy link
Member

AltGr commented Nov 25, 2019

The first way to mitigate this kind of issues would be to remove the remove: fields, which is generally unneeded, or make it as small as possible in the other cases:

  • explicit remove: is basically only needed when during install you modify existing files
  • otherwise, it's best to comply with the light-uninstall package flag, i.e. not require the package source.

What I don't get is that, normally, failures during uninstall are printed but treated by opam as non-fatal (it will use a best-effort policy); and you seem to face a hard failure ?

Note 1: we have pending PRs improving the handling of modified system packages / system compilers
Note 2: you can force opam to update its definitions for already installed packages with opam reinstall --forget-pending (since opam detects the need for reinstallation by diffing the current and installed opam files, forgetting pending reinstalls is implemented by updating the latter with the former).

@dra27
Copy link
Member

dra27 commented Jul 19, 2021

Notes from meeting last Friday: ocamlfind no longer uses the remove section; @kit-ty-kate was going to double-check that:

  • System compiler @ ocaml 4.08 and ocamlfind.1.8.0 in the switch
  • Upgrade system compiler to 4.09
  • opam update

correctly upgrades ocamlfind (i.e. it doesn't attempt to reinstall ocamlfind.1.8.0)

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

No branches or pull requests

3 participants