-
Notifications
You must be signed in to change notification settings - Fork 374
opam remove --force
no longer run commands in current directory
#6672
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
base: master
Are you sure you want to change the base?
Conversation
src/client/opamClient.ml
Outdated
List.fold_left (fun nothing_to_do atom -> | ||
nothing_to_do && force_remove atom) | ||
true not_installed |
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.
This changes the behaviour from "run force_remove for all elements of not_installed" to "[...] until it returns false". Is that expected?
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.
absolutely not!
List.fold_left (fun nothing_to_do atom -> | |
nothing_to_do && force_remove atom) | |
true not_installed | |
List.fold_left (fun nothing_to_do atom -> | |
force_remove atom && nothing_to_do) | |
true not_installed |
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 believe this can be simplified into:
List.fold_left (fun nothing_to_do atom -> | |
nothing_to_do && force_remove atom) | |
true not_installed | |
List.for_all force_remove not_installed |
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.
Wouldn't for_all
have the same issue than the first implem ?
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.
oops yes, my bad. Please use your suggestion instead
opam remove --force
no longer run commands in current directory
if not_installed = [] then true else | ||
if force then |
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.
if not_installed = [] then true else | |
if force then | |
if not_installed = [] then | |
true | |
else if force then |
src/client/opamClient.ml
Outdated
List.fold_left (fun nothing_to_do atom -> | ||
nothing_to_do && force_remove atom) | ||
true not_installed |
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.
oops yes, my bad. Please use your suggestion instead
OpamFilename.rmdir d; | ||
OpamFilename.mkdir d; |
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.
OpamFilename.rmdir d; | |
OpamFilename.mkdir d; | |
OpamFilename.cleandir d; |
OpamFilename.rmdir d; | ||
OpamFilename.mkdir d; |
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 think it would be nice to have a dedicated function in OpamFilename
that does that. It doesn't have to be optimized (only remove the directory content but not the directory if it exists already), but having it there simplifies things for whenever we will optimize it.
We have cleandir
already, maybe cleandir_create
or something like that
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.
Actually ignore what i just said, i think i would prefer to have this logic deeper in the code anyway. I don't think this should be done in OpamClient
(see dae8e6b). This way we avoid useless checks that were already done and we ensure the same logic applies everywhere the OpamAction
function is used
This is not ideal as it launches the removal of uninstalled packages before the resolving/apply of the request. But integrating those removal in the solution is not easy as it rely on installed state of package (not installed -> no op).
opam remove --force
launches remove commands in current directory #6570sed-cmd
#6675