Skip to content

Improve dune lang version not supported error message #11934

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

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Alizter
Copy link
Collaborator

@Alizter Alizter commented Jun 21, 2025

In this PR we do two things:

  1. Fix a bug where the wrong dune lang version was being printed when using an older dune. For instance we used to print:
File "dune-project", line 1, characters 11-18:
  1 | (lang dune 123.123)
                 ^^^^^^^
  Error: Version 123.123 of the dune language is not supported.
  Supported versions of this extension in version 123.123 of the dune language:
  - 1.0 to 1.12
  - 2.0 to 2.9
  - 3.0 to 3.20

But we are not in version 123.123!

We fix this by passing the current supported version of dune lang instead of the one we just parsed, allowing the error message to become:

  File "dune-project", line 1, characters 11-18:
  1 | (lang dune 123.123)
                 ^^^^^^^
  Error: Version 123.123 of the dune language is not supported.
  Supported versions of this extension in version 3.20 of the dune language:
  - 1.0 to 1.12
  - 2.0 to 2.9
  - 3.0 to 3.20
  1. In our second commit, we improve the error message more generally. We have access to a bit more information in dune_lang/syntax.ml which we make use of. This allows an error message like before to become:
  File "dune-project", line 1, characters 11-18:
  1 | (lang dune 123.123)
                 ^^^^^^^
  Error: Version 123.123 of the dune language is not supported.
  Supported versions of the dune language in version 3.20 of dune are:
  - 1.0 to 1.12
  - 2.0 to 2.9
  - 3.20 to 3.20

Before we were mentioning "extensions" to the user which doesn't make too much sense in this context.

@Alizter Alizter force-pushed the fix-new-lang-error branch from 3174b02 to 26aab68 Compare June 21, 2025 09:35
Previously, we would output the version we were parsing which led to
nonsensical error messages like:

```
File "dune-project", line 1, characters 11-18:
  1 | (lang dune 123.123)
                 ^^^^^^^
  Error: Version 123.123 of the dune language is not supported.
  Supported versions of this extension in version 123.123 of the dune language:
  - 1.0 to 1.12
  - 2.0 to 2.9
  - 3.0 to 3.20
```

We fix this by passing the current supported version of dune lang
instead of the one we just parsed, allowing the error message to
beceome:

```
  File "dune-project", line 1, characters 11-18:
  1 | (lang dune 123.123)
                 ^^^^^^^
  Error: Version 123.123 of the dune language is not supported.
  Supported versions of this extension in version 3.20 of the dune language:
  - 1.0 to 1.12
  - 2.0 to 2.9
  - 3.0 to 3.20
```

The error message is still a bit nonsensical due to us mentioning
extensions here, but that will be left as a future improvement.

Signed-off-by: Ali Caglayan <[email protected]>
@Alizter Alizter force-pushed the fix-new-lang-error branch 5 times, most recently from 7644cba to 15267e9 Compare June 21, 2025 21:02
When we display an error for an outdated dune version which can happen
when `dune lang` appears to be unsupported by the current version of
dune, we used to mention an "extension". This was confusing to users who
didn't know about language extensions or that dune lang was an extension
under the hood.

We improve the error message by using some of the information already
provided by dune_lang/syntax.ml.

Signed-off-by: Ali Caglayan <[email protected]>
@Alizter Alizter force-pushed the fix-new-lang-error branch from 15267e9 to 8dbf2b2 Compare June 21, 2025 21:26
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.

1 participant