Skip to content

Conversation

rjbou
Copy link
Collaborator

@rjbou rjbou commented Sep 4, 2025

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).

Comment on lines 2439 to 2441
List.fold_left (fun nothing_to_do atom ->
nothing_to_do && force_remove atom)
true not_installed
Copy link
Member

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?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

absolutely not!

Suggested change
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

Copy link
Member

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:

Suggested change
List.fold_left (fun nothing_to_do atom ->
nothing_to_do && force_remove atom)
true not_installed
List.for_all force_remove not_installed

Copy link
Collaborator Author

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 ?

Copy link
Member

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

@rjbou rjbou marked this pull request as ready for review September 5, 2025 16:13
@rjbou rjbou requested a review from kit-ty-kate September 5, 2025 16:15
@rjbou rjbou changed the title opam remove --force` no longer run commands in current directory opam remove --force no longer run commands in current directory Sep 5, 2025
@rjbou rjbou added the PR: QUEUED Pending pull request, waiting for other work to be merged or closed label Sep 5, 2025
@rjbou rjbou added this to the 2.5.0~alpha1 milestone Sep 5, 2025
Comment on lines +2418 to 2419
if not_installed = [] then true else
if force then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if not_installed = [] then true else
if force then
if not_installed = [] then
true
else if force then

Comment on lines 2439 to 2441
List.fold_left (fun nothing_to_do atom ->
nothing_to_do && force_remove atom)
true not_installed
Copy link
Member

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

Comment on lines +2429 to +2430
OpamFilename.rmdir d;
OpamFilename.mkdir d;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
OpamFilename.rmdir d;
OpamFilename.mkdir d;
OpamFilename.cleandir d;

Comment on lines +2429 to +2430
OpamFilename.rmdir d;
OpamFilename.mkdir d;
Copy link
Member

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

Copy link
Member

@kit-ty-kate kit-ty-kate Sep 5, 2025

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
KIND: BUG PR: QUEUED Pending pull request, waiting for other work to be merged or closed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

opam remove --force launches remove commands in current directory
2 participants