tarides / opam-monorepo

Assemble dune workspaces to build your project and its dependencies as a whole
ISC License
130 stars 27 forks source link

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

Open gridbugs opened 2 years ago

gridbugs commented 2 years ago

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

gridbugs commented 2 years ago

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 https://github.com/tarides/opam-monorepo/issues/258

Leonidas-from-XIV commented 2 years ago

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 commented 2 years ago

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

gridbugs commented 2 years ago

(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 commented 2 years ago

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 commented 2 years ago

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.

gridbugs commented 2 years ago

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!

Leonidas-from-XIV commented 2 years ago

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?