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

[working-directory: {{variable}}] doesn't seem to work #2527

Closed
jonathanunderwood opened this issue Dec 12, 2024 · 3 comments
Closed

[working-directory: {{variable}}] doesn't seem to work #2527

jonathanunderwood opened this issue Dec 12, 2024 · 3 comments

Comments

@jonathanunderwood
Copy link

Consider the following justfile:

mydir := "foo"

[working-directory: {{mydir}}]
recipe:
    echo Hello world

which, naively, I expected to work. But:

❯ just
error: Expected identifier or string, but found '{'
 ——▶ justfile:3:21
  │
3 │ [working-directory: {{mydir}}]
  │                     ^

So, perhaps this is expected to work (i.e. following the error message and providing an identifier:

mydir := "foo"

[working-directory: mydir]
recipe:
    echo Hello world

but:

❯ just
error: Expected keyword `x` but found identifier `mydir`
 ——▶ justfile:3:21
  │
3 │ [working-directory: mydir]
  │                     ^^^^^

So, I am not sure what the expected semantics of [working-directory: ...] are - the docs don't really tackle this.

@casey
Copy link
Owner

casey commented Dec 12, 2024

Unfortunately this isn't supported, see #2521 for the tracking issue.

@casey casey closed this as completed Dec 12, 2024
@jonathanunderwood
Copy link
Author

@casey thanks for the rapid response and clarifying this isn't yet expected to work at this time.

I do think there is an issue here as well with the incorrect error messages:

In the first case error: Expected identifier or string, but found '{' really shouldn't mention identifier, since, as you say, that's not currently supported.

In the second case error: Expected keyword xbut found identifiermydir`` is probably also wrong, since it doesn't seem that specifying x and hoping for shell expansion to work would lead to a good outcome.

@casey
Copy link
Owner

casey commented Dec 13, 2024

Ah yeah, that is confusing. The reason you get: Expected identifier or string, but found '{' is because a shell-expanded string, x"foo" is accepted, and x is an identifier. x is accepted though, for shell-expanded string, so Expected keyword x but found idntifier is a correct error message.

The just parser is only dimly aware of keywords, and mostly treats them like identifiers, so it might be hard to improve the error message, which should ideally be something like Expected x keyword or string, but found '{'.

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

2 participants