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

Ignore interpolation for comments #2179

Closed
gl-yziquel opened this issue Jun 21, 2024 · 4 comments · Fixed by #2180
Closed

Ignore interpolation for comments #2179

gl-yziquel opened this issue Jun 21, 2024 · 4 comments · Fixed by #2180

Comments

@gl-yziquel
Copy link
Contributor

gl-yziquel commented Jun 21, 2024

Hi.

I've just been shuffling around some build instructions encapsulated in my justfiles. And commented out one such build instruction (since the build system of jax has been in flux).

#cd jax-{{TAG}} && bazelisk run --verbose-failure=true //jaxlib/tools:build_wheel -- --output_path=dist --cpu=x86_64

just then told me the following:

error: Variable `TAG` not defined

So, basically, it tried to interpolate the TAG value in the comment. I believe this is a situation where you should opt out of interpolation.

Of course, this depends whether or not the comment is a comment for the shell, or a comment for just. It seems to be a comment for the shell, in which case, well, I would understand just not being aware of what is a comment for the shell.

Nonetheless, the ergonomics of it seems suboptimal: I'd like to wildly refactor my build instructions without having just complaining about failing to interpolate my comments...

EDIT: It can be fixed by putting the # as the first element of the line and not putting it after the tab. But, still, it feels wrong.

@laniakea64
Copy link
Contributor

By default it's still an arbitrary line for the shell, so interpolation would be expected. But shouldn't it become a just comment if the justfile does set ignore-comments? Surprisingly, set ignore-comments doesn't eliminate this error? 👀

@gl-yziquel
Copy link
Contributor Author

gl-yziquel commented Jun 21, 2024

I'll give it a shot with set ignore-comments. I learn about just every day...

P.S.: feel free to close.

@laniakea64
Copy link
Contributor

I'll give it a shot with set ignore-comments. ...

P.S.: feel free to close.

😕 To be clear, I expected set ignore-comments to be the solution to the error, but it doesn't work for me with latest just master:

set ignore-comments

foo:
	echo recipe
	#echo {{not_an_interpolation}}
	echo recipe
error: Variable `not_an_interpolation` not defined
 ——▶ justfile:5:10
  │
5 │     #echo {{not_an_interpolation}}
  │             ^^^^^^^^^^^^^^^^^^^^

So I would wonder if this is a bug?

@casey
Copy link
Owner

casey commented Jun 21, 2024

It's not quite a bug, I think originally the point of ignore-comments was just to not print and execute comment lines, but they would still be parsed and analyzed.

I thought it would be hard also skip analysis (when unknown variable errors are raised) but it turned out to be pretty straightforward. As of #2180, comments are now parsed but not analyzed when ignore-comments is set. Since they're parsed, they need to be valid syntax, but you won't get unknown variable errors anymore.

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 a pull request may close this issue.

3 participants