-
-
Notifications
You must be signed in to change notification settings - Fork 769
feat(lockfile): add env field and local lockfile support #7099
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
Conversation
There was a problem hiding this 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 adds environment-specific version tracking and local lockfile support to mise. When using environment-specific configs (e.g., mise.test.toml), tools are now marked with an env field in the lockfile. Local configs (mise.local.toml) use a separate mise.local.lock file to avoid committing local-only tools. Version resolution prioritizes environment-specific entries when MISE_ENV is set, falling back to base entries.
Key Changes
- Added
env: Option<Vec<String>>field toLockfileToolfor tracking which environments use a tool version - Implemented
lockfile_path_for_config()to determine lockfile path (main vs local) based on config filename - Enhanced
get_locked_version()with environment-aware resolution logic - Added
--localflag tomise lockcommand
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| src/lockfile.rs | Core implementation: added env field, config-to-lockfile mapping, env-aware resolution, and local lockfile support |
| src/cli/lock.rs | Added --local flag to target mise.local.lock instead of mise.lock |
| e2e/lockfile/test_lockfile_local | Test verifying local configs use separate lockfile |
| e2e/lockfile/test_lockfile_env_resolution | Test verifying correct version selection based on MISE_ENV |
| e2e/lockfile/test_lockfile_env | Test verifying env field is written when using MISE_ENV |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| } else { | ||
| Some(envs.into_iter().sorted().collect()) | ||
| }; | ||
| tool |
Copilot
AI
Nov 27, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code sorts by version as strings, which will produce incorrect ordering for semantic versions (e.g., '10.0.0' will sort before '2.0.0'). Consider using semver comparison or a version-aware sorting function.
| return Ok(None); | ||
| } | ||
|
|
||
| let current_envs: HashSet<&str> = env::MISE_ENV.iter().map(|s| s.as_str()).collect(); |
Copilot
AI
Nov 27, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The variable name current_envs is misleading since env::MISE_ENV is likely a single environment value, not multiple environments. Consider renaming to current_env_set or active_envs to clarify this is a set created from the environment value(s).
| .file_name() | ||
| .and_then(|n| n.to_str()) | ||
| .unwrap_or_default(); | ||
| filename.contains(".local.") |
Copilot
AI
Nov 27, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using string contains for pattern matching is fragile. This would match unintended filenames like 'mise.local.backup.toml' or 'not-local.toml'. Consider using a more precise pattern match or regex to ensure only configs with '.local.' in the expected position are matched.
| filename.contains(".local.") | |
| // Match: mise.local.toml, .mise.local.toml, config.local.toml | |
| let re = regex!(r"^(?:\.?mise|config)\.local\.toml$"); | |
| re.is_match(filename) |
src/lockfile.rs
Outdated
|
|
||
| // Pattern: mise.{env}.toml or .mise.{env}.toml or config.{env}.toml | ||
| // But not mise.toml, .mise.toml, config.toml, or config.local.toml | ||
| let re = regex!(r"^(?:\.?mise|config)\.([^.]+)\.toml$"); |
Copilot
AI
Nov 27, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The regex pattern doesn't match against the actual filename variable. The pattern is defined but re.captures(filename) on line 280 may not work as intended if the pattern needs to account for different file extensions or naming conventions used in the codebase.
| let re = regex!(r"^(?:\.?mise|config)\.([^.]+)\.toml$"); | |
| // Updated regex: allow env names with letters, numbers, dashes, and underscores | |
| let re = regex!(r"^(?:\.?mise|config)\.([a-zA-Z0-9_-]+)\.toml$"); |
| tool.env = if has_base || envs.is_empty() { | ||
| None | ||
| } else { | ||
| Some(envs.into_iter().sorted().collect()) |
Copilot
AI
Nov 27, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Calling sorted() on every tool entry during lockfile updates could be inefficient when processing many tools. Since envs is already a BTreeSet which maintains sorted order, convert it directly to a Vec without additional sorting.
| Some(envs.into_iter().sorted().collect()) | |
| Some(envs.into_iter().collect()) |
| for (short, tools) in l.tools { | ||
| let existing = acc.tools.entry(short).or_default(); | ||
| for tool in tools { | ||
| // Avoid duplicates (same version+options+env) | ||
| if !existing.iter().any(|t| { | ||
| t.version == tool.version && t.options == tool.options && t.env == tool.env | ||
| }) { |
Copilot
AI
Nov 27, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This linear search through existing tools for duplicates creates O(n²) complexity when merging lockfiles with many tools. Consider using a HashSet with a custom key (version, options, env) for O(1) duplicate detection.
| for (short, tools) in l.tools { | |
| let existing = acc.tools.entry(short).or_default(); | |
| for tool in tools { | |
| // Avoid duplicates (same version+options+env) | |
| if !existing.iter().any(|t| { | |
| t.version == tool.version && t.options == tool.options && t.env == tool.env | |
| }) { | |
| use std::collections::HashSet; | |
| for (short, tools) in l.tools { | |
| let existing = acc.tools.entry(short).or_default(); | |
| // Build a set of existing keys for O(1) duplicate detection | |
| let mut seen: HashSet<(String, Option<serde_json::Value>, Option<serde_json::Value>)> = existing | |
| .iter() | |
| .map(|t| (t.version.clone(), t.options.clone(), t.env.clone())) | |
| .collect(); | |
| for tool in tools { | |
| let key = (tool.version.clone(), tool.options.clone(), tool.env.clone()); | |
| if !seen.contains(&key) { | |
| seen.insert(key); |
7dd085f to
51a7927
Compare
- Add `env` field to LockfileTool for environment-specific version tracking - Environment configs (mise.test.toml) write entries with `env = ["test"]` - Local configs (mise.local.toml) use separate mise.local.lock file - Env-aware resolution: env-specific match → base entry → fallback - Add --local flag to `mise lock` command - Add e2e tests for env and local lockfile behavior 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
51a7927 to
7bd164b
Compare
Hyperfine Performance
|
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
mise-2025.11.10 x -- echo |
19.6 ± 0.4 | 19.0 | 23.1 | 1.00 ± 0.04 |
mise x -- echo |
19.5 ± 0.6 | 18.5 | 21.2 | 1.00 |
mise env
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
mise-2025.11.10 env |
19.3 ± 0.5 | 18.6 | 25.7 | 1.02 ± 0.04 |
mise env |
18.9 ± 0.5 | 18.1 | 23.3 | 1.00 |
mise hook-env
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
mise-2025.11.10 hook-env |
19.2 ± 0.3 | 18.6 | 20.5 | 1.03 ± 0.03 |
mise hook-env |
18.7 ± 0.4 | 18.1 | 22.3 | 1.00 |
mise ls
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
mise-2025.11.10 ls |
16.5 ± 0.3 | 15.9 | 20.0 | 1.03 ± 0.03 |
mise ls |
16.0 ± 0.3 | 15.5 | 18.0 | 1.00 |
xtasks/test/perf
| Command | mise-2025.11.10 | mise | Variance |
|---|---|---|---|
| install (cached) | 107ms | 108ms | +0% |
| ls (cached) | 65ms | 65ms | +0% |
| bin-paths (cached) | 70ms | 71ms | -1% |
| task-ls (cached) | 424ms | 423ms | +0% |
582feaf to
c69f974
Compare
dd6ed40 to
1c2aeca
Compare
1c2aeca to
61dcb6b
Compare
- Add caching to read_all_lockfiles using Arc<Lockfile> - Change read_lockfile_for to use Arc<Lockfile> instead of cloning - Fix extract_env_from_config_path for mise.test.local.toml configs 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
cfaeb1f to
c1b223f
Compare
Document known limitation where base lockfile entries can be lost when env-specific configs override them. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [docker/metadata-action](https://github.com/docker/metadata-action) | action | digest | `318604b` -> `c299e40` | --- ### Configuration 📅 **Schedule**: Branch creation - "before 4am on friday" in timezone America/Chicago, Automerge - At any time (no schedule defined). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR was generated by [Mend Renovate](https://mend.io/renovate/). View the [repository job log](https://developer.mend.io/github/jdx/mise). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0Mi4xOS45IiwidXBkYXRlZEluVmVyIjoiNDIuMTkuOSIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOltdfQ==--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
…7102) This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | ghcr.io/jdx/mise | container | digest | `7351bbe` -> `693c5f6` | --- ### Configuration 📅 **Schedule**: Branch creation - "before 4am on friday" in timezone America/Chicago, Automerge - At any time (no schedule defined). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR was generated by [Mend Renovate](https://mend.io/renovate/). View the [repository job log](https://developer.mend.io/github/jdx/mise). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0Mi4xOS45IiwidXBkYXRlZEluVmVyIjoiNDIuMTkuOSIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOltdfQ==--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
) This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | ghcr.io/jdx/mise | container | digest | `3a847f2` -> `9985cab` | --- ### Configuration 📅 **Schedule**: Branch creation - "before 4am on friday" in timezone America/Chicago, Automerge - At any time (no schedule defined). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR was generated by [Mend Renovate](https://mend.io/renovate/). View the [repository job log](https://developer.mend.io/github/jdx/mise). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0Mi4xOS45IiwidXBkYXRlZEluVmVyIjoiNDIuMTkuOSIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOltdfQ==--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
…7103) This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | ghcr.io/jdx/mise | container | digest | `546dffb` -> `564d8e1` | --- ### Configuration 📅 **Schedule**: Branch creation - "before 4am on friday" in timezone America/Chicago, Automerge - At any time (no schedule defined). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR was generated by [Mend Renovate](https://mend.io/renovate/). View the [repository job log](https://developer.mend.io/github/jdx/mise). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0Mi4xOS45IiwidXBkYXRlZEluVmVyIjoiNDIuMTkuOSIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOltdfQ==--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
When running with MISE_ENV=test and mise.test.toml overrides a tool from mise.toml, the base lockfile entry was being silently dropped. This caused subsequent runs without MISE_ENV to use the wrong version. The fix preserves base entries (env=None) from the existing lockfile that aren't in the new entries before merging. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
f0b5259 to
db7e5b0
Compare
When updating an env-specific tool (e.g., upgrading from 2.0.0 to 2.1.0 with env=["test"]), check if the existing entry's env values are already covered by a new entry before preserving. This prevents stale entries from being kept when the user updates an env-specific version. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
## Summary Updates the lockfile documentation (`docs/dev-tools/mise-lock.md`) to reflect the recent changes since v2025.11.10: - **#7091** - Cross-platform lockfile generation - **#7093** - Always use TOML array format `[[tools.name]]` - **#7092** - Added `options` field for backend-specific artifact identity - **#7098** - Added `locked` setting for strict lockfile mode - **#7099** - Added `env` field and `mise.local.lock` support ### Changes - Update file format examples to use array syntax `[[tools.name]]` - Add documentation for new fields: `options`, `env` - Add **Environment-Specific Versions** section (env field, MISE_ENV workflow) - Add **Local Lockfiles** section (mise.local.lock, --local flag) - Add **Strict Lockfile Mode** section (locked setting) - Remove outdated **Legacy Format Migration** and **Benefits of the New Format** sections ## Test plan - [ ] Verify docs build correctly with `mise run docs` - [ ] Review documentation renders correctly on the site 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Refreshes `mise.lock` docs to use `[[tools.name]]` array syntax, add `options`/`env`, document environment-specific and local lockfiles, and introduce strict `locked` mode while removing obsolete sections. > > - **Docs (lockfile)** > - **File format**: > - Switch examples to `[[tools.name]]` array syntax > - Add fields: `options`, `env`; clarify `platforms` metadata and platform key formats > - **Environment-specific versions**: > - Document `MISE_ENV` workflow and resolution priority; show `mise.test.toml` example > - **Local lockfiles**: > - Explain `mise.local.toml` → `mise.local.lock`, `--local` usage and commands > - **Strict lockfile mode**: > - Add `locked` setting (`mise settings locked=true`, `MISE_LOCKED=1`) and `mise lock` URL pre-resolution workflow > - **Cleanup**: > - Remove Legacy Format Migration and Benefits sections > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit e6fe67f. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY --> Co-authored-by: Claude <[email protected]>
### 🚀 Features - **(backend)** add filter_bins option to github/gitlab backends by @risu729 in [#7105](#7105) - **(ci)** auto-close PRs from non-maintainers by @jdx in [#7108](#7108) - **(conda)** add conda backend for installing packages from conda-forge by @jdx in [#7139](#7139) - **(github)** add rename_exe option and switch elm, opam, yt-dlp from ubi by @jdx in [#7140](#7140) - **(install)** add --locked flag for strict lockfile mode by @jdx in [#7098](#7098) - **(lock)** implement cross-platform lockfile generation by @jdx in [#7091](#7091) - **(lockfile)** add options field for tool artifact identity by @jdx in [#7092](#7092) - **(lockfile)** add env field and local lockfile support by @jdx in [#7099](#7099) - **(lockfile)** add URL support for deno, go, and zig backends by @jdx in [#7112](#7112) - **(lockfile)** add URL support for vfox backend by @jdx in [#7114](#7114) - **(lockfile)** add multi-platform checksums without downloading tarballs by @jdx in [#7113](#7113) ### 🐛 Bug Fixes - **(backend)** allow platform-specific strip_components by @risu729 in [#7106](#7106) - **(backend)** prefer path root for bin path if it contains an executable by @risu729 in [#7151](#7151) - **(bash)** avoid deactivate error on (no)unset PROMPT_COMMAND by @scop in [#7096](#7096) - **(ci)** use updatedAt instead of createdAt for stale PR detection by @jdx in [#7109](#7109) - **(github)** search subdirectories for executables in discover_bin_paths by @jdx in [#7138](#7138) - **(lockfile)** combine api_url with asset_pattern for GitHub release URLs by @jdx in [#7111](#7111) ### 🚜 Refactor - **(lock)** simplify lockfile to always use array format by @jdx in [#7093](#7093) - **(lockfile)** use compact inline table format by @jdx in [#7141](#7141) ### 📚 Documentation - **(gitlab)** document rename_exe option also for gitlab backend by @risu729 in [#7149](#7149) - **(lockfile)** update documentation for recent lockfile changes by @jdx in [#7107](#7107) - **(node)** use config_root in _.path for pnpm example by @risu729 in [#7146](#7146) - **(registry)** add github/gitlab backends to the preferred backends list by @risu729 in [#7148](#7148) - **(registry)** add url mappings for all backends by @risu729 in [#7147](#7147) ### 📦️ Dependency Updates - update docker/metadata-action digest to c299e40 by @renovate[bot] in [#7101](#7101) - update ghcr.io/jdx/mise:alpine docker digest to 693c5f6 by @renovate[bot] in [#7102](#7102) - update ghcr.io/jdx/mise:deb docker digest to 9985cab by @renovate[bot] in [#7104](#7104) - update ghcr.io/jdx/mise:copr docker digest to 564d8e1 by @renovate[bot] in [#7103](#7103) - update rust crate ubi to 0.8.4 by @risu729 in [#7154](#7154) ### 📦 Registry - add aqua backend as primary for e1s by @jdx in [#7115](#7115) - add gem backend for bashly by @jdx in [6af6607](6af6607) - switch 1password from asdf to vfox backend by @jdx in [#7116](#7116) - add vfox backend for bfs by @jdx in [#7126](#7126) - add github backend for btrace by @jdx in [#7129](#7129) - add github backend for cf by @jdx in [#7131](#7131) - add vfox backend for bpkg by @jdx in [#7130](#7130) - switch apollo-ios from asdf to github backend by @jdx in [#7118](#7118) - add vfox backend for chromedriver by @jdx in [#7134](#7134) - switch superhtml, vespa-cli, xcsift from ubi to github backend by @jdx in [#7137](#7137) - add vfox backend for clickhouse by @jdx in [#7136](#7136) - switch chicken to vfox plugin by @jdx in [#7135](#7135) - switch chezscheme from asdf to vfox backend by @jdx in [#7132](#7132) - add vfox backend for carthage by @jdx in [#7133](#7133) - switch azure-functions-core-tools from asdf to vfox backend by @jdx in [#7128](#7128) - switch aapt2 to vfox backend by @jdx in [#7117](#7117) - switch ant to vfox backend by @jdx in [#7119](#7119) - switch asciidoctorj from asdf to vfox backend by @jdx in [#7121](#7121) - switch awscli-local to pipx backend by @jdx in [#7120](#7120) - add omnictl by @risu729 in [#7145](#7145) - remove pnpm asdf plugin from fallback by @risu729 in [#7143](#7143) - switch tanzu to github backend by @jdx in [#7124](#7124) - switch android-sdk to vfox plugin by @jdx in [#7127](#7127) - add vfox backend for ag (The Silver Searcher) by @jdx in [#7122](#7122) ### Chore - **(registry)** ignore deleted tools in test-tool workflow by @risu729 in [#7081](#7081) - **(release)** show registry section last in changelog by @jdx in [#7156](#7156) - update mise.lock with checksums by @jdx in [71e9123](71e9123) - disable cancel-in-progress for test workflow on main branch by @risu729 in [#7152](#7152) ## 📦 Aqua Registry Updates #### Updated Packages (1) - [`orf/gping`](https://github.com/orf/gping)
Summary
envfield toLockfileToolfor environment-specific version trackingmise.test.toml) write entries withenv = ["test"]to the samemise.lockmise.local.toml) use separatemise.local.lockfile (intended to be gitignored)--localflag tomise lockcommand for explicit local lockfile generationTest plan
e2e/lockfile/test_lockfile_env- verifies env field is written when using MISE_ENVe2e/lockfile/test_lockfile_env_resolution- verifies correct version is selected based on MISE_ENVe2e/lockfile/test_lockfile_local- verifies separation of local vs base lockfiles🤖 Generated with Claude Code
Note
Adds env-aware lockfile entries and separate local lockfile support, introduces
--localtomise lock, and updates docs, tests, completions, and CI refs.envfield toLockfileTooland env-aware resolution/prioritization inget_locked_version.mise.local.lockwith per-config lockfile path resolution and merging logic.version+options; cache lockfile reads.mise lock):--localflag to targetmise.local.lock.docs/cli/lock.md,man/man1/mise.1, andmise.usage.kdlwith--localand examples.xtasks/fig/src/mise.ts) to include--local.docker/metadata-actionrefs in workflows.Written by Cursor Bugbot for commit 742525d. This will update automatically on new commits. Configure here.