ocaml / ocaml/dune

(package ...) doesn't work when package is installed and not in the workspace

Open
#3,192 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Expected Behavior

Sorry if this is because I'm doing the wrong thing.

I have a test (part of package foo) that declares (deps (package bar)). When bar is installed, I would like dune runtest -p foo (with is what opam install -t foo does) to work.

Actual Behavior

It fails with

File "foo/dune", line 6, characters 0-81:
 6 | (rule
 7 |   (alias runtest)
 8 |   (deps (package bar))
 9 |   (action (run %{exe:main.exe}))
10 | )
Error: No rule found for alias .bar-files

Reproduction

The real life example is in the tezos codebase: https://gitlab.com/nomadic-labs/tezos/-/jobs/449208773 . That involves pinning and installing the dependencies of tezos-sandbox-tests and running dune runtest -p tezos-sandbox-tests.

A minimized example (I hope) is dune-deps-files.tar.gz. untar, cd, pin and install bar and dune runtest -p foo

the folder structure is

$ find plouf/ -print
plouf/
plouf/foo
plouf/foo/main.ml
plouf/foo/dune
plouf/dune-project
plouf/foo.opam
plouf/bar.opam
plouf/bar
plouf/bar/dune
plouf/bar/bar.mli
plouf/bar/bar.ml

with

$ cat plouf/bar/dune 
(library
 (name bar))

and

$ cat plouf/foo/dune 
(executable
  (name main)
  (public_name example)
  (package foo))

(rule
  (alias runtest)
  (package foo)
  (deps (package bar))
  (action (run %{exe:main.exe}))
)

Specifications

  • Version of dune: 2.3.0 and 1.11.2
  • Version of ocaml: 4.07.1 and 4.09.0
  • Operating system: linux

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

Start with the minimized example and inspect foo/dune, bar/dune, and dune-project, focusing on how (deps (package bar)) is resolved when bar is installed outside the workspace. Reproduce with dune runtest -p foo after installing bar. Done means the command succeeds for the provided example and the existing error no longer occurs.

Written by the indexing model from the issue text.

Assessment

Tech stack
ocaml
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 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.