Skip to content

fix(cargo): reinstall when install options change - #11480

Merged
jdx merged 1 commit into
jdx:mainfrom
Marukome0743:pr11480
Jul 30, 2026
Merged

jdx merged 1 commit into
jdx:mainfrom
Marukome0743:pr11480

Conversation

@Marukome0743

@Marukome0743 Marukome0743 commented Jul 29, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • record the effective Cargo install options in .mise-cargo-install.toml for each installed version
  • reinstall when features, default-features, bin, crate, or locked changes
  • preserve legacy default installs and shadow incompatible shared installs in the primary install directory

Problem

Cargo artifacts are identified by more than the package version. The selected crate and binary determine what is installed, feature flags determine which code is compiled, and locked mode determines dependency resolution. Previously mise only checked whether the version directory existed, so changing any of these options could silently reuse the wrong artifact.

Approach

The Cargo backend now derives a normalized install state from the exact options passed to the installer. Feature strings and arrays are split on commas or whitespace, then sorted and deduplicated. Omitted locked and default-features values normalize to their existing true defaults, while bin is resolved for the current platform and crate records the selected override.

All successful external cargo-binstall, native binstall, and cargo install paths attempt to write the state file. A metadata write failure logs a warning and preserves the successfully installed artifact; the missing state then causes a non-default request to retry on the next install. A missing state file remains compatible with an all-default legacy install; missing state for non-default options, malformed state, option mismatches, and removal of non-default options trigger one reinstall.

When an incompatible artifact comes from a shared or system fallback, mise leaves that directory untouched and installs the requested variant into the primary user install directory instead.

install_env, registry selection, and cargo-binstall settings are intentionally excluded because they are execution inputs rather than public artifact-selection options and may contain secrets.

Benefits of tracking all five options

  • features and default-features select compiled code and capabilities.
  • bin selects which executable Cargo installs from a multi-binary package.
  • crate selects the workspace package for Git sources.
  • locked controls whether Cargo uses the committed dependency graph.

Treating the complete selection as the artifact identity prevents stale binaries without requiring users to remember --force.

Verification

  • mise exec -- cargo test backend::cargo::tests — 19 passed
  • mise run test:e2e e2e/backend/test_cargo_install_options_stub_slow — passed; covers all five changes, option removal, feature normalization, and shared shadowing
  • mise run test:e2e e2e/backend/test_cargo_install_options_slow — passed; recompiles the same local Git tag and changes runtime output after enabling a feature
  • mise run test:e2e e2e/backend/test_cargo_binstall_token — passed
  • mise run test:e2e e2e/cli/test_shared_install_dirs — passed
  • mise exec -- cargo check --all-features — passed
  • Cargo fmt, ShellCheck, shfmt, Markdownlint, and Prettier checks for changed files — passed
  • mise run lint cannot run as a wrapper in this Sapling working copy because hk reports failed to find git repository; the applicable checks above were run individually

Addresses #5235

AI-assisted — Tool: Codex; model: OpenAI/GPT-5; version: unavailable.

Summary by CodeRabbit

  • New Features
    • Cargo tool installs now record and reuse installation configuration (including selected features and flags) to ensure the requested variant is what’s installed.
    • Feature names are normalized so different orderings/representations are treated as equivalent, preventing unnecessary reinstalls.
  • Bug Fixes
    • Rolling-release upgrades now correctly shadow shared installs, leaving the shared copy unchanged.
  • Documentation
    • Updated Cargo backend docs to clarify how effective Cargo options are tracked and when reinstalls occur.
  • Tests
    • Added/expanded end-to-end coverage for Cargo install option determinism and rolling behavior.

@coderabbitai

coderabbitai Bot commented Jul 29, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Central YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: 685292bc-c635-4530-ace6-74775e6223bf

📥 Commits

Reviewing files that changed from the base of the PR and between fc28fdb and ac02412.

📒 Files selected for processing (10)
  • docs/dev-tools/backends/cargo.md
  • e2e/backend/test_cargo_binstall_token
  • e2e/backend/test_cargo_install_options_slow
  • e2e/backend/test_cargo_install_options_stub_slow
  • e2e/backend/test_vfox_rolling_install
  • src/backend/cargo.rs
  • src/backend/mod.rs
  • src/backend/vfox.rs
  • src/toolset/install_state.rs
  • src/toolset/outdated_info.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • docs/dev-tools/backends/cargo.md

📝 Walkthrough

Walkthrough

Cargo installations now persist normalized install options and compare them when deciding whether a version is satisfied. Install orchestration handles shared paths and rolling checksums by concrete install path, with unit, end-to-end, and documentation coverage.

Changes

Install state and rolling install paths

Layer / File(s) Summary
Persisted Cargo state and install integration
src/backend/cargo.rs
Cargo options are normalized, serialized to .mise-cargo-install.toml, compared during satisfaction checks, written after installs, and covered by unit tests.
Install orchestration and path-aware rolling checks
src/backend/mod.rs, src/backend/vfox.rs, src/toolset/install_state.rs, src/toolset/outdated_info.rs
Rolling checks receive ToolVersion, checksums are stored under concrete install paths, and shared-directory redirection uses precomputed installation satisfaction.
Behavior validation and Cargo documentation
e2e/backend/test_cargo_*, e2e/backend/test_vfox_rolling_install, docs/dev-tools/backends/cargo.md
Tests cover option changes, normalization, generated state, shared-install shadowing, rolling updates, and documented reinstall behavior.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant BackendInstallVersion
  participant CargoBackend
  participant InstallStateFile
  participant CargoInstaller
  User->>BackendInstallVersion: run mise install
  BackendInstallVersion->>CargoBackend: check version and normalized options
  CargoBackend->>InstallStateFile: read persisted install state
  alt state is not satisfied
    BackendInstallVersion->>CargoInstaller: install Cargo version
    CargoInstaller->>InstallStateFile: write normalized options
  else state is satisfied
    BackendInstallVersion-->>User: report already installed
  end
Loading

Possibly related PRs

  • jdx/mise#11207: Related install-state locking and shared install mutation handling in the backend installation flow.

Suggested reviewers: jdx

Poem

I’m a rabbit with options tucked tight,
Features sorted and states kept right.
Cargo hops, installs anew,
Reuses builds when choices stay true.
Shared paths keep their tales in view—
Ears up for mise, and carrots too!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: Cargo now reinstalls when install options change.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/backend/cargo.rs`:
- Line 265: Make all three write_install_state call sites in install_version_
best-effort: handle write errors by logging them and continue returning the
successful install result instead of propagating with ?. Apply the same behavior
to the additional state write path around lines 391-397, preserving normal error
handling for the actual installation commands.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Central YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: 14f29d5d-c20b-4d05-a155-b42161b82e2a

📥 Commits

Reviewing files that changed from the base of the PR and between ca91ccc and 22e2ba9.

📒 Files selected for processing (6)
  • docs/dev-tools/backends/cargo.md
  • e2e/backend/test_cargo_binstall_token
  • e2e/backend/test_cargo_install_options_slow
  • e2e/backend/test_cargo_install_options_stub_slow
  • src/backend/cargo.rs
  • src/backend/mod.rs

Comment thread src/backend/cargo.rs Outdated
@Marukome0743
Marukome0743 marked this pull request as ready for review July 30, 2026 01:39
@greptile-apps

greptile-apps Bot commented Jul 30, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR makes Cargo installation identity sensitive to artifact-selection options and improves handling of shared rolling installs.

  • Records normalized Cargo features, default-feature behavior, binary, crate, and lockfile mode beside successful installations.
  • Reinstalls Cargo tools when the requested installation state differs while preserving compatibility with legacy default installs.
  • Redirects incompatible shared installations into the primary install directory rather than modifying shared artifacts.
  • Reads and writes rolling-version checksums relative to the resolved physical installation path.
  • Adds unit, end-to-end, and documentation coverage for option changes, normalization, shared shadowing, and rolling upgrades.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
src/backend/cargo.rs Adds normalized Cargo option-state persistence and incorporates that state into installation satisfaction checks.
src/backend/mod.rs Updates generic installation flow to shadow unsatisfied fallback installations and passes resolved tool versions into rolling checksum checks.
src/toolset/install_state.rs Changes rolling checksum storage from logical tool/version keys to physical installation paths.
src/backend/vfox.rs Writes rolling release checksums into the actual installation directory.
src/toolset/outdated_info.rs Uses the resolved ToolVersion when checking whether rolling installations are outdated.
e2e/backend/test_cargo_install_options_stub_slow Covers Cargo option changes, normalization, option removal, metadata persistence, and shared-install shadowing.
e2e/backend/test_vfox_rolling_install Extends rolling-install coverage to shared fallback resolution and primary-directory shadowing.

Reviews (3): Last reviewed commit: "fix(cargo): reinstall when install optio..." | Re-trigger Greptile

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/backend/mod.rs`:
- Around line 2389-2404: Confirm and encode the intended behavior around
install_satisfied and rolling_reinstall in the install flow: add coverage for
outdated rolling-channel installs using shared paths, or adjust the redirect
condition so rolling checksum staleness does not redirect an otherwise matching
shared install. Anchor the change in is_install_satisfied_or_false,
rolling_reinstall, and the shared-install redirect block, preserving forced and
genuinely unsatisfied install behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Central YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: f4a2ae12-48c1-40f1-a37d-3de4c0a9b880

📥 Commits

Reviewing files that changed from the base of the PR and between 22e2ba9 and fc28fdb.

📒 Files selected for processing (6)
  • docs/dev-tools/backends/cargo.md
  • e2e/backend/test_cargo_binstall_token
  • e2e/backend/test_cargo_install_options_slow
  • e2e/backend/test_cargo_install_options_stub_slow
  • src/backend/cargo.rs
  • src/backend/mod.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • docs/dev-tools/backends/cargo.md

Comment thread src/backend/mod.rs
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.

3 participants