Skip to content

feat(config): add lockfile_platforms setting to restrict lockfile platforms#8966

Merged
jdx merged 6 commits intojdx:mainfrom
cameronbrill:feat/lockfile-platforms
Apr 9, 2026
Merged

feat(config): add lockfile_platforms setting to restrict lockfile platforms#8966
jdx merged 6 commits intojdx:mainfrom
cameronbrill:feat/lockfile-platforms

Conversation

@cameronbrill
Copy link
Copy Markdown
Contributor

@cameronbrill cameronbrill commented Apr 8, 2026

Summary

  • Adds a new lockfile_platforms setting that controls which platforms are targeted during lockfile operations
  • When set, mise install, mise use, and mise lock (without --platform) only resolve checksums/URLs for the configured platforms instead of all 7 common platforms
  • Uses the same validation as mise lock --platform — invalid platform strings produce a hard error
  • Does NOT override explicit mise lock --platform flags

Closes #8610

Usage

[settings]
lockfile_platforms = ["macos-arm64", "linux-x64"]

Or via environment variable:

MISE_LOCKFILE_PLATFORMS=macos-arm64,linux-x64

Test plan

  • cargo check — compiles cleanly
  • mise run lint — all lints pass
  • mise run test:e2e test_lockfile_platforms_setting — new e2e test passes (4 test cases: auto-lock restriction, mise lock restriction, --platform override, setting via mise.toml)
  • mise run test:e2e test_lockfile_existing_platforms — existing test still passes

🤖 Generated with Claude Code

…latforms

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 8, 2026

Greptile Summary

Adds a lockfile_platforms setting (and matching MISE_LOCKFILE_PLATFORMS env var) that restricts which platforms are resolved during auto-lock and mise lock without --platform. The implementation is clean: both resolution paths (determine_target_platforms_from_lockfile and determine_existing_platforms) check the setting first and return early, --platform continues to take full precedence, and the docs correctly note that the running machine's platform is always appended.

Confidence Score: 5/5

Safe to merge; all remaining findings are P2 test-coverage suggestions that do not affect runtime behaviour.

The logic changes are minimal and well-bounded — two functions whose return types were promoted to Result and a new setting lookup added before the existing default paths. Previous P1 concerns (missing positive assertions, undocumented current-platform behaviour) have been addressed. Only P2 style gaps remain in the e2e test.

e2e/lockfile/test_lockfile_platforms_setting — Test 3 could add negative assertions to fully validate the --platform override semantics.

Vulnerabilities

No security concerns identified. Platform strings are validated through the existing Platform::parse/validate pipeline — invalid values surface as hard errors rather than being silently ignored.

Important Files Changed

Filename Overview
src/lockfile.rs Adds lockfile_platforms setting awareness to both auto-lock and explicit-lock platform resolution; return types promoted to Result; logic is correct and well-structured.
src/cli/lock.rs Minimal change: propagates the new Result return type from determine_existing_platforms; --platform flag continues to bypass the setting correctly.
src/config/settings.rs Adds lockfile_platforms() helper that parses and validates platform strings; empty-vec guard returns None (default behaviour) cleanly.
settings.toml New lockfile_platforms setting entry is complete with description, env var, comma-list parsing, and updated docs noting the always-included current platform.
e2e/lockfile/test_lockfile_platforms_setting Five test cases covering env-var, mise lock, --platform override, mise.toml, and mise use; positive + negative assertions added; Test 3 (--platform override) missing negative assertions for the configured platforms.
schema/mise.json Schema updated to include the new lockfile_platforms array-of-strings field; straightforward addition.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[mise install / mise use / mise lock] --> B{--platform flag given?}
    B -- Yes --> C[Platform::parse_multiple CLI args\nreturn those platforms only]
    B -- No --> D{lockfile_platforms\nsetting configured?}
    D -- Yes --> E[Use configured platforms\n+ always insert current platform]
    D -- No --> F{Existing lockfile\nhas platform entries?}
    F -- Yes --> G[Use existing lockfile platforms\n+ current platform]
    F -- No --> H[Use all common platforms\n+ current platform]
    E --> I[Resolve checksums / update lockfile]
    C --> I
    G --> I
    H --> I
Loading

Reviews (6): Last reviewed commit: "[autofix.ci] apply automated fixes" | Re-trigger Greptile

Comment thread settings.toml
Comment thread settings.toml
Comment thread e2e/lockfile/test_lockfile_platforms_setting
Comment thread e2e/lockfile/test_lockfile_platforms_setting Outdated
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces the lockfile_platforms setting, allowing users to restrict lockfile operations to specific platforms to reduce file size and improve installation speed. The implementation includes updates to the configuration schema, documentation, and the logic for resolving target platforms. Feedback suggests refactoring duplicated platform-merging logic in src/lockfile.rs into a helper function and updating the documentation to clarify that the current platform is always included in the target set regardless of the configuration.

Comment thread src/lockfile.rs
Comment thread src/lockfile.rs
…assertions

Address bot review feedback:
- Document that current platform is always included in lockfile_platforms
- Add positive assertions to e2e test (verify configured platforms ARE present)
- Use $MISE_PLATFORM to verify current platform auto-inclusion

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 8, 2026

Tip:

Greploops — Automatically fix all review issues by running /greploops in Claude Code. It iterates: fix, push, re-review, repeat until 5/5 confidence.

Use the Greptile plugin for Claude Code to query reviews, search comments, and manage custom context directly from your terminal.

cameronbrill and others added 2 commits April 8, 2026 11:21
Platform::current() auto-inserts the current platform (e.g. linux-x64-musl
on musl runners), so negative assertions for musl platforms are unreliable.
The windows-x64 assertions already prove the restriction works.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The original issue was about `mise use` overwriting lockfile platforms.
Add explicit test coverage for this code path.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@cameronbrill cameronbrill marked this pull request as ready for review April 8, 2026 19:49
Comment thread e2e/lockfile/test_lockfile_platforms_setting Outdated
@jdx jdx merged commit efaedc2 into jdx:main Apr 9, 2026
34 checks passed
mise-en-dev added a commit that referenced this pull request Apr 10, 2026
### 🚀 Features

- **(config)** add lockfile_platforms setting to restrict lockfile
platforms by @cameronbrill in
[#8966](#8966)
- **(sandbox)** support wildcard patterns in allow_env by @jdx in
[#8974](#8974)
- bump usage-lib v2 → v3 to render examples in task --help by @baby-joel
in [#8890](#8890)

### 🐛 Bug Fixes

- **(activate)** handle empty __MISE_FLAGS array with set -u on bash 3.2
by @jdx in [#8988](#8988)
- **(env)** add trace logging for module hook PATH diagnostics by @jdx
in [#8981](#8981)
- **(go)** Query module proxy directly for version resolution by @c22 in
[#8968](#8968)
- **(install)** render tera templates in tool postinstall hooks by @jdx
in [#8978](#8978)
- **(install)** add missing env vars to tool postinstall hooks by @jdx
in [#8977](#8977)
- **(task)** prevent hang when skipped task has dependents by @jdx in
[#8937](#8937)
- **(task)** invalidate dependent task sources when dependency runs by
@jdx in [#8975](#8975)
- **(task)** prevent deadlock when MISE_JOBS=1 with sub-task references
by @jdx in [#8976](#8976)
- **(task)** fetch remote task files before parsing usage specs by @jdx
in [#8979](#8979)
- **(task)** prevent panic when running parallel sub-tasks with
replacing output by @jdx in
[#8986](#8986)
- **(upgrade)** update lockfile and config when upgrading to specific
version by @jdx in [#8983](#8983)

### 📚 Documentation

- **(node)** remove "recommended for teams" from pin example by @jdx in
[b334363](b334363)

### 📦️ Dependency Updates

- update ghcr.io/jdx/mise:alpine docker digest to 17a29f2 by
@renovate[bot] in [#8995](#8995)
- update docker/dockerfile:1 docker digest to 2780b5c by @renovate[bot]
in [#8994](#8994)

### New Contributors

- @baby-joel made their first contribution in
[#8890](#8890)
- @cameronbrill made their first contribution in
[#8966](#8966)
- @c22 made their first contribution in
[#8968](#8968)
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