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

Respect the "depext" field of global opam config #344

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

gridbugs
Copy link
Collaborator

Prior to this change, opam-monorepo will attempt to install external dependencies, even if this field is set to false.

@gridbugs
Copy link
Collaborator Author

The context for this change is that I was trying to do the mirage tutorial on nixos and was running into an error when opam-monorepo tried to check the status of depexts:

opam-monorepo: internal error, uncaught exception:
               Failure("External dependency handling not supported for OS family 'nixos'.")
               Raised at Stdlib.failwith in file "stdlib.ml", line 29, characters 17-33
               Called from CamlinternalLazy.force_lazy_block in file "camlinternalLazy.ml", line 31, characters 17-27
               Re-raised at CamlinternalLazy.force_lazy_block in file "camlinternalLazy.ml", line 36, characters 4-11
               Called from OpamSysInteract.packages_status in file "duniverse/opam/src/state/opamSysInteract.ml", line 224, characters 8-17
               Called from Duniverse_cli__Depext.run.(fun) in file "cli/depext.ml", line 29, characters 20-56
               Called from OpamGlobalState.with_ in file "duniverse/opam/src/state/opamGlobalState.ml", line 186, characters 14-18
               Re-raised at OpamStd.Exn.finalise in file "duniverse/opam/src/core/opamStd.ml", line 1372, characters 4-38
               Called from Cmdliner_term.app.(fun) in file "duniverse/cmdliner/src/cmdliner_term.ml", line 24, characters 19-24
               Called from Cmdliner_term.app.(fun) in file "duniverse/cmdliner/src/cmdliner_term.ml", line 22, characters 12-19
               Called from Cmdliner_eval.run_parser in file "duniverse/cmdliner/src/cmdliner_eval.ml", line 34, characters 37-44

Opam doesn't know how to install depexts on nixos, and even if it did, I'd rather it not mess with my system packages.

Possibly relevant to #258

@Leonidas-from-XIV
Copy link
Member

Thanks, could you also add a command line flag to control the setting? As-is it makes builds less reproducible as it reads more from opam settings (a thing that we're gradually trying to reduce to zero for higher reproduceability, with all settings controlled by the CLI/opam-files).

@Leonidas-from-XIV
Copy link
Member

(I am confused why even despite #323 you get this stacktrace, there is some kind of error still lurking in the code)

@gridbugs
Copy link
Collaborator Author

gridbugs commented Nov 1, 2022

(I am confused why even despite #323 you get this stacktrace, there is some kind of error still lurking in the code)

The stacktrace only prints out when I run opam-monorepo as an opam plugin. If I run opam-monorepo instead, the output is:

==> Using lockfile mirage/noop-unix.opam.locked
opam_monorepo.exe: [ERROR] External dependency handling not supported for OS family 'nixos'.

@gridbugs
Copy link
Collaborator Author

gridbugs commented Nov 1, 2022

Thanks, could you also add a command line flag to control the setting? As-is it makes builds less reproducible as it reads more from opam settings (a thing that we're gradually trying to reduce to zero for higher reproduceability, with all settings controlled by the CLI/opam-files).

I added a flag --disable-depext which causes the same behaviour as setting depext: false in the global config.

@Leonidas-from-XIV
Copy link
Member

I would suggest to make the flag --resolve-depext=true|false|config (or yes|no|auto, idk) with the default of config, that way it can be forced either way, without having to add more flags like --force-depext.

Prior to this change, opam-monorepo will attempt to install external
dependencies, even if this field is set to false.
@gridbugs
Copy link
Collaborator Author

gridbugs commented Nov 2, 2022

I would suggest to make the flag --resolve-depext=true|false|config (or yes|no|auto, idk) with the default of config, that way it can be forced either way, without having to add more flags like --force-depext.

Good suggestion. Updated!

Copy link
Member

@Leonidas-from-XIV Leonidas-from-XIV left a comment

Choose a reason for hiding this comment

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

Yes, this is nice. Some small comments on how to make it more consistent/readable but the concept is solid now.

@@ -17,7 +17,8 @@ let available_packages pkgs =
| available_pkgs, _not_found_pkgs -> Ok available_pkgs
| exception Failure msg -> Error (`Msg msg)

let run (`Root root) (`Lockfile explicit_lockfile) dry_run (`Yes yes) () =
let run (`Root root) (`Lockfile explicit_lockfile) dry_run resolve_depexts
Copy link
Member

Choose a reason for hiding this comment

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

Looks good, can you wrap this argument in a `` Resolve_depext constructor?

@@ -17,6 +17,7 @@
vendor (#321, @NathanReb)
- Display a better error message when the depext command fails when getting the
status of the packages (#258, #323, @RyanGibb, @Julow)
- Respect the "depext" config option when installing depexts (#344, @gridbugs)
Copy link
Member

Choose a reason for hiding this comment

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

This needs to be updated since it's configurable now.

The following packages may need to be installed manually:"
in
l "%s\n%s" message
(String.concat ~sep:"\n"
Copy link
Member

Choose a reason for hiding this comment

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

You can use Fmt.list ~sep:(Fmt.any "\n") string to avoid that concat.

Or even (untested, but I enjoy how much one can do with Fmt combinators):

let pp_sys_pkg = Fmt.of_to_string OpamSysPkg.to_string in
let pp_item ppf = Fmt.pf ppf "- %a" pp_sys_pkg in
l "%s\n%a" message (Fmt.list ~sep:(Fmt.any "\n") pp_item) (OpamSysPkg.Set.elements pkgs)

@Leonidas-from-XIV
Copy link
Member

I think @RyanGibb mentions a good point here. Maybe it makes no sense to call opam-monorepo depext if the depexts are not supposed to be computed? From a user perspective it might be rather strange to call opam-monorepo depext and then nothing happens because it was disabled in the configuration?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants