Skip to content

fix(registry): apply overrides in shims#8199

Merged
jdx merged 4 commits intojdx:mainfrom
risu729:overrides-shims
Feb 17, 2026
Merged

fix(registry): apply overrides in shims#8199
jdx merged 4 commits intojdx:mainfrom
risu729:overrides-shims

Conversation

@risu729
Copy link
Contributor

@risu729 risu729 commented Feb 17, 2026

This was reported somewhere; it didn't work with shims before.

Copilot AI review requested due to automatic review settings February 17, 2026 07:41
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @risu729, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances how mise handles tool overrides, particularly for shims. It introduces a sophisticated graph-based topological sorting algorithm to ensure that when multiple tools are present and one is configured to override another (e.g., an explicit npm overriding a node-bundled npm), the correct, overriding tool is always prioritized. This change resolves potential ambiguities in tool resolution and improves the reliability of shim behavior, ensuring that user-defined tool preferences are consistently respected.

Highlights

  • New Tool Override Sorting Logic: A new sort_by_overrides function has been introduced in src/toolset/mod.rs. This function uses a directed graph and topological sort with priority queue to correctly order installed tools based on overrides relationships defined in the registry, ensuring that overriding tools are prioritized.
  • Integration into Tool Resolution: The new sort_by_overrides function is now utilized in Toolset::which and Toolset::which_bin methods, as well as in Toolset::list_paths, to ensure that the correct tool (e.g., an explicitly installed npm that overrides node's bundled npm) is selected when resolving binaries or paths.
  • Enhanced Testing: A new end-to-end test (e2e/registry/test_overrides_shims) has been added to validate the shim override behavior, specifically for npm overriding node. Additionally, unit tests for the sort_by_overrides function have been included to cover various override scenarios.
  • Refactored Path Listing: The previous ad-hoc sorting logic in Toolset::list_paths within src/toolset/toolset_paths.rs has been replaced with a call to the more robust sort_by_overrides function, simplifying the code and improving correctness.
Changelog
  • e2e/registry/test_overrides_shims
    • Added a new end-to-end test to verify correct shim behavior when tool overrides are configured.
  • src/toolset/mod.rs
    • Implemented sort_by_overrides function to topologically sort installed tools based on registry override relationships, including cycle detection.
    • Integrated sort_by_overrides into Toolset::which and Toolset::which_bin for proper tool prioritization.
    • Added unit tests for the sort_by_overrides function to ensure its correctness.
    • Imported necessary data structures and utilities like BinaryHeap, Reverse, DiGraphMap, Direction, REGISTRY, and bail.
  • src/toolset/toolset_paths.rs
    • Replaced the previous custom sorting logic in Toolset::list_paths with a call to the new Toolset::sort_by_overrides function.
    • Removed the unused import of REGISTRY.
Activity
  • risu729 created the pull request with the title "fix(registry): apply overrides in shims".
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
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 refactors the tool sorting logic to correctly handle overrides, for example, ensuring an explicitly installed npm is preferred over one bundled with node. The new implementation uses a topological sort on a dependency graph, which is a robust approach. I've identified a few places where error handling could be improved to prevent panics in case of misconfiguration, such as a cycle in tool overrides. I've also suggested a small fix in a test for consistency.

) -> Option<(Arc<dyn Backend>, ToolVersion)> {
for (p, tv) in self.list_current_installed_versions(config) {
let mut installed = self.list_current_installed_versions(config);
Self::sort_by_overrides(&mut installed).unwrap();
Copy link
Contributor

Choose a reason for hiding this comment

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

high

Using .unwrap() here can cause a panic if sort_by_overrides returns an error (e.g., due to a cycle in tool overrides). This would crash the mise process. It's better to handle the error gracefully, for instance by logging a warning and continuing with the unsorted list. This prevents a crash and informs the user of the configuration problem.

        if let Err(e) = Self::sort_by_overrides(&mut installed) {
            warn!("Failed to sort tools by overrides: {:#}", e);
        }

Copy link
Contributor Author

Choose a reason for hiding this comment

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

intended. The cycle in the registry must not be configured

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 ensures tool registry overrides ordering is respected when resolving shims/paths (e.g., an explicitly-installed npm should take precedence over Node’s bundled npm).

Changes:

  • Replaces ad-hoc override sorting in list_paths with a shared Toolset::sort_by_overrides implementation.
  • Applies override-aware ordering to which/which_bin resolution.
  • Adds unit + e2e coverage targeting npm/node override behavior for shims.

Reviewed changes

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

File Description
src/toolset/toolset_paths.rs Uses the new shared override-aware sort before building PATH entries.
src/toolset/mod.rs Introduces sort_by_overrides, applies it to which/which_bin, and adds a unit test.
e2e/registry/test_overrides_shims Adds an e2e regression test asserting shims pick explicit npm regardless of config order.

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

@risu729 risu729 marked this pull request as draft February 17, 2026 08:56
@risu729
Copy link
Contributor Author

risu729 commented Feb 17, 2026

/gemini review

@risu729 risu729 marked this pull request as ready for review February 17, 2026 09:52
Copy link
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 a fix to respect tool overrides in shims by sorting installed tools before path resolution. A new sort_by_overrides function using a graph-based topological sort is implemented for this. The changes look good and are supported by a new end-to-end test.

My main concern is the use of .unwrap() on the result of sort_by_overrides in multiple places. This could lead to a panic if a cycle is detected in the tool overrides, which is a critical issue. I've left comments with suggestions to handle these errors gracefully by either propagating the error or returning None.

@jdx jdx merged commit 1d76298 into jdx:main Feb 17, 2026
33 checks passed
@risu729 risu729 deleted the overrides-shims branch February 17, 2026 11:05
mise-en-dev added a commit that referenced this pull request Feb 18, 2026
### 🚀 Features

- **(mcp)** add run_task tool for executing mise tasks by @joaommartins
in [#8179](#8179)
- **(node)** suggest setting node.flavor if the flavor is not found in
mirror by @risu729 in [#8206](#8206)

### 🐛 Bug Fixes

- **(java)** sort order for shorthand versions by @roele in
[#8197](#8197)
- **(node)** migrate env vars to settings by @risu729 in
[#8200](#8200)
- **(registry)** apply overrides in shims by @risu729 in
[#8199](#8199)
- migrate MISE_CARGO_BINSTALL_ONLY to settings by @risu729 in
[#8202](#8202)

### 📚 Documentation

- **(doctor)** fix subcommand in an example by @risu729 in
[#8198](#8198)

### 📦 Registry

- add github backend for typst by @3w36zj6 in
[#8210](#8210)

### Chore

- **(test)** disable flaky Forgejo e2e test by @jdx in
[#8211](#8211)
lucasew pushed a commit to lucasew/CONTRIB-mise that referenced this pull request Feb 18, 2026
This was reported somewhere; it didn't work with shims before.
risu729 added a commit to risu729/mise that referenced this pull request Feb 27, 2026
This was reported somewhere; it didn't work with shims before.
risu729 pushed a commit to risu729/mise that referenced this pull request Feb 27, 2026
### 🚀 Features

- **(mcp)** add run_task tool for executing mise tasks by @joaommartins
in [jdx#8179](jdx#8179)
- **(node)** suggest setting node.flavor if the flavor is not found in
mirror by @risu729 in [jdx#8206](jdx#8206)

### 🐛 Bug Fixes

- **(java)** sort order for shorthand versions by @roele in
[jdx#8197](jdx#8197)
- **(node)** migrate env vars to settings by @risu729 in
[jdx#8200](jdx#8200)
- **(registry)** apply overrides in shims by @risu729 in
[jdx#8199](jdx#8199)
- migrate MISE_CARGO_BINSTALL_ONLY to settings by @risu729 in
[jdx#8202](jdx#8202)

### 📚 Documentation

- **(doctor)** fix subcommand in an example by @risu729 in
[jdx#8198](jdx#8198)

### 📦 Registry

- add github backend for typst by @3w36zj6 in
[jdx#8210](jdx#8210)

### Chore

- **(test)** disable flaky Forgejo e2e test by @jdx in
[jdx#8211](jdx#8211)
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