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

Set minimal required just version for a justfile #2290

Open
nyurik opened this issue Aug 2, 2024 · 6 comments
Open

Set minimal required just version for a justfile #2290

nyurik opened this issue Aug 2, 2024 · 6 comments

Comments

@nyurik
Copy link
Contributor

nyurik commented Aug 2, 2024

just is rapidly evolving, frequently adding new features. justfiles are frequently shared between users, and those users may have different Just versions installed, which means in some cases some newer features might not be available in the older just versions.

We need a way to specify the minimum required version for just, similar to how cmake and many other similar tools do it. The actual syntax is up for a discussion:

Naming is hard

Some ideas...

set mjv := '1.32.0'
set minimum-just := '1.32.0'
set require-just-at-least := '1.32.0'
set min-required-just := '1.32.0'
set min-just-version := '1.32.0'
@hustcer
Copy link
Contributor

hustcer commented Aug 2, 2024

set min-just-version := '1.32.0'

@casey
Copy link
Owner

casey commented Aug 2, 2024

This is actually quite a tricky problem. Let's say there's a new function foo() in just 1.50.0, so when using it, you put set minimum-just-version := '1.50.0':

set minimum-just-version := '1.50.0'

foo:
  echo {{ foo() }}

However, a call to a new function in just 1.49.0 is a compilation error, so when you're producing an error message, you do not have a Justfile whose settings you can inspect for a minimum-just-version to produce a better error message.

This is a somewhat trivial example, because a missing function error could be deferred until the end of compilation, so you did have a Justfile you could get the minimum just version from, however in the case of, for example, new grammatical constructs, there's no way you can parse the justfile at all, so you can't extract the minimum just version to improve the error message.

There are a few solutions, but none of them seem very nice:

  • Have a separatefile, like .justversion, which is a file which only contains the minimum version, and refer to that when an error happens.
  • Try to grep through the file if you get an error, and just search for a line that matches set min-just-version := '.*'
  • Have a special form for directives embedded in comments, so they don't depend on parsing anything else #! just-version 1.50.0

I'm not convinced though that any of these are worth it though.

@Spatenheinz
Copy link
Contributor

Just a thought,
Would it make sense to only allow the minimum version as the very first tokens of a Justfile, but still as optional?

@casey
Copy link
Owner

casey commented Aug 6, 2024

Just a thought, Would it make sense to only allow the minimum version as the very first tokens of a Justfile, but still as optional?

This is possible, although I'd like to avoid adding special case parsing logic just for this feature.

@windl1n
Copy link

windl1n commented Oct 18, 2024

what if add version into filename? like

.a.b.c.justfile
a.b.c@justfile

which can be created by just --init
and in justfile, when add new function,

[min(a.b.c)]
foo:
  ...

i think not all func need to work at the same version

@nyurik
Copy link
Contributor Author

nyurik commented Oct 18, 2024

lets not, min version is a small implementation detail, and most users of the repo shouldn't be aware of it. First non-comment line could work ok though

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

No branches or pull requests

5 participants