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

task-specific env vars unavailable in templates but accessible as shell vars #3756

Closed
bartsmykla opened this issue Dec 21, 2024 · 0 comments · Fixed by #3758
Closed

task-specific env vars unavailable in templates but accessible as shell vars #3756

bartsmykla opened this issue Dec 21, 2024 · 0 comments · Fixed by #3758
Labels

Comments

@bartsmykla
Copy link

Describe the bug
Environment variables defined in TOML tasks are not accessible in templates via the env object or the get_env function, but they are available as regular Bash environment variables. For example, when using the following mise.toml:

[env]
FOO = "foo"

[tasks.foo]
env.BAR = "bar"

run = """
printf '$BAR: %s\n' $BAR
echo "{% raw %}{{ env.BAR }}{% endraw %}: {{ env.BAR | default(value='undefined') }}"
"""

depends_post = [
    "debug:env:clean"
]

[tasks."debug:env:clean"]
run = """
cat <<'EOF' | sed -e "s|$HOME||g" | jq '.PATH = "..."'
{{ env | json_encode() }}
EOF
"""

When I run mise run foo, the results are as follows:

[foo] $ printf '$BAR: %s
$BAR: bar
{{ env.BAR }}: undefined
[debug:env:clean] $ cat <<'EOF' | sed -e "s|$HOME||g" | jq '.PATH = "..."'
{
  "FOO": "foo",
  "PATH": "..."
}

The variable BAR defined in the task's env is visible to the shell as a regular environment variable but is not accessible in the template via {{ env.BAR }} or {{ get_env('BAR') }}.

To Reproduce

  1. Use the mise.toml configuration provided above.
  2. Run mise run foo.
  3. Observe that {{ env.BAR }} and {{ get_env('BAR') }} in the run template are not rendered and default to undefined, while $BAR is correctly available as a Bash environment variable.

Expected behavior
Environment variables defined in a task's env should be accessible in templates using env.BAR or get_env('BAR').

mise doctor output

version: 2024.12.15 macos-arm64 (0d37f33 2024-12-19)
activated: yes
shims_on_path: no

build_info:
Target: aarch64-apple-darwin
Features: DEFAULT, NATIVE_TLS, OPENSSL
Built: Thu, 19 Dec 2024 18:51:18 +0000
Rust Version: rustc 1.83.0 (90b35a623 2024-11-26)
Profile: release

shell:
/opt/homebrew/bin/fish
fish, version 3.7.1

dirs:
cache: ~/Library/Caches/mise
config: ~/.config/mise
data: ~/.local/share/mise
shims: ~/.local/share/mise/shims
state: ~/.local/state/mise

config_files:
~/.config/mise/config.toml
~/project/mise.toml

backends:
aqua
asdf
cargo
core
gem
go
npm
pipx
spm
ubi
vfox

plugins:
clang-format           [email protected]:higebu/asdf-llvm.git#c527fd9
kube-controller-tools  [email protected]:jimmidyson/asdf-kube-controller-tools.git#37526dc
oapi-codegen           [email protected]:dylanrayboss/asdf-oapi-codegen.git#a988840

toolset:
aqua:GoogleContainerTools/[email protected]
aqua:etcd-io/[email protected]
aqua:golangci/[email protected]
aqua:helm/[email protected]
aqua:jqlang/[email protected]
aqua:koalaman/[email protected]
aqua:kubernetes-sigs/[email protected]
aqua:kubernetes/[email protected]
aqua:norwoodj/[email protected]
aqua:protocolbuffers/protobuf-go/[email protected]
aqua:protocolbuffers/protobuf/[email protected]
aqua:stackrox/[email protected]
asdf:[email protected]
asdf:[email protected]
core:[email protected]
go:github.com/envoyproxy/[email protected]
go:github.com/google/osv-scanner/cmd/[email protected]
go:github.com/onsi/ginkgo/v2/[email protected]
go:github.com/pubg/[email protected]
go:google.golang.org/grpc/cmd/[email protected]
ubi:bartsmykla/clang-tools-static-binaries@foo
ubi:hadolint/[email protected]
ubi:jdx/[email protected]
ubi:k3d-io/[email protected]
ubi:kubernetes-sigs/[email protected]
ubi:mikefarah/[email protected]
@bartsmykla bartsmykla added the bug label Dec 21, 2024
@bartsmykla bartsmykla changed the title task-specific (TOML) env vars unavailable in templates but accessible as shell vars task-specific env vars unavailable in templates but accessible as shell vars Dec 21, 2024
jdx added a commit that referenced this issue Dec 21, 2024
@jdx jdx closed this as completed in #3758 Dec 21, 2024
@jdx jdx closed this as completed in dca96d2 Dec 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant