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

enabled_if field does not support environment variables on executable stanza #10905

Open
fsestini opened this issue Sep 11, 2024 · 2 comments · May be fixed by #10936
Open

enabled_if field does not support environment variables on executable stanza #10905

fsestini opened this issue Sep 11, 2024 · 2 comments · May be fixed by #10936
Assignees
Labels

Comments

@fsestini
Copy link

In the docs, it is claimed that the field enabled_if behaves for executables the same as libraries. As of dune 3.15, enabled_if should allow to enable/disable a library (and therefore executable) based on environment variables.

Expected Behavior

Given a directory with

dune-project file:

(lang dune 3.15)
(name dune-test)
(package
 (name dune-test))

dune file:

(executable
 (name main)
 (public_name dune_test)
 (modules main)
 (package dune-test)
 (modes exe))

(executable
 (name main_2)
 (public_name dune_test_2)
 (enabled_if (= %{env:MYVAR=disabled} enabled))
 (modules main_2)
 (package dune-test)
 (modes exe))

and files main.ml and main_2.ml (omitted as irrelevant), running dune build should result in producing either main.exe, or both main.exe and main_2.exe, based on the value of $MYVAR.

Actual Behavior

dune build fails with the following error:

File "dune", line 11, characters 16-37:
11 |  (enabled_if (= %{env:MYVAR=disabled} enabled))
                     ^^^^^^^^^^^^^^^^^^^^^
Error: Only architecture, system, model, os_type, ccomp_type, profile,
ocaml_version, context_name and arch_sixtyfour variables are allowed in this
'enabled_if' field. Please upgrade your dune language to at least 3.15.

Note that dune-project already states (lang dune 3.15). Setting the language version to 3.16 results in the same error.

Also note that the same enabled_if expression has the desired effect if used on library.

Specifications

  • Version of dune: 3.16.0
  • Version of ocaml: 4.12.1
  • Operating system: macOS 13.5.1, Darwin Kernel Version 22.6.0 arm64
@rgrinberg
Copy link
Member

Thanks for the report. @moyodiallo do you want to try fixing this one?

@rgrinberg rgrinberg added the bug label Sep 11, 2024
@moyodiallo
Copy link
Collaborator

Thanks for the report. @moyodiallo do you want to try fixing this one?

Yeah, I'll try.

@moyodiallo moyodiallo self-assigned this Sep 12, 2024
@moyodiallo moyodiallo linked a pull request Sep 19, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants