Skip to content

Conversation

@neunenak
Copy link
Contributor

The env attribute accepts two arguments (env_var, value) and can be used multiple times per recipe to set environment variables without using the existing $parameter syntax:

[env('API_KEY', 'secret')]
[env('LOG_LEVEL', 'debug')]
deploy:
    ./deploy.sh

Addresses #2825

@neunenak
Copy link
Contributor Author

Also as a general note, I initially generated this PR with LLM coding tools and then manually audited+tweaked some things. I dunno if just as a project does or should have some kind of stated policy on that, but I wanted to mention that for the sake of transparency.

I'm personally pretty bullish on AI-assisted coding, I do it all the time myself, and I take the position that in general a human developer is responsible for the code they submit to a project, but the project shouldn't care exactly how they generated that code.

@neunenak
Copy link
Contributor Author

@casey it'd be great if you could take a look at this, I think this is a pretty simple change that yields a pretty useful feature

Copy link
Owner

@casey casey left a comment

Choose a reason for hiding this comment

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

This looks good. Some minor tweaks.

A couple bigger questions:

Should exported environment variables should be available to recipe parameters?

[env("foo", "bar")]
baz x=`echo ${foo}.txt`:

Also, should they be available to env functions?

[env("foo", "bar")]
baz:
  echo {{ env("foo") }}.txt

I think the answer to both is probably yes.

As far as AI goes, I have no problem at all with LLM and AI generated code, as long as you the human coder "vouches" for the code to the same degree as code you wrote yourself, which requires reviewing the whole thing in depth before submitting it.

matches!(
self,
Attribute::Arg { .. } | Attribute::Group(_) | Attribute::Metadata(_),
Attribute::Arg { .. } | Attribute::Env(_, _) | Attribute::Group(_) | Attribute::Metadata(_),
Copy link
Owner

Choose a reason for hiding this comment

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

These should be alphabetically sorted.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Am I missing something here, the Attribute members are in alphabetical order here

@casey
Copy link
Owner

casey commented Jan 11, 2026

Actually, maybe they shouldn't be available to env functions. The env functions don't see exported top-level assignments or parameters, so the env attribute shouldn't be an exception. The question about parameters remains.

neunenak and others added 4 commits January 12, 2026 17:41
The env attribute accepts two arguments (env_var_name, value) and can be used
multiple times per recipe to set environment variables:

    [env('API_KEY', 'secret')]
    [env('LOG_LEVEL', 'debug')]
    deploy:
      ./deploy.sh
Co-authored-by: Casey Rodarmor <casey@rodarmor.com>
@neunenak
Copy link
Contributor Author

neunenak commented Jan 13, 2026

Actually, maybe they shouldn't be available to env functions. The env functions don't see exported top-level assignments or parameters, so the env attribute shouldn't be an exception. The question about parameters remains.

This is actually potentially confusing behavior with env(), although altering this would be a breaking change. In any case, I implemented making environment variables set via env accessible in parameters but not via env(). I think it's fine to deter thinking about what the right way for env() to behave is to another issue.

@neunenak neunenak requested a review from casey January 13, 2026 05:42
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.

2 participants