Skip to content
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

dune crashes on dune pkg lock #11058

Closed
maxRN opened this issue Oct 30, 2024 · 10 comments · Fixed by #11090
Closed

dune crashes on dune pkg lock #11058

maxRN opened this issue Oct 30, 2024 · 10 comments · Fixed by #11090

Comments

@maxRN
Copy link
Contributor

maxRN commented Oct 30, 2024

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

  • Version of dune (output of dune --version):
    "Dune Developer Preview: build 2024-10-30T02:16:37Z, git revision d84d83a4becd373549757d907ba4e4d5434c5e0f"

  • Version of ocaml (output of ocamlc --version): none

  • nothing

  • Operating system (distribution and version): MacOS Sonoma 15.1

Additional information

I'm using the dune developer preview.

@maxRN
Copy link
Contributor Author

maxRN commented Oct 30, 2024

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
Copy link
Collaborator

maiste commented Oct 30, 2024

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

@Leonidas-from-XIV
Copy link
Collaborator

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
Copy link
Member

I can take a look since I introduced the issue.

@maxRN
Copy link
Contributor Author

maxRN commented Oct 30, 2024

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

@maxRN
Copy link
Contributor Author

maxRN commented Oct 30, 2024

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 rgrinberg self-assigned this Oct 30, 2024
@rgrinberg
Copy link
Member

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

@maxRN
Copy link
Contributor Author

maxRN commented Nov 1, 2024

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.

rgrinberg added a commit that referenced this issue Nov 3, 2024
Signed-off-by: Rudi Grinberg <me@rgrinberg.com>

<!-- ps-id: 435862bf-91ef-4750-bf38-10336954f242 -->
rgrinberg added a commit that referenced this issue Nov 4, 2024
Signed-off-by: Rudi Grinberg <me@rgrinberg.com>

<!-- ps-id: 435862bf-91ef-4750-bf38-10336954f242 -->
rgrinberg added a commit that referenced this issue Nov 4, 2024
Signed-off-by: Rudi Grinberg <me@rgrinberg.com>

<!-- ps-id: 435862bf-91ef-4750-bf38-10336954f242 -->
@gridbugs
Copy link
Collaborator

gridbugs commented Nov 5, 2024

Ran into this in my travels. It happens whenever a package has 3 or more depopts. Opam represents this as Or(Or(A, B), C) but dune expects it to be Or(A, Or(B, C)). Fix is here: #11099. I'll make a repro while I'm at it.

@gridbugs
Copy link
Collaborator

gridbugs commented Nov 5, 2024

Repro: #11100

@rgrinberg rgrinberg linked a pull request Nov 5, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants