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

DUNE_PROFILE should be ignored when -p specified #4632

Closed
dra27 opened this issue May 19, 2021 · 5 comments
Closed

DUNE_PROFILE should be ignored when -p specified #4632

dra27 opened this issue May 19, 2021 · 5 comments
Labels

Comments

@dra27
Copy link
Member

dra27 commented May 19, 2021

DUNE_PROFILE being set in the environment can break the installation of opam packages:

dra@thor:~$ DUNE_PROFILE=dev opam install uri.2.2.1
The following actions will be performed:
  ∗ install uri 2.2.1

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
⬇ retrieved uri.2.2.1  (cached)
[ERROR] The compilation of uri.2.2.1 failed at "dune build -p uri -j 7".

#=== ERROR while compiling uri.2.2.1 ==========================================#
# context     2.1.0~beta4 | linux/x86_64 | ocaml-base-compiler.4.11.2 | file:///home/dra/opam-repository
# path        ~/.opam/dev-4.11/.opam-switch/build/uri.2.2.1
# command     ~/.opam/opam-init/hooks/sandbox.sh build dune build -p uri -j 7
# exit-code   1
# env-file    ~/.opam/log/uri-3421537-40d977.env
# output-file ~/.opam/log/uri-3421537-40d977.out
### output ###
# [...]
# - [@sexp_drop_default.equal] if the type supports [%equal]
# - [@sexp_drop_default.sexp] if you want to compare the sexp representations
#
# File "lib/uri_sexp.ml", line 21, characters 18-31:
# 21 |           scheme: string option [@default None] [@sexp_drop_default];
#                        ^^^^^^^^^^^^^
# Error (warning 22): [@sexp_drop_default] is deprecated: please use one of:
# - [@sexp_drop_default f] and give an explicit equality function ([f = Poly.(=)] corresponds to the old behavior)
# - [@sexp_drop_default.compare] if the type supports [%compare]
# - [@sexp_drop_default.equal] if the type supports [%equal]
# - [@sexp_drop_default.sexp] if you want to compare the sexp representations
#



<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
┌─ The following actions failed
│ λ build uri 2.2.1
└─
╶─ No changes have been performed

--profile got changed as part of the 2.0 bootstrap, so it can be specified with -p (so that the bootstrap can do -p --profile dune-bootstrap. This is fine for the command line, but DUNE_PROFILE should definitely be ignored in this case.

Cmdliner doesn't make the provenance of a term available. There are a few possible fixes:

  1. Don't pass DUNE_PROFILE to Cmdliner at all and manually fill it in (this is what opam does for pretty much all of its environment variables - the downside is that the man-page no longer automatically documents the variable). This is a fairly simple change.
  2. Put a sentinel value on the start of DUNE_PROFILE before evaluating the term, so that Dune can tell that the environment variable was used. The more serious downside is that it affects the evaluation of the term for all the commands so it's a bigger diff.
  3. Only allow dune-release as the argument for --profile when -p is given. Also fairly simple; might break some unexpected usage of dune.
  4. Pre-process Sys.argv to identify the presence of -p and anything beginning --profile (this isn't as crazy as it sounds, but it's quite crazy - FWIW we have to pre-process Sys.argv in opam, too!). If -p is present (before any --) and no term begins --profile, the the --profile argument could be omitted in the term.
  5. Restore --profile to the pre-2.0 behaviour of conflicting with -p and introduce a different argument for the bootstrap to communicate the bootstrap profile.

Technically speaking I broke this in #2854 (although I think the change was actually Jeremie's 😉) - I'm very happy to do whichever of these fixes we settle on! The options above are given in increasing order of preference (so I think 4 or 5 are probably best - 4 is slightly dirtier internally, but doesn't require a special bootstrap flag which is always visible in the CLI).

@ghost
Copy link

ghost commented May 19, 2021

Haha, yeah it was definitely me. I remember this.

What about we patch cmdliner to allow capturing the source?

@dra27
Copy link
Member Author

dra27 commented May 19, 2021

I guess that can be option 6 - but I imagine that such a patch would have to live in Dune, just because it will be an API change for Cmdliner?

@ghost
Copy link

ghost commented May 19, 2021

The API questions are more for cmdliner upstream. I imagine that if you add a new function to preserve backward compat it should be fine. But if you want to add a patch to ocaml-dune/cmdliner first that's fine as well.

@voodoos voodoos added the bug label May 19, 2021
@ghost
Copy link

ghost commented May 19, 2021

We discussed this during today's meeting. Doing something ad-hoc for DUNE_PROFILE seems fine, although it would be nicer to have a more principled way to support such command line aliases.

@bobot and @aalekseyev had some ideas how to do that.

ejgallego added a commit to ejgallego/opam-repository that referenced this issue Jun 29, 2021
…ator, dune-private-libs, dune and dune-build-info (2.9.0)

CHANGES:

- Add `(enabled_if ...)` to `(mdx ...)` (ocaml/dune#4434, @emillon)

- Add support for instrumentation dependencies (ocaml/dune#4210, fixes ocaml/dune#3983, @nojb)

- Add the possibility to use `locks` with the cram tests stanza (ocaml/dune#4480, @voodoos)

- Allow to set up merlin in a variant of the default context
  (ocaml/dune#4145, @TheLortex, @voodoos)

- Add `(package ...)` to `(mdx ...)` (ocaml/dune#4691, fixes ocaml/dune#3756, @emillon)

- Handle renaming of `coq.kernel` library to `coq-core.kernel` in Coq 8.14 (ocaml/dune#4713, @proux01)

- Fix generation of merlin configuration when using `(include_subdirs
  unqualified)` on Windows (ocaml/dune#4745, @nojb)

- Fix bug for the install of Coq native files when using `(include_subdirs qualified)`
  (ocaml/dune#4753, @ejgallego)

- Allow users to specify install target directories for `doc` and
  `etc` sections. We add new options `--docdir` and `--etcdir` to both
  Dune's configure and `dune install` command. (ocaml/dune#4744, fixes ocaml/dune#4723,
  @ejgallego, thanks to @JasonGross for reporting this issue)

- Fix issue where Dune would ignore `(env ... (coq (flags ...)))`
  declarations appearing in `dune` files (ocaml/dune#4749, fixes ocaml/dune#4566, @ejgallego @rgrinberg)

- Disable some warnings on Coq 8.14 and `(lang coq (>= 0.3))` due to
  the rework of the Coq "native" compilation system (ocaml/dune#4760, @ejgallego)

- Fix a bug where instrumentation flags would be added even if the
  instrumentatation was disabled (@nojb, ocaml/dune#4770)

- Fix ocaml/dune#4682: option `-p` takes now precedence on environement variable
  `DUNE_PROFILE` (ocaml/dune#4730, ocaml/dune#4774, @bobot, reported by @dra27 ocaml/dune#4632)

- Fix installation with opam of package with dune sites. The `.install` file is
  now produced by a local `dune install` during the build phase (ocaml/dune#4730, ocaml/dune#4645,
  @bobot, reported by @kit-ty-kate ocaml/dune#4198)

- Fix multiple issues in the sites feature (ocaml/dune#4730, ocaml/dune#4645 @bobot, reported by @Lelio-Brun
  ocaml/dune#4219, by @Kakadu ocaml/dune#4325, by @toots ocaml/dune#4415)
ejgallego added a commit to ejgallego/opam-repository that referenced this issue Jul 1, 2021
…ator, dune-private-libs, dune and dune-build-info (2.9.0)

CHANGES:

- Add `(enabled_if ...)` to `(mdx ...)` (ocaml/dune#4434, @emillon)

- Add support for instrumentation dependencies (ocaml/dune#4210, fixes ocaml/dune#3983, @nojb)

- Add the possibility to use `locks` with the cram tests stanza (ocaml/dune#4480, @voodoos)

- Allow to set up merlin in a variant of the default context
  (ocaml/dune#4145, @TheLortex, @voodoos)

- Add `(package ...)` to `(mdx ...)` (ocaml/dune#4691, fixes ocaml/dune#3756, @emillon)

- Handle renaming of `coq.kernel` library to `coq-core.kernel` in Coq 8.14 (ocaml/dune#4713, @proux01)

- Fix generation of merlin configuration when using `(include_subdirs
  unqualified)` on Windows (ocaml/dune#4745, @nojb)

- Fix bug for the install of Coq native files when using `(include_subdirs qualified)`
  (ocaml/dune#4753, @ejgallego)

- Allow users to specify install target directories for `doc` and
  `etc` sections. We add new options `--docdir` and `--etcdir` to both
  Dune's configure and `dune install` command. (ocaml/dune#4744, fixes ocaml/dune#4723,
  @ejgallego, thanks to @JasonGross for reporting this issue)

- Fix issue where Dune would ignore `(env ... (coq (flags ...)))`
  declarations appearing in `dune` files (ocaml/dune#4749, fixes ocaml/dune#4566, @ejgallego @rgrinberg)

- Disable some warnings on Coq 8.14 and `(lang coq (>= 0.3))` due to
  the rework of the Coq "native" compilation system (ocaml/dune#4760, @ejgallego)

- Fix a bug where instrumentation flags would be added even if the
  instrumentatation was disabled (@nojb, ocaml/dune#4770)

- Fix ocaml/dune#4682: option `-p` takes now precedence on environement variable
  `DUNE_PROFILE` (ocaml/dune#4730, ocaml/dune#4774, @bobot, reported by @dra27 ocaml/dune#4632)

- Fix installation with opam of package with dune sites. The `.install` file is
  now produced by a local `dune install` during the build phase (ocaml/dune#4730, ocaml/dune#4645,
  @bobot, reported by @kit-ty-kate ocaml/dune#4198)

- Fix multiple issues in the sites feature (ocaml/dune#4730, ocaml/dune#4645 @bobot, reported by @Lelio-Brun
  ocaml/dune#4219, by @Kakadu ocaml/dune#4325, by @toots ocaml/dune#4415)
@dra27
Copy link
Member Author

dra27 commented Jul 5, 2021

This is fixed in Dune 2.9.0, thank you!

@dra27 dra27 closed this as completed Jul 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants