ocaml / ocaml/dune

Unable to include s-expression files in `env-vars` stanza

Open
#4,775 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

build config
Dominant language
OCaml
Stars
1.9k
Forks
500
Avg merge
15h 21m
Merged PRs (30d)
277

Description

Given a dune-workspace file as follows,

(lang dune 2.0)

(env
  (_ (env-vars ("a" "a-value") (:include ./more-vars.sexp))))

... Dune is unable to include values from a sexp file

Expected Behavior

Dune includes values from the s-expression file

Actual Behavior

Dune creates and env value :include with value "./more-vars.sexp"

When extra parens are added around :include, there is a syntax error

File "dune-workspace", line 4, characters 32-59:
4 |   (_ (env-vars ("a" "a-value") ((:include ./more-vars.sexp)))))
                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: Atom or quoted string expected

Reproduction

(happy to create a PR with a failing test if this indeed is a bug)

  1. Create workspace file
(lang dune 2.0)

(env
  (_ (env-vars ("a" "a-value") ((:include ./more-vars.sexp)))))
  1. Create more-vars.sexp with some key value pairs (optional)
("b" "b-value"
  1. Run dune exec -- env and look for environment variables a and b (b wont be created)

Specifications

  • Version of dune (output of dune --version): 2.8.5
  • Version of ocaml (output of ocamlc --version): 4.12.0
  • Operating system (distribution and version): Linux

Additional information

Context: I was trying to work around https://github.com/ocaml/dune/issues/108 with a shell script that scans _opam and creates linker flags and hand it down to dune (via a configurator). Users would have to ./load-env.sh && dune build. This was fine and it worked. I was looking for a way to craft the new environment inside configurator but set the environment globally for the entire project, so that users dont have to run the additional ./load-env.sh script before running dune build

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the behavior with the shown dune-workspace and more-vars.sexp files, then run dune exec -- env and inspect how the env-vars stanza handles :include. Done means the included key-value pairs appear in the command environment without treating :include as a literal variable or raising the shown syntax error.

Written by the indexing model from the issue text.

Assessment

Tech stack
ocaml
Domain
build-system
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.