-
Notifications
You must be signed in to change notification settings - Fork 349
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
pre/post-session-commands ignored in switch config #4472
Comments
In fact pre/post session command are just not called. Thanks for the report! |
As an additional comment: It would be useful if these commands could be executed before/after the lock on the config file is acquired/released (this is currently not the behavior in the global config). That would allow for additional Opam commands/checks to be run. |
And thanks for the fix! |
It is not possible to lunch them before/after the lock. These lock are acquired on global/switch state load (ro/rw/none according the kind of action needed), usually at the beginning of an opam command. Pre/post session hooks are meant to be launched around sequence of actions (cf. manual), not at each command. Plus they can be conditioned by filter and embed/use some opam variables (installed, new, removed, etc.), those variables are resolved at a quite advanced moment, long after states are loaded. |
I was thinking that it might be possible to (1) acquire a lock, (2) evaluate the filters, (3) release the lock, (4) execute the pre session hooks (5) re-acquire the lock (6) run the main command sequence. But I suppose there is an opportunity for another opam command to obtain the lock in the meantime and screw things up. In the ideal situation, it should be possible to somehow lend the current lock to the pre/post session commands. But that would probably be quite difficult to realize... (This is not really an active feature request, but just some idle speculation.) |
yes, as you saw it, losing the lock could result on inconsistent state. Between (4) & (5) another process can change the switch, resulting on a need to recompute set of action, as the old one became invalid. And a new set of action, means reverting the presession command launched first and relaunching it with the new actions, that gives us a new (4) state, etc. Why do you need a lock free opam at pre/post sessions ? |
I'm the developer of Tactician, a machine learning plugin for Coq. I'm injecting some instrumentation code into the builds of Coq packages to learn from their proofs. This is actually working quite well now, but when my package is removed all of the instrumented packages should be recompiled again to reflect this. I'm trying to automate this. I know I should use (optional) dependencies for that, but that is not possible for my usecase. I would need to be able to declare an optional dependency from the dependency package and not the dependee for that to work, and it would have to be possible to enable/disable this dependency dynamically. I actually also tried adding a dependency dynamically to packages using (Note that I know this is a bit of an extreme thing to do, and as such, I don't really expect you guys to provide support for this.) |
Oh yup! We already talked on discuss :) I didn't recognized the username.
But after checking, In fact, there is a file in opam internals that permit to mark package to reinstall in One solution could be to add a removal target to
but in some distro it can not work as the binary can't be erased if in use... |
Ah, I didn't recognize you either :-)
The problem with that is, that there no printing allowed during removal, and there is no
Yes, I can indeed try that. I was thinking of combining that with a |
In Opam 2.0.7, adding a pre/post-session-commands command to a
switch-config
file has no effect (it does in the global config, however). For example, addingDoes not display
test
during installs, even when run in--verbose
mode.The text was updated successfully, but these errors were encountered: