Skip to content

Conversation

@benodiwal
Copy link
Contributor

Closes #12801

@benodiwal benodiwal force-pushed the fix/good-error-msg-pkg-enabled branch from 47184b5 to 80dd5e8 Compare November 27, 2025 13:50
Copy link
Collaborator

@Leonidas-from-XIV Leonidas-from-XIV left a comment

Choose a reason for hiding this comment

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

Thanks for the PR. I have made some comments on how to improve the code.

However I think I would ask the opinion of other Dune maintainers to ask whether adding support for pkg in dune-project only to state that you don't support is is a good idea. It feels a bit.. odd. Likewise, should we add stanzas for other error cases too (lock_dir etc)?

@benodiwal
Copy link
Contributor Author

Thanks for the PR. I have made some comments on how to improve the code.

However I think I would ask the opinion of other Dune maintainers to ask whether adding support for pkg in dune-project only to state that you don't support is is a good idea. It feels a bit.. odd. Likewise, should we add stanzas for other error cases too (lock_dir etc)?

Thanks for the feedback @Leonidas-from-XIV ! I've implemented all your suggestions ! You raise a good point about whether this approach feels odd. I can see the concern, we're essentially adding a field just to reject it with a better error message.

@Leonidas-from-XIV Leonidas-from-XIV dismissed their stale review November 27, 2025 14:27

Concerns addressed

@benodiwal benodiwal force-pushed the fix/good-error-msg-pkg-enabled branch from 73e634e to 5bc200f Compare November 27, 2025 15:42
@Alizter
Copy link
Collaborator

Alizter commented Nov 27, 2025

@Leonidas-from-XIV Given that we are/will be pushing people to use package management it would be good to handle this particular case since it does occur if users are new to the dune-workspace file. It's better than the confusing message we get otherwise. #12761 (comment)

@Leonidas-from-XIV
Copy link
Collaborator

Thanks for addressing the issues, quite nice.

I've been looking at this a little and if we decide that we want to support a feature like this maybe we should extend Syntax.check_supported with an additional case for something like `Unsupported_in_dune_project. That way it would be easier to add stanzas that are unsupported without having to write an ad-hoc error message for every single of them.

@Alizter Alizter self-requested a review November 27, 2025 17:25
@Alizter Alizter self-assigned this Nov 27, 2025
@benodiwal benodiwal force-pushed the fix/good-error-msg-pkg-enabled branch from 5bc200f to 39c60f3 Compare November 27, 2025 18:23
@benodiwal benodiwal force-pushed the fix/good-error-msg-pkg-enabled branch from 39c60f3 to d031b30 Compare November 28, 2025 10:08
Alizter
Alizter previously approved these changes Nov 28, 2025
@benodiwal benodiwal force-pushed the fix/good-error-msg-pkg-enabled branch from c74120e to 58b4cfe Compare November 28, 2025 11:00
@Alizter Alizter dismissed their stale review November 28, 2025 11:09

noticed something

Comment on lines 10 to 17
File "dune-project", line 2, characters 0-13:
2 | (pkg enabled)
^^^^^^^^^^^^^
Error: The (pkg ...) configuration is only valid in dune-workspace, not a
dune-project.
Hint: Add this configuration to your dune-workspace file (create one in your
workspace root if you don't have one).
[1]
Copy link
Collaborator

Choose a reason for hiding this comment

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

cc @avsm, since you encountered this situation before, could you give this a read and see if you would have found it useful with your issue before?

Copy link
Collaborator

@Alizter Alizter left a comment

Choose a reason for hiding this comment

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

Sorry to keep iterating on the wording but I am still not happy. Let me block this to avoid others merging.

@Alizter
Copy link
Collaborator

Alizter commented Nov 28, 2025

File "dune-project", line 2, characters 0-13:
2 | (pkg enabled)
    ^^^^^^^^^^^^^
Error: The (pkg ...) stanza is only valid in dune-workspace files.
Hint: Move this stanza to your dune-workspace file. If you don't have one,
create one in your workspace root.

This should be better I think.

@benodiwal
Copy link
Contributor Author

Sorry to keep iterating on the wording but I am still not happy. Let me block this to avoid others merging.

Sure @Alizter

@benodiwal benodiwal force-pushed the fix/good-error-msg-pkg-enabled branch from b740483 to 47180f5 Compare November 28, 2025 21:47
@benodiwal
Copy link
Contributor Author

Hey @Alizter, is there any update on the new message text

@Alizter
Copy link
Collaborator

Alizter commented Dec 1, 2025

@benodiwal Did you see my proposed wording above? #12802 (comment)

@benodiwal
Copy link
Contributor Author

@benodiwal Did you see my proposed wording above? #12802 (comment)

Ohh shoot, missed it. Making the change now

Signed-off-by: Sachin Beniwal <[email protected]>
Signed-off-by: Sachin Beniwal <[email protected]>
@benodiwal benodiwal force-pushed the fix/good-error-msg-pkg-enabled branch from 47180f5 to a95cd99 Compare December 1, 2025 10:51
Signed-off-by: Sachin Beniwal <[email protected]>
Comment on lines 967 to 968
"Move this stanza to your dune-workspace file. If you don't have one,\n\
\ create one in your workspace root."
Copy link
Collaborator

Choose a reason for hiding this comment

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

You don't need to put new lines in the text. Pp will break it appropriately for you.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have fixed it

Signed-off-by: Sachin Beniwal <[email protected]>
Copy link
Collaborator

@Alizter Alizter left a comment

Choose a reason for hiding this comment

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

Looks great. Thanks!

@Alizter
Copy link
Collaborator

Alizter commented Dec 1, 2025

@shonfeder This will be in 3.21, but I don't know if you want to keep the changelog entry since it is package management related. I think its fine to keep in this case but I defer judgement to you.

@Alizter Alizter enabled auto-merge December 1, 2025 11:11
@Alizter Alizter merged commit 79117e3 into ocaml:main Dec 1, 2025
27 checks passed
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.

Good error when (pkg enabled) is put in dune-project

3 participants