fix(registry): apply overrides in shims#8199
Conversation
Summary of ChangesHello @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 Highlights
Changelog
Activity
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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);
}There was a problem hiding this comment.
intended. The cycle in the registry must not be configured
There was a problem hiding this comment.
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_pathswith a sharedToolset::sort_by_overridesimplementation. - Applies override-aware ordering to
which/which_binresolution. - 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.
|
/gemini review |
There was a problem hiding this comment.
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.
### 🚀 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)
This was reported somewhere; it didn't work with shims before.
This was reported somewhere; it didn't work with shims before.
### 🚀 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)
This was reported somewhere; it didn't work with shims before.