Skip to content

Show error message when dune-workspace disables package management - #38

Merged
shym merged 3 commits into
ocaml-dune:mainfrom
Leonidas-from-XIV:better-disabled-detection
Jun 1, 2026
Merged

shym merged 3 commits into
ocaml-dune:mainfrom
Leonidas-from-XIV:better-disabled-detection

Conversation

@Leonidas-from-XIV

@Leonidas-from-XIV Leonidas-from-XIV commented May 28, 2026 •

Copy link
Copy Markdown
Contributor

Currently you can have no global dune config file but your workspace has (pkg disabled). In this case the code currently assumes that writing (pkg enabled) is enough to enable package management but when actually trying to build package management is disabled and there is no ocamlc so the build will fail.

This PR adds an error message (unfortunately folded by default) in the case where the workspace disables package management, so we don't attempt to build with disabled package management.

@Leonidas-from-XIV
Leonidas-from-XIV requested a review from shym May 28, 2026 13:40
@Leonidas-from-XIV Leonidas-from-XIV changed the title Show error message when dune-workspace disables package management Show error message when dune-workspace disables package management May 28, 2026
@Leonidas-from-XIV
Leonidas-from-XIV force-pushed the better-disabled-detection branch from 50dabb1 to 4bbb425 Compare May 28, 2026 13:58

@shym shym left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn’t understand by reading your commit messages and your PR message why you get rid of dune_aux? (It is not relevant to show traces when dune pkg enabled exits on failure, as it’s an intended behaviour, I admit. If that’s indeed what you had in mind (and that I didn’t miss something else), I’ll propose an update to your PR for that)

@Leonidas-from-XIV

Leonidas-from-XIV commented Jun 1, 2026 •

Copy link
Copy Markdown
Contributor Author

The issue I had was that dune_aux does not seem to properly return non-zero exit codes. If I call dune_aux pkg enabled and the code is 1 In my experience it will terminate and never return the 1. I spent a lot of time pulling out my hair why the CI would always terminate instead if displaying my dune_aux pkg enabled || alert "oops" failure.

In the end I just skipped dune_aux because it did a number of things that aren't necessary. That said, I had to add the workspace option back in and its still not working properly as can be seen from the test failures, so probably the better option is to fix dune_aux. Will look into that.

shym and others added 3 commits June 1, 2026 14:25
Replace an early `exit` with a `return` and actually `exit` in `w` on error
Add a simple wrapper to call Dune in the correct directory with the
correct `workspace` setting, with the option to make that call with
`set -x` enabled
Rename `dune_aux` into `dune_trace` to emphasise what that wrapper
provides

Signed-off-by: Samuel Hym <samuel@tarides.com>
Also switch to `dune_` instead of `dune_trace` for the test whether
package management is enabled

Co-authored-by: Samuel Hym <samuel@tarides.com>
Signed-off-by: Marek Kubica <marek@tarides.com>
@shym
shym force-pushed the better-disabled-detection branch from 03d7ff3 to 0a501ad Compare June 1, 2026 12:55
@shym

shym commented Jun 1, 2026

Copy link
Copy Markdown
Collaborator

Thanks for your explanations, I’ve updated the PR to fix the issues you encountered and rebase your change on top.
What do you think?

@Leonidas-from-XIV

Copy link
Copy Markdown
Contributor Author

Yes, I think this is a nicer solution. It also resolves the issue with the tests in my previous version.

@shym
shym merged commit 0a501ad into ocaml-dune:main Jun 1, 2026
9 of 10 checks passed
@Leonidas-from-XIV
Leonidas-from-XIV deleted the better-disabled-detection branch June 2, 2026 09:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants