Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Env vars exported from shell scripts fail to render in subsequent templates #3774

Closed
bartsmykla opened this issue Dec 22, 2024 · 1 comment
Closed
Labels

Comments

@bartsmykla
Copy link

Describe the bug
Env vars exported from a shell script and loaded via _.source fail to render in subsequent env var templates. This behavior is inconsistent with how variables defined directly in the [env] section work.

This issue does not occur when the variable is defined directly in the [env] section.

This is a followup for #3755

To Reproduce

  1. Create a shell script .mise/env.sh with the following content:
    export __GENERATE_TOOLS_DIR="foo"
  2. Define the following in your configuration:
    [env]
    _.source = ".mise/env.sh"
    
    _.path = [
        "{{ env.__GENERATE_TOOLS_DIR }}",
    ]
  3. Run any task or any mise command

Expected behavior
The env var {{ env.__GENERATE_TOOLS_DIR }} should resolve to the value set in the shell script (foo), and _.path should render correctly.

mise doctor output

version: 2024.12.17 macos-arm64 (6abef71 2024-12-21)
activated: yes
shims_on_path: no

build_info:
  Target: aarch64-apple-darwin
  Features: DEFAULT, NATIVE_TLS, OPENSSL
  Built: Sat, 21 Dec 2024 16:00:07 +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
  ~/foo/mise.toml

ignored_config_files: (none)

backends:
  aqua
  asdf
  cargo
  core
  dotnet
  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:hadolint/[email protected]
  ubi:jdx/[email protected]
  ubi:k3d-io/[email protected]
  ubi:kubernetes-sigs/[email protected]
  ubi:mikefarah/[email protected]

path:
  ~/.local/share/mise/installs/container-structure-test/1.19.3
  ~/.local/share/mise/installs/etcd/3.5.17/etcd-v3.5.17-darwin-amd64
  ~/.local/share/mise/installs/go/1.23.4/bin
  ~/.local/share/mise/installs/ginkgo/2.22.0/bin
  ~/.local/share/mise/installs/golangci-lint/1.62.0/golangci-lint-1.62.0-darwin-arm64
  ~/.local/share/mise/installs/hadolint/2.12.0/bin
  ~/.local/share/mise/installs/helm/3.16.4/darwin-arm64
  ~/.local/share/mise/installs/helm-docs/1.11.0
  ~/.local/share/mise/installs/jq/1.7.1
  ~/.local/share/mise/installs/k3d/5.7.5/bin
  ~/.local/share/mise/installs/kind/0.26.0/bin
  ~/.local/share/mise/installs/kube-controller-tools/0.16.5/bin
  ~/.local/share/mise/installs/kube-linter/0.6.5
  ~/.local/share/mise/installs/kubebuilder/4.3.1
  ~/.local/share/mise/installs/kubectl/1.32.0
  ~/.local/share/mise/installs/oapi-codegen/2.4.1/bin
  ~/.local/share/mise/installs/osv-scanner/1.9.1/bin
  ~/.local/share/mise/installs/protoc/3.20.0/bin
  ~/.local/share/mise/installs/protoc-gen-go/1.28.1
  ~/.local/share/mise/installs/protoc-gen-go-grpc/1.1.0/bin
  ~/.local/share/mise/installs/protoc-gen-jsonschema/0.6.2/bin
  ~/.local/share/mise/installs/protoc-gen-validate/v1.1.0/bin
  ~/.local/share/mise/installs/shellcheck/0.10.0/shellcheck-v0.10.0
  ~/.local/share/mise/installs/yq/4.30.8/bin
  ~/.local/share/mise/installs/usage/1.7.2/bin
  ~/.local/share/mise/installs/go/1.23.4/bin
  ~/.local/bin
  /opt/homebrew/bin
  /opt/homebrew/sbin
  /opt/homebrew/opt/make/libexec/gnubin
  /opt/homebrew/opt/coreutils/libexec/gnubin
  ~/.cargo/bin
  /bin
  ~/go/bin
  ~/bin
  /usr/local/opt/libiconv/bin
  /usr/local/sbin
  /usr/local/opt/ruby/bin
  /usr/local/opt/curl/bin
  /usr/local/opt/fzf/bin
  /opt/homebrew/opt/fzf/bin
  /usr/local/bin
  /System/Cryptexes/App/usr/bin
  /usr/bin
  /usr/sbin
  /sbin
  /Library/Apple/usr/bin
  /usr/local/MacGPG2/bin
  /Applications/Wireshark.app/Contents/MacOS

env_vars:
  MISE_SHELL=fish

settings:
  experimental  true ~/.config/mise/config.toml
  experimental  true ~/foo/mise.toml

No problems found
@bartsmykla bartsmykla added the bug label Dec 22, 2024
@jdx
Copy link
Owner

jdx commented Dec 22, 2024

there is a TODO in the code which addresses why this happens—path gets loaded before tools. You can work around by having separate [[env]] sections. I probably won't work on this but would happily accept a PR.

// TODO: parse these in the order they're defined somehow

Repository owner locked and limited conversation to collaborators Dec 22, 2024
@jdx jdx converted this issue into discussion #3783 Dec 22, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
Projects
None yet
Development

No branches or pull requests

2 participants