Stream: Dune devs & users

Topic: Is it normal `-p` ignores dependencies?


view this post on Zulip Paolo Giarrusso (Jul 10 2022 at 17:01):

Silly Q: If b depends on a and I run dune build -p b, is it expected the result differs from -p a,b? Is the point that -p b assumes a is installed already? This behavior does not seem Coq-specific, I get errors on both executables and Coq theories that live in a.

view this post on Zulip Paolo Giarrusso (Jul 10 2022 at 17:25):

I've first noticed this together with Coq theory composition — with dune build -p b, Cob

view this post on Zulip Emilio Jesús Gallego Arias (Jul 11 2022 at 13:40):

Yes, that's the whole point of -p

view this post on Zulip Emilio Jesús Gallego Arias (Jul 11 2022 at 13:40):

to build the package against installed deps

view this post on Zulip Emilio Jesús Gallego Arias (Jul 11 2022 at 13:40):

see the docs. Note you can do -pa,b

view this post on Zulip Emilio Jesús Gallego Arias (Jul 11 2022 at 13:40):

we are still missing user-contrib support so that's useless for Coq unfortunately

view this post on Zulip Rudi Grinberg (Jul 11 2022 at 13:41):

Why are you using -p anyway?

view this post on Zulip Paolo Giarrusso (Jul 11 2022 at 13:52):

I can use that with a slight hack — if I install a, for now I can patch out mentions of a's theories in b. Emilio's right and that doesn't scale, but it's still better than coq_makefile in my scenario

view this post on Zulip Paolo Giarrusso (Jul 11 2022 at 13:53):

@Rudi Grinberg I'm packaging a so -p was the obvious choice

view this post on Zulip Paolo Giarrusso (Jul 11 2022 at 13:57):

it's a bit unfortunate that --no-config disables the cache, but -p a --cache enabled seems to work out. I get cache misses for Coq code that depends on custom OCaml plugins, but that seems as intended (the OCaml command-line changes in release mode, and the Coq one does not).

view this post on Zulip Paolo Giarrusso (Jul 11 2022 at 14:02):

and of course, skipping caches might be the reasonable default for a reproducible build but YMMV. In fact, "write to the cache but don't read from it" seems an attractive option when you fear (or know for certain) that your incremental builds are not sound because you do not track dependencies fully

view this post on Zulip Rudi Grinberg (Jul 11 2022 at 16:28):

Isn't the problem that you've enabled the cache in the config? Release builds shouldn't be relying on any configuration settings in your HOME dir

view this post on Zulip Paolo Giarrusso (Jul 11 2022 at 16:33):

Yes, that's certainly as specified* — it's just unfortunate that the spec means caching is disabled.
*because -p implies --release which implies --no-config; dune build --help is unambiguous here.

view this post on Zulip Paolo Giarrusso (Jul 11 2022 at 16:33):

of course I can patch _my_ foo.opam to use dune build -p ... --cache enabled (if I don't use dune-release), but that won't enable caches for other packages.

view this post on Zulip Rudi Grinberg (Jul 11 2022 at 16:35):

I think there's a way to enable the cache for an entire switch in opam

view this post on Zulip Rudi Grinberg (Jul 11 2022 at 16:35):

See this issue https://github.com/ocaml/opam-repository/issues/19150

view this post on Zulip Rudi Grinberg (Jul 11 2022 at 16:40):

There's a way to set environment variables for opam switches but it escapes me at the moment

view this post on Zulip Paolo Giarrusso (Jul 11 2022 at 17:36):

Ah, it's opam config env :-)

view this post on Zulip Paolo Giarrusso (Jul 11 2022 at 17:44):

so even with -p, env variables are still considered (as the manual says).

view this post on Zulip Paolo Giarrusso (Jul 11 2022 at 17:47):

I'm less sure how to _set_ such environment variables... opam packages can use the setenv field, (https://opam.ocaml.org/doc/Manual.html)
and it seems opam option setenv allows to change the per-switch-global setenv option (https://opam.ocaml.org/doc/man/opam-option.html)...

view this post on Zulip Rudi Grinberg (Jul 11 2022 at 17:56):

Yes, you need the latter here

view this post on Zulip Paolo Giarrusso (Jul 11 2022 at 18:04):

setenv doesn't seem modular or fully documented (need I query the current map to extend it?) — can I just set the variables in the environment? or does opam clear them?

view this post on Zulip Rudi Grinberg (Jul 11 2022 at 18:08):

You could try it. I don't remember if opam clears them.

view this post on Zulip Rudi Grinberg (Jul 11 2022 at 18:09):

try DUNE_CACHE=enabled; opam exec -- sh -c 'echo $DUNE_CACHE'

view this post on Zulip Paolo Giarrusso (Jul 11 2022 at 18:23):

$ export DUNE_CACHE=enabled; opam exec -- sh -c 'echo $DUNE_CACHE'
enabled

:-)

view this post on Zulip Paolo Giarrusso (Jul 11 2022 at 18:24):

thanks a lot!


Last updated: Oct 13 2024 at 01:02 UTC