Skip to content

Dune repo doesn't work with (vendored_dirs ..) #3843

@dra27

Description

@dra27

Background to this is assembling a project which vendors the Dune repository in order to have configurator in a "Duniverse"-style build.

Taking the configurator example from the manual as a minimum setup, in a switch which just has an OCaml compiler:

git clone https://github.com/ocaml/dune dune-repo
git clone https://github.com/janestreet/result
git clone https://github.com/ocaml-dune/csexp
cd dune-repo ; ocaml bootstrap.ml ; cd ..

Create discover.ml with the example from the manual:

module C = Configurator.V1

let clock_gettime_code = {|
#include <time.h>

int main()
{
  struct timespec ts;
  clock_gettime(CLOCK_REALTIME, &ts);
  return 0;
}
|}

let () =
  C.main ~name:"foo" (fun c ->
    let has_clock_gettime = C.c_test c clock_gettime_code ~link_flags:["-lrt"] in

    C.C_define.gen_header_file c ~fname:"config.h"
      [ "HAS_CLOCK_GETTIME", Switch has_clock_gettime ]);

and create a dune file for assembling just this strange project:

(vendored_dirs csexp result dune-repo)

(executable
 (name discover)
 (libraries dune.configurator))

(rule
 (targets config.h)
 (action (run ./discover.exe)))

(install
 (section share)
 (files config.h))

Now run dune-repo/dune.exe build @install and you will be presented with this error:

File "dune-repo/test/blackbox-tests/test-cases/dialects.t/bad1/dune-project", line 9, characters 1-74:
 9 |  (name d)
10 |  (implementation (extension foo2))
11 |  (interface (extension bar2)))
Error: dialect "d" is already defined

There are two possible fixes:

  1. Remove dune-repo from the vendored_dirs stanza (but that now means that @install builds everything)
  2. Add (subdir dune-repo (data_only_dirs test)) to the dune file

It doesn't feel like either should be required, but I'm not sure what's causing Dune to start reading tests when the repo is part of a vendored_dirs stanza.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions