ocaml / dune

A composable build system for OCaml.
https://dune.build/
MIT License
1.63k stars 403 forks source link

dune crashes on `dune pkg lock` #11058

Open maxRN opened 2 days ago

maxRN commented 2 days ago

Expected Behavior

dune doesn't crash and the lock dir is generated.

Actual Behavior

dune crashes.

Reproduction

$ dune pkg lock
Internal error, please report upstream including the contents of _build/log.
Description:
  ("invalid depopts", {})
Raised at Stdune__Code_error.raise in file
  "otherlibs/stdune/src/code_error.ml", line 10, characters 30-62
Called from Dune_pkg__Opam_solver.resolve_depopts in file
  "src/dune_pkg/opam_solver.ml", line 565, characters 3-21
Called from Dune_pkg__Opam_solver.opam_package_to_lock_file_pkg in file
  "src/dune_pkg/opam_solver.ml", line 645, characters 6-48
Called from Stdlib__List.rev_map.rmap_f in file "list.ml", line 105,
  characters 22-25
Called from Stdune__List.map in file "otherlibs/stdune/src/list.ml"
  (inlined), line 5, characters 19-33
Called from Dune_pkg__Opam_solver.solve_lock_dir.(fun) in file
  "src/dune_pkg/opam_solver.ml", line 856, characters 8-277
Called from Fiber__Scheduler.exec in file "vendor/fiber/src/scheduler.ml",
  line 76, characters 8-11
Re-raised at Stdune__Exn.raise_with_backtrace in file
  "otherlibs/stdune/src/exn.ml" (inlined), line 38, characters 27-56
Called from Stdune__Exn_with_backtrace.reraise in file
  "otherlibs/stdune/src/exn_with_backtrace.ml", line 20, characters 33-71
Called from Fiber__Scheduler.exec in file "vendor/fiber/src/scheduler.ml",
  line 76, characters 8-11

I must not crash.  Uncertainty is the mind-killer. Exceptions are the
little-death that brings total obliteration.  I will fully express my cases.
Execution will pass over me and through me.  And when it has gone past, I
will unwind the stack along its path.  Where the cases are handled there will
be nothing.  Only I will remain.

Output of _build/log

https://gist.github.com/maxRN/27b87ae926eece0f98c54780547bd6eb

Specifications

Additional information

I'm using the dune developer preview.

maxRN commented 2 days ago

It used to work before with the same configuration, I just upgraded the nightly dune. After some investigation, the regressions started appearing in version nightly-2024-10-22.

Output of dune --version:

"Dune Developer Preview: build 2024-10-22T02:16:49Z, git revision
bd29b159396e41b256deec430ae08cbf5b70ce77"
maiste commented 2 days ago

Thanks for reporting! :+1: Do you have a pointer to the project you are trying to build or a reproducible step to get the error?

Leonidas-from-XIV commented 2 days ago

This looks like a regression caused by #11022. Can you post your depopts so we can build a reproduction case?

As a short-term fix, you need to simplify the optional dependencies, to be only a list of packages that don't use &.

rgrinberg commented 2 days ago

I can take a look since I introduced the issue.

maxRN commented 2 days ago

Here's a link to a reproduction repository: https://github.com/maxrn/dune-pkg-repro

maxRN commented 2 days ago

Just simplified the example, cohttp-unix-lwt seems to be causing problems.

EDIT: Minimal dune-project file:

(lang dune 3.17)

(name pkg_repro)

(package
 (name pkg_repro)
 (synopsis "A short synopsis")
 (description "A longer description")
 (depends
  cohttp-lwt-unix
  ))
rgrinberg commented 1 day ago

Thanks. Do you mind repro'ing with dune in main? This PR should improve the error message.

maxRN commented 15 hours ago
Internal error, please report upstream including the contents of _build/log.
Description:
  ("invalid depopts",
   { depopts =
       Or
         [ Or [ Atom ("tls-lwt", Empty); Atom ("lwt_ssl", Empty) ]
         ; Atom ("launchd", Empty)
         ]
   })
Raised at Stdune__Code_error.raise in file
  "otherlibs/stdune/src/code_error.ml", line 10, characters 30-62
Called from Dune_pkg__Opam_solver.resolve_depopts in file
  "src/dune_pkg/opam_solver.ml", line 565, characters 3-21
Called from Dune_pkg__Opam_solver.opam_package_to_lock_file_pkg in file
  "src/dune_pkg/opam_solver.ml", line 645, characters 6-48
Called from Stdlib__List.rev_map.rmap_f in file "list.ml", line 105,
  characters 22-25
Called from Stdune__List.map in file "otherlibs/stdune/src/list.ml"
  (inlined), line 5, characters 19-33
Called from Dune_pkg__Opam_solver.solve_lock_dir.(fun) in file
  "src/dune_pkg/opam_solver.ml", line 856, characters 8-277
Called from Fiber__Scheduler.exec in file "vendor/fiber/src/scheduler.ml",
  line 76, characters 8-11
Re-raised at Stdune__Exn.raise_with_backtrace in file
  "otherlibs/stdune/src/exn.ml" (inlined), line 38, characters 27-56
Called from Stdune__Exn_with_backtrace.reraise in file
  "otherlibs/stdune/src/exn_with_backtrace.ml", line 20, characters 33-71
Called from Fiber__Scheduler.exec in file "vendor/fiber/src/scheduler.ml",
  line 76, characters 8-11

I must not crash.  Uncertainty is the mind-killer. Exceptions are the
little-death that brings total obliteration.  I will fully express my cases.
Execution will pass over me and through me.  And when it has gone past, I
will unwind the stack along its path.  Where the cases are handled there will
be nothing.  Only I will remain.

with latest dune nightly

"Dune Developer Preview: build 2024-11-01T02:24:10Z, git revision
3ac95e5f1dfa4738faa197330a64555bbaec5421"

Let me know if you need the _build/log as well.