-
Notifications
You must be signed in to change notification settings - Fork 365
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
Reinstall plugin package if the symlink is missing #4621
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
if cmd = None then | ||
raise Not_found | ||
else | ||
OpamPackage.package_of_name installed (OpamPackage.Name.of_string prefixed_name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Won't this cause problems if the currently installed version is no longer available ? This could happen e.g. with available:
depending on opam-version
after an opam root upgrade, where an upgrade of the plugin becomes mandatory, and cause an error during resolution, requiring a manual opam upgrade
.
I don't remember why this code used to force the latest version (within availability) though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It turns out it doesn't, but I think that's a bug - the availability check is not done for opam reinstall
!
The alternative would be to upgrade the package by name instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't remember why this code used to force the latest version (within availability) though
OPAM 1.x days? (easing or even avoiding the solver?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The candidates
package already have the availability check, so if a plugin is no more available it won't be in installed
and its latest version will be "newly" installed:
$ opam install opam-depext.1.1.3 #without opam < 2.1 condition
$ opam update # reintroduce opam < 2.1 condition
$ rm <link>
$ opam depext
Opam plugin "depext" is not installed. Install it on the current switch? [Y/n] y
opam-depext.1.1.5 is not installed. Install it? [Y/n] y
The following actions will be performed:
↗ upgrade opam-depext 1.1.3 to 1.1.5
<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
⬇ retrieved opam-depext.1.1.5 (cached)
⊘ removed opam-depext.1.1.3
∗ installed opam-depext.1.1.5
Done.
On the availability check for reinstall, this (specific) case is handled by the orphans
mechanism, and can't be reinstalled:
$ opam install opam-depext.1.1.3 #without opam < 2.1 condition
$ opam update # reintroduce opam < 2.1 condition
$ opam reinstall opam-depext
[ERROR] Sorry, these packages are no longer available from the repositories: opam-depext (= 1.1.3)
8818ed2
to
b60c8dc
Compare
Need to double-check the |
A rebase and good to merge for me! |
b60c8dc
to
8633e78
Compare
At present opam plugin will simply run opam-plugin if it is resolved in the environment of the current switch. Now $OPAMROOT/plugins/bin is checked for the required symlink. The command is still resolved as normal, but the presence or not of the symlink is used to control whether opam _installs_ the plugin package or does a reinstall. The reinstall both recreates the symlink and ensures that any changes to the plugin have been picked up.
8633e78
to
2c19103
Compare
I agree - the |
This is a partial fix for #4619 (the other part would be to remove the plugin symlinks at format upgrade).
This tweaks the plugin detection slightly so that if the symlink is missing, the command is still resolved, but package will be reinstalled in the current switch. This will recreate the symlink and also apply any changes to dependencies (e.g. after an opam client upgrade).
It's demonstrated by this slightly convoluted Dockerfile - commenting out the final
rm
command shows the existing error.