Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions e2e/backend/test_npm_dep_warning_suppressed
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env bash

# Test that "npm may be required" warning is NOT shown when node is configured
# in the same mise.toml alongside an npm package (even if node isn't installed yet).
# Regression test for https://github.com/jdx/mise/discussions/8919

# Create a PATH that has mise but not npm/node
MISE_BIN="$(command -v mise)"
MISE_DIR="$(dirname "$MISE_BIN")"
export PATH="$MISE_DIR:/usr/bin:/bin:/usr/sbin:/sbin"

# Verify npm is not on PATH
if command -v npm >/dev/null 2>&1; then
echo "SKIP: npm is already in PATH, cannot test missing dependency behavior"
exit 0
fi
Comment thread
greptile-apps[bot] marked this conversation as resolved.

# Create a mise.toml that has both node and an npm package
cat >mise.toml <<'EOF'
[tools]
node = "latest"
"npm:prettier" = "3"
EOF

# Run ls-remote for the npm package — should NOT show the warning since node is configured
output=$(MISE_LOG_LEVEL=warn mise ls-remote npm:prettier 2>&1 || true)

if [[ $output == *"npm may be required but was not found"* ]]; then
echo "FAIL: warning was shown even though node is configured in mise.toml"
echo "Output: $output"
exit 1
fi

echo "PASS: no spurious npm warning when node is configured"
8 changes: 8 additions & 0 deletions src/backend/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1365,6 +1365,14 @@ pub trait Backend: Debug + Send + Sync {
};

if !found {
// Check if a tool providing this program is configured in the toolset
// (even if not yet installed). If so, mise will install it as a dependency
// before this tool needs it, so the warning is spurious.
if let Ok(ts) = self.dependency_toolset(config).await {
if !ts.list_current_versions().is_empty() {
return;
}
Comment thread
greptile-apps[bot] marked this conversation as resolved.
Outdated
}

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.

medium

The current implementation suppresses the warning if any dependency of the backend is configured in the toolset. This is too broad and can lead to missing warnings for unrelated dependencies. For example, if a backend depends on both node and git, and only node is configured, a warning about git being missing from the system would be suppressed.

Additionally, dependency_toolset is called here again, even though it was already called inside dependency_which on line 1346. Since dependency_toolset performs version resolution (which can involve network requests), calling it twice is inefficient.

Consider making the check more specific to the program being requested by checking if the toolset contains a tool that matches the program name or is related via registry overrides.

            if let Ok(ts) = self.dependency_toolset(config).await {
                let is_configured = ts.list_current_versions().iter().any(|(b, _)| {
                    b.id() == program || b.tool_name() == program ||
                    REGISTRY.get(program).is_some_and(|rt| {
                        rt.overrides.iter().any(|o| *o == b.id() || *o == b.tool_name())
                    })
                });
                if is_configured {
                    return;
                }
            }

Comment thread
cursor[bot] marked this conversation as resolved.
warn!(
"{} may be required but was not found.\n\n{}",
program, install_instructions
Expand Down
Loading