Skip to content

odoc required by cram depending on objs/byte #11633

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

Open
cuihtlauac opened this issue Apr 17, 2025 · 6 comments
Open

odoc required by cram depending on objs/byte #11633

cuihtlauac opened this issue Apr 17, 2025 · 6 comments

Comments

@cuihtlauac
Copy link
Contributor

cuihtlauac commented Apr 17, 2025

Expected Behavior

> dune runtest
> echo $?
0

Actual Behavior

> dune runtest
File ".foo.objs/byte/_unknown_", line 1, characters 0-0:
Error: Program odoc not found in the tree or in PATH
 (context: default)
Hint: opam install odoc

Reproduction

  1. Create and check into an opam switch with only ocaml and dune
  2. Create a file dune-project with (lang dune 3.18)
  3. Create empty files foo.ml and foo.t
  4. Create the following dune file:
(library (name foo))

(cram
 (deps
  (glob_files .foo.objs/byte/*)))
  1. Run dune runtest

Specifications

  • Dune 3.18.0
  • OCaml 5.3.0
  • Ubuntu 24.10

Additional information

Local switch contents

base-bigarray         base
base-domains          base
base-effects          base
base-nnp              base
base-threads          base
base-unix             base
dune                  3.18.0
ocaml                 5.3.0
ocaml-base-compiler   5.3.0
ocaml-compiler        5.3.0
ocaml-config          3
ocaml-options-vanilla 1
@Alizter
Copy link
Collaborator

Alizter commented Apr 18, 2025

Here is a repro cram test:

  $ cat > dune-project <<EOF
  > (lang dune 3.18)
  > (package (name foo))
  > EOF

  $ cat > foo.ml
  $ cat > foo.t
  $ cat > dune <<EOF
  > (library
  >  (public_name foo))
  > (cram
  >  (deps
  >   (glob_files .foo.objs/byte/*)))
  > EOF

  $ PATH=$(dirname -- $(command -v ocaml))\
  > :$(dirname -- $(command -v dune))\
  > :$(dirname -- $(command -v cat))\
  > :$(dirname -- $(command -v sh))

  $ dune build @runtest
  File "_doc/_odoc/pkg/foo/_unknown_", line 1, characters 0-0:
  Error: Program odoc not found in the tree or in PATH
   (context: default)
  Hint: opam install odoc
  [1]

@Alizter
Copy link
Collaborator

Alizter commented Apr 18, 2025

Here is the reason:

  $ dune build @runtest --debug-dependency-path
  File "_doc/_odoc/pkg/foo/_unknown_", line 1, characters 0-0:
  Error: Program odoc not found in the tree or in PATH
   (context: default)
  -> required by _build/default/_doc/_odoc/pkg/foo/page-index.odoc
  -> required by alias _doc/_odoc/pkg/foo/.odoc-all
  -> required by _build/default/.foo.objs/byte/foo.odoc
  -> required by alias foo
  -> required by alias runtest
  Hint: opam install odoc
  [1]

We are storing foo.odoc in byte/.foo.objs so naturally this requires odoc to build. You can fix your glob by excluding foo.odoc.

@Alizter
Copy link
Collaborator

Alizter commented Apr 18, 2025

One way you can exclude is to do:

   (glob_files .foo.objs/byte/foo.c*)

since all the files you are interested in have a .c in this case.

@cuihtlauac
Copy link
Contributor Author

cuihtlauac commented Apr 18, 2025

Brilliant! Thanks for the workaround. BTW, don't you think it would be nice to have something like %{objs:foo}? Somehow similar to %{cma:foo}

@Alizter
Copy link
Collaborator

Alizter commented Apr 18, 2025

I'm not sure what exactly we would include in such a %{objs:_} variable. i.e. bytecode or native or both?

However I suppose the more idiomatic way to do what you want would be:

  (deps %{cmo:foo} %{cmi:foo}))

if there are other compilation artefacts that you require and are not listed here: https://dune.readthedocs.io/en/stable/advanced/variables-artifacts.html#variables-for-artifacts

then we could definitely consider adding them.

@rgrinberg
Copy link
Member

Maybe we could the odoc artifacts into their own object directory. Shouldn't be too hard and it does seem like the safer default.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants