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

Fix behaviour of menu and depexts in non-interactive environments #5295

Merged
merged 3 commits into from
Oct 12, 2022

Conversation

AltGr
Copy link
Member

@AltGr AltGr commented Sep 22, 2022

The rationale is now to assume the "no" case in the menus whenever there is no input to read from.

and check_again t sys_packages =
let needed, _notfound = OpamSysInteract.packages_status sys_packages in
let needed, _notfound = OpamSysInteract.packages_status ~env sys_packages in
Copy link
Member Author

Choose a reason for hiding this comment

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

This one was well hidden, but at least one test caught it. Maybe the parameter shouldn't have been optional 😬

Copy link
Member

Choose a reason for hiding this comment

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

Totally agree! Optional parameters should be avoided as much as possible IMO.

let installed = OpamSysPkg.Set.diff sys_packages needed in
let t, sys_packages =
map_sysmap (fun sysp -> OpamSysPkg.Set.diff sysp installed) t, needed
in
if OpamSysPkg.Set.is_empty sys_packages then t else
(OpamConsole.error "These packages are still missing: %s\n"
(syspkgs_to_string sys_packages);
entry_point t sys_packages)
if OpamStd.Sys.tty_in then entry_point t sys_packages
else give_up ())
Copy link
Member Author

Choose a reason for hiding this comment

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

Always avoid looping if we don't read from a tty

@AltGr
Copy link
Member Author

AltGr commented Sep 22, 2022

As mentionned in private, this is more restrictive when running non-interactively but better reflects what I had in mind when adding the menu. I am open to discussion if it has some unwanted effects though, esp. since different workarounds have been proposed in the meantime.

@dra27 dra27 added this to PR in progress in Opam 2.2.0 via automation Sep 26, 2022
@dra27 dra27 added this to the 2.2.0~alpha milestone Sep 26, 2022
@rjbou rjbou moved this from PR in progress to PR to review in Opam 2.2.0 Sep 27, 2022
Copy link
Collaborator

@rjbou rjbou left a comment

Choose a reason for hiding this comment

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

thanks!

@rjbou rjbou moved this from PR to review to PR finalised (merge with CI) in Opam 2.2.0 Oct 12, 2022
@rjbou
Copy link
Collaborator

rjbou commented Oct 12, 2022

The new mechanism is good for me! clearer and more local

@rjbou rjbou merged commit b00153e into ocaml:master Oct 12, 2022
Opam 2.2.0 automation moved this from PR finalised (merge with CI) to Done Oct 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Opam 2.2.0
  
Done
Development

Successfully merging this pull request may close these issues.

None yet

4 participants