fix(npm): improve error message when npm/bun is not installed#6359
Merged
fix(npm): improve error message when npm/bun is not installed#6359
Conversation
- Added check_npm_available() method to detect if npm or bun is installed - Checks use dependency_which() to include tools installed via mise - Provides helpful error messages suggesting how to install the missing tool - Added e2e test to verify the error messages Fixes #6357 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR improves error handling in the npm backend by detecting when npm or bun is not installed and providing helpful error messages with installation suggestions.
- Adds a
check_npm_available()method to verify tool availability before operations - Uses
dependency_which()to check for tools including those installed via mise - Provides specific error messages suggesting how to install the missing tool or switch alternatives
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/backend/npm.rs | Adds npm/bun availability check with helpful error messages to npm backend operations |
| e2e/backend/test_npm_missing_error | Adds comprehensive e2e test to verify error messages when npm/bun is not available |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
src/backend/npm.rs
Outdated
| } | ||
| } | ||
|
|
||
| async fn check_npm_available(&self, config: &Arc<Config>) -> Result<()> { |
There was a problem hiding this comment.
[nitpick] The method name 'check_npm_available' is misleading since it checks for both npm and bun depending on configuration. Consider renaming to 'check_package_manager_available' or 'check_required_tool_available' to better reflect its dual purpose.
Suggested change
| async fn check_npm_available(&self, config: &Arc<Config>) -> Result<()> { | |
| async fn check_package_manager_available(&self, config: &Arc<Config>) -> Result<()> { |
- Added dependency checks to all package manager backends (cargo, gem, go, pipx, dotnet, spm) - Each backend now checks if its required tool is installed before attempting operations - Provides helpful error messages suggesting how to install the missing dependency - Added e2e test to verify error messages for missing dependencies 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
- Add ensure_dependency() helper method to Backend trait to reduce duplication - Update npm backend to use bun for _list_remote_versions and latest_stable_version when configured - Replace duplicated dependency checking code across all package manager backends (npm, cargo, gem, go, pipx, dotnet, spm) with the new helper - Consolidate npm-specific test into general backend dependency test - All backends now provide consistent, helpful error messages when dependencies are missing Addresses discussion #6357 to improve error messages when package manager dependencies are not installed 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Fix test_backend_missing_deps to fail (not warn) when tools are in PATH - Remove unnecessary mise availability check from e2e test - Add comprehensive test_npm_bun for npm backend's bun mode behavior - Test properly checks if bun supports 'view' command before testing - Fix shellcheck warning about stderr/stdout redirection order 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Hyperfine Performance
|
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
mise-2025.9.14 x -- echo |
19.6 ± 0.4 | 19.0 | 23.6 | 1.00 |
mise x -- echo |
19.8 ± 0.7 | 19.3 | 29.5 | 1.01 ± 0.04 |
mise env
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
mise-2025.9.14 env |
19.1 ± 0.3 | 18.5 | 22.8 | 1.00 |
mise env |
19.2 ± 0.4 | 18.7 | 22.1 | 1.01 ± 0.02 |
mise hook-env
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
mise-2025.9.14 hook-env |
18.9 ± 0.8 | 18.3 | 27.7 | 1.00 ± 0.05 |
mise hook-env |
18.8 ± 0.3 | 18.2 | 21.3 | 1.00 |
mise ls
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
mise-2025.9.14 ls |
16.6 ± 0.3 | 16.1 | 19.7 | 1.00 |
mise ls |
16.9 ± 1.0 | 16.2 | 30.6 | 1.02 ± 0.07 |
xtasks/test/perf
| Command | mise-2025.9.14 | mise | Variance |
|---|---|---|---|
| install (cached) | 169ms | ✅ 104ms | +62% |
| ls (cached) | 63ms | 63ms | +0% |
| bin-paths (cached) | 69ms | 71ms | -2% |
| task-ls (cached) | 467ms | 477ms | -2% |
✅ Performance improvement: install cached is 62%
- npm is now always required for version queries (even in bun mode) - bun is only required for actual package installation when npm.bun=true - Added TODOs to support bun-native version queries once bun supports it - Updated tests to verify correct error messages for missing dependencies - Clarified that bun info requires package.json and cannot be used for registry queries Fixes #6357
- Created generic helper functions test_backend_command() and test_missing_dependency() - Consolidated test cases into a data-driven approach with test_cases array - Reduced code duplication by ~60% while maintaining same test coverage - Made it easier to add new backend tests in the future
- Remove complex data structure and parsing logic - Use simple, direct test functions for each backend - Reduce cognitive complexity while maintaining coverage - Fix command execution using eval for proper string handling
- Install node and bun as required dependencies - Fail test if installation fails instead of skipping - Simplify test to match actual implementation behavior - Add test for npm mode installation - Verify packages can be executed after installation
- mise install requires tool to be in config - mise use adds to config and installs in one step
- Replace manual if/then checks with assert_succeed - Quiet verbose output with redirects - Cleaner, more consistent test structure
jdx
added a commit
that referenced
this pull request
Sep 21, 2025
### 📦 Registry - add missing cargo backends by @jayvdb in [#6307](#6307) ### 🚀 Features - add env propagation by @Its-Just-Nans in [#6342](#6342) ### 🐛 Bug Fixes - **(aqua)** improve GitHub token handling for sigstore verification by @jdx in [#6351](#6351) - **(backend)** change dependency checks to warnings instead of errors by @jdx in [#6363](#6363) - **(npm)** improve error message when npm/bun is not installed by @jdx in [#6359](#6359) - **(vfox)** enable TLS support for reqwest to fix CI tests by @jdx in [#6356](#6356) ### 🚜 Refactor - **(registry)** convert to nested TOML sections format by @jdx in [#6361](#6361) ### 🧪 Testing - **(e2e)** resolve mise via PATH in backend missing deps test by @jdx in [#6362](#6362) - **(vfox)** replace flaky external HTTP tests with local mock server by @jdx in [#6354](#6354) ### 📦️ Dependency Updates - pin dependencies by @renovate[bot] in [#6243](#6243) ### Chore - **(install.sh)** add `MISE_INSTALL_MUSL` to force installing musl variants on Linux by @malept in [#6355](#6355) Co-authored-by: mise-en-dev <release@mise.jdx.dev>
netbsd-srcmastr
pushed a commit
to NetBSD/pkgsrc
that referenced
this pull request
Sep 24, 2025
## [2025.9.16](https://github.com/jdx/mise/compare/v2025.9.15..v2025.9.16) - 2025-09-22 ### 📦 Registry - use npm backend for zbctl by @risu729 in [#6379](jdx/mise#6379) ### 🐛 Bug Fixes - **(aqua)** remove blake3 support from aqua checksum algorithms by @risu729 in [#6370](jdx/mise#6370) - **(aqua)** remove cosign and slsa-verifier dependencies by @risu729 in [#6371](jdx/mise#6371) - **(aqua)** remove cosign.experimental by @risu729 in [#6376](jdx/mise#6376) ### 📚 Documentation - minisign doesn't require cli by @risu729 in [#6369](jdx/mise#6369) ### Chore - ignore renovate new bot name by @risu729 in [#6364](jdx/mise#6364) ## [2025.9.15](https://github.com/jdx/mise/compare/v2025.9.14..v2025.9.15) - 2025-09-21 ### 📦 Registry - add missing cargo backends by @jayvdb in [#6307](jdx/mise#6307) ### 🚀 Features - add env propagation by @Its-Just-Nans in [#6342](jdx/mise#6342) ### 🐛 Bug Fixes - **(aqua)** improve GitHub token handling for sigstore verification by @jdx in [#6351](jdx/mise#6351) - **(backend)** change dependency checks to warnings instead of errors by @jdx in [#6363](jdx/mise#6363) - **(npm)** improve error message when npm/bun is not installed by @jdx in [#6359](jdx/mise#6359) - **(vfox)** enable TLS support for reqwest to fix CI tests by @jdx in [#6356](jdx/mise#6356) ### 🚜 Refactor - **(registry)** convert to nested TOML sections format by @jdx in [#6361](jdx/mise#6361) ### 🧪 Testing - **(e2e)** resolve mise via PATH in backend missing deps test by @jdx in [#6362](jdx/mise#6362) - **(vfox)** replace flaky external HTTP tests with local mock server by @jdx in [#6354](jdx/mise#6354) ### 📦️ Dependency Updates - pin dependencies by @renovate[bot] in [#6243](jdx/mise#6243) ### Chore - **(install.sh)** add `MISE_INSTALL_MUSL` to force installing musl variants on Linux by @malept in [#6355](jdx/mise#6355) ## [2025.9.14](https://github.com/jdx/mise/compare/v2025.9.13..v2025.9.14) - 2025-09-20 ### 🐛 Bug Fixes - fix an issue where Swift could not be installed on arm64 Ubuntu by @lish82 in [#6348](jdx/mise#6348) ### Chore - use cross to build on linux by @jdx in [#6346](jdx/mise#6346) ### New Contributors - @lish82 made their first contribution in [#6348](jdx/mise#6348) ## [2025.9.13](https://github.com/jdx/mise/compare/v2025.9.12..v2025.9.13) - 2025-09-19 ### 📦 Registry - remove deprecated virtualos by @jdx in [166379f](jdx/mise@166379f) - add trufflehog ([aqua:trufflesecurity/trufflehog](https://github.com/trufflesecurity/trufflehog)) by @risu729 in [#6316](jdx/mise#6316) ### 🚀 Features - **(aqua)** integrate native sigstore-verification for security verification by @jdx in [#6332](jdx/mise#6332) - **(docs)** improve search result readability with lighter teal background by @jdx in [#6328](jdx/mise#6328) - **(ui)** update logo as favicon and fix hover transitions by @jdx in [#6325](jdx/mise#6325) - **(vfox)** add file.read lua function by @malept in [#6333](jdx/mise#6333) - add documentation for "Environment in tasks" #5134 #5638 by @Its-Just-Nans in [#6329](jdx/mise#6329) ### 🐛 Bug Fixes - **(github)** correctly paginate releases/tags for private repos by @malept in [#6318](jdx/mise#6318) - **(hk)** exclude aqua-registry from prettier linting by @jdx in [#6327](jdx/mise#6327) - **(ui)** improve GitHub star badge layout and alignment by @jdx in [#6326](jdx/mise#6326) ### 📚 Documentation - change 'hello.py' to 'main.py' in python.md by @my1e5 in [#6319](jdx/mise#6319) - customize VitePress theme with unique branding by @jdx in [#6324](jdx/mise#6324) ### 📦️ Dependency Updates - update taiki-e/install-action digest to 0aa4f22 by @renovate[bot] in [#6334](jdx/mise#6334) - update rust crate comfy-table to v7.2.1 by @renovate[bot] in [#6335](jdx/mise#6335) - update rust crate console to v0.16.1 by @renovate[bot] in [#6336](jdx/mise#6336) - update rust crate indexmap to v2.11.4 by @renovate[bot] in [#6337](jdx/mise#6337) ### Chore - fixing typos by @Its-Just-Nans in [#6331](jdx/mise#6331) ### New Contributors - @Its-Just-Nans made their first contribution in [#6331](jdx/mise#6331) - @my1e5 made their first contribution in [#6319](jdx/mise#6319)
riastradh
pushed a commit
to riastradh/pkgsrc-test20250901
that referenced
this pull request
Feb 8, 2026
## [2025.9.16](https://github.com/jdx/mise/compare/v2025.9.15..v2025.9.16) - 2025-09-22 ### 📦 Registry - use npm backend for zbctl by @risu729 in [#6379](jdx/mise#6379) ### 🐛 Bug Fixes - **(aqua)** remove blake3 support from aqua checksum algorithms by @risu729 in [#6370](jdx/mise#6370) - **(aqua)** remove cosign and slsa-verifier dependencies by @risu729 in [#6371](jdx/mise#6371) - **(aqua)** remove cosign.experimental by @risu729 in [#6376](jdx/mise#6376) ### 📚 Documentation - minisign doesn't require cli by @risu729 in [#6369](jdx/mise#6369) ### Chore - ignore renovate new bot name by @risu729 in [#6364](jdx/mise#6364) ## [2025.9.15](https://github.com/jdx/mise/compare/v2025.9.14..v2025.9.15) - 2025-09-21 ### 📦 Registry - add missing cargo backends by @jayvdb in [#6307](jdx/mise#6307) ### 🚀 Features - add env propagation by @Its-Just-Nans in [#6342](jdx/mise#6342) ### 🐛 Bug Fixes - **(aqua)** improve GitHub token handling for sigstore verification by @jdx in [#6351](jdx/mise#6351) - **(backend)** change dependency checks to warnings instead of errors by @jdx in [#6363](jdx/mise#6363) - **(npm)** improve error message when npm/bun is not installed by @jdx in [#6359](jdx/mise#6359) - **(vfox)** enable TLS support for reqwest to fix CI tests by @jdx in [#6356](jdx/mise#6356) ### 🚜 Refactor - **(registry)** convert to nested TOML sections format by @jdx in [#6361](jdx/mise#6361) ### 🧪 Testing - **(e2e)** resolve mise via PATH in backend missing deps test by @jdx in [#6362](jdx/mise#6362) - **(vfox)** replace flaky external HTTP tests with local mock server by @jdx in [#6354](jdx/mise#6354) ### 📦️ Dependency Updates - pin dependencies by @renovate[bot] in [#6243](jdx/mise#6243) ### Chore - **(install.sh)** add `MISE_INSTALL_MUSL` to force installing musl variants on Linux by @malept in [#6355](jdx/mise#6355) ## [2025.9.14](https://github.com/jdx/mise/compare/v2025.9.13..v2025.9.14) - 2025-09-20 ### 🐛 Bug Fixes - fix an issue where Swift could not be installed on arm64 Ubuntu by @lish82 in [#6348](jdx/mise#6348) ### Chore - use cross to build on linux by @jdx in [#6346](jdx/mise#6346) ### New Contributors - @lish82 made their first contribution in [#6348](jdx/mise#6348) ## [2025.9.13](https://github.com/jdx/mise/compare/v2025.9.12..v2025.9.13) - 2025-09-19 ### 📦 Registry - remove deprecated virtualos by @jdx in [166379f](jdx/mise@166379f) - add trufflehog ([aqua:trufflesecurity/trufflehog](https://github.com/trufflesecurity/trufflehog)) by @risu729 in [#6316](jdx/mise#6316) ### 🚀 Features - **(aqua)** integrate native sigstore-verification for security verification by @jdx in [#6332](jdx/mise#6332) - **(docs)** improve search result readability with lighter teal background by @jdx in [#6328](jdx/mise#6328) - **(ui)** update logo as favicon and fix hover transitions by @jdx in [#6325](jdx/mise#6325) - **(vfox)** add file.read lua function by @malept in [#6333](jdx/mise#6333) - add documentation for "Environment in tasks" #5134 #5638 by @Its-Just-Nans in [#6329](jdx/mise#6329) ### 🐛 Bug Fixes - **(github)** correctly paginate releases/tags for private repos by @malept in [#6318](jdx/mise#6318) - **(hk)** exclude aqua-registry from prettier linting by @jdx in [#6327](jdx/mise#6327) - **(ui)** improve GitHub star badge layout and alignment by @jdx in [#6326](jdx/mise#6326) ### 📚 Documentation - change 'hello.py' to 'main.py' in python.md by @my1e5 in [#6319](jdx/mise#6319) - customize VitePress theme with unique branding by @jdx in [#6324](jdx/mise#6324) ### 📦️ Dependency Updates - update taiki-e/install-action digest to 0aa4f22 by @renovate[bot] in [#6334](jdx/mise#6334) - update rust crate comfy-table to v7.2.1 by @renovate[bot] in [#6335](jdx/mise#6335) - update rust crate console to v0.16.1 by @renovate[bot] in [#6336](jdx/mise#6336) - update rust crate indexmap to v2.11.4 by @renovate[bot] in [#6337](jdx/mise#6337) ### Chore - fixing typos by @Its-Just-Nans in [#6331](jdx/mise#6331) ### New Contributors - @Its-Just-Nans made their first contribution in [#6331](jdx/mise#6331) - @my1e5 made their first contribution in [#6319](jdx/mise#6319)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #6357
🤖 Generated with Claude Code
Co-Authored-By: Claude noreply@anthropic.com