Skip to content

Conversation

@antonsergeyev
Copy link
Contributor

@antonsergeyev antonsergeyev commented Dec 6, 2025

When parsing tools section, add locally defined environment variables to Tera context, so they are available for templating.

Note that this only allows using the variables from the current file. References to other files are not resolved.

Example:

[env]
TERRAFORM_VERSION = '1.0.0'
JQ_PREFIX = '1.6'

[tools]
terraform = "{{env.TERRAFORM_VERSION}}"
jq = { prefix = "{{ env.JQ_PREFIX }}" }

Also see this discussion: #3782


Note

Allow tools entries to reference environment variables defined in the same mise.toml via Tera context; update docs and add tests.

  • Core/Config (src/config/config_file/mise_toml.rs)
    • Add update_context_env to merge base env with local [env] vars and inject into Tera context (env).
    • Call update_context_env in init and from_str to enable templating env vars in tools (versions/options).
    • Imports updated to use EnvMap and env module.
  • Tests
    • Add test_env_var_in_tool verifying tools can use {{ env.VAR }}; add snapshot ...env_var_in_tool.snap.
  • Docs
    • docs/dev-tools/index.md: Note that tool versions can reference env vars defined in the same file (no resolution from referenced files).
    • docs/templates.md: Expand example showing [env]-defined var used in [tools], and external env via get_env().

Written by Cursor Bugbot for commit e437569. This will update automatically on new commits. Configure here.

Copilot AI review requested due to automatic review settings December 6, 2025 10:43
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR enables environment variable templating in the tools section of mise configuration files by adding locally defined environment variables to the Tera template context during parsing.

  • Allows tools to reference env vars defined in the same file using {{ env.VARIABLE_NAME }} syntax
  • Updates context initialization to include environment variables during config file parsing
  • Documents the new feature with examples and limitations

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/config/config_file/mise_toml.rs Implements env var context update logic and adds test coverage for the new templating feature
docs/templates.md Adds example showing env var usage in tools section
docs/dev-tools/index.md Documents the new templating capability and its limitation regarding referenced files

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

When parsing `tools` section, add locally defined
environment variables to Tera context,
so they are available for templating.

Note that this only allows using the variables from the current file.
References to other files are not resolved.
@jdx
Copy link
Owner

jdx commented Dec 8, 2025

bugbot run

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no bugs!


@jdx jdx merged commit 8f421fc into jdx:main Dec 8, 2025
30 checks passed
jdx pushed a commit that referenced this pull request Dec 8, 2025
### 🚀 Features

- **(npm)** support pnpm as a package manager for npm backend by
@risu729 in [#7214](#7214)
- **(tool-stubs)** add --bootstrap flag to mise generate tool-stub by
@jdx in [#7203](#7203)

### 🐛 Bug Fixes

- **(alpine)** increase alpine release timeout to 60 minutes by @jdx in
[#7188](#7188)
- **(bun)** use x64-baseline for aarch64 on Windows by @roele in
[#7190](#7190)
- **(tools)** allow using env vars in tools by @antonsergeyev in
[#7205](#7205)
- add cfg(feature = "self_update") to statics only used by that feature
by @jdx in [#7185](#7185)

### 📚 Documentation

- Update registry.md by @jdx in
[ad11ad1](ad11ad1)

### 📦️ Dependency Updates

- update ghcr.io/jdx/mise:alpine docker digest to 2909cce by
@renovate[bot] in [#7196](#7196)
- update fedora:43 docker digest to 6cd815d by @renovate[bot] in
[#7195](#7195)
- update ghcr.io/jdx/mise:deb docker digest to 1893530 by @renovate[bot]
in [#7198](#7198)
- update ghcr.io/jdx/mise:copr docker digest to 0447a85 by
@renovate[bot] in [#7197](#7197)

### 📦 Registry

- add Supabase CLI to registry.toml by @bodadotsh in
[#7206](#7206)
- add cmake aqua backend by @mangkoran in
[#7186](#7186)

### New Contributors

- @antonsergeyev made their first contribution in
[#7205](#7205)
- @bodadotsh made their first contribution in
[#7206](#7206)

## 📦 Aqua Registry Updates

#### New Packages (3)

- [`skanehira/ghost`](https://github.com/skanehira/ghost)
- [`square/certigo`](https://github.com/square/certigo)
- [`steveyegge/beads`](https://github.com/steveyegge/beads)

#### Updated Packages (8)

- [`apache/maven`](https://github.com/apache/maven)
- [`apple/container`](https://github.com/apple/container)
- [`aquasecurity/trivy`](https://github.com/aquasecurity/trivy)
- [`charmbracelet/crush`](https://github.com/charmbracelet/crush)
- [`goreleaser/goreleaser`](https://github.com/goreleaser/goreleaser)
- [`goreleaser/nfpm`](https://github.com/goreleaser/nfpm)
- [`ninja-build/ninja`](https://github.com/ninja-build/ninja)
- [`twpayne/chezmoi`](https://github.com/twpayne/chezmoi)
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