fix(qmd): run global npm CLIs without relying on PATH
CI / CI configuration security checks (push) Successful in 2s
CI / Capabilities and shell quality (push) Successful in 12s
CI / Python tests and compilation (push) Successful in 25s
CI / QMD unit tests (push) Successful in 5s
CI / Build and inspect generated packages (push) Successful in 15s
CI / PowerShell tests on Ubuntu (push) Successful in 1m5s
CI / Installed client configuration smoke tests (push) Successful in 40s
CI / Bash integration and installation guards (push) Successful in 1m10s

npm's global bin directory is often missing from PATH on Windows, so the
installer failed at `qmd pull` right after installing the package. Run the
QMD CLI through node from `npm root --global`, as the QMD scripts already
do, and look up other globally installed CLIs such as mcporter in
`npm prefix --global` when they are not on PATH. Doctor now warns when
npm's global bin directory is missing from PATH, since agents call
mcporter directly.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Julian LechnerandClaude Opus 5.5 committed 2026-11-05 11:24:10 +01:00
1 parent a89be2604b
commit 6fad45105f
7 files changed
+101 -7

No files matched your search

+25
View File
@@ -336,6 +336,31 @@ class CommandTests(unittest.TestCase):
result = extensions.run_command([str(executable), 'plugin', 'list', '--json'], True, home)
self.assertEqual([str(home / '.codex'), str(home / '.claude')], result.splitlines())
def test_global_npm_cli_is_found_when_its_directory_is_not_on_path(self):
with tempfile.TemporaryDirectory() as temporary:
prefix = Path(temporary)
bin_dir = prefix if os.name == 'nt' else prefix / 'bin'
bin_dir.mkdir(exist_ok=True)
tool = bin_dir / ('mcporter.cmd' if os.name == 'nt' else 'mcporter')
tool.write_text('@echo off\n' if os.name == 'nt' else '#!/bin/sh\n')
tool.chmod(0o700)
real_which = shutil.which
def which(name, mode=os.F_OK | os.X_OK, path=None):
if path is None:
return '/usr/bin/npm' if name == 'npm' else None
return real_which(name, mode, path)
prefix_result = subprocess.CompletedProcess(['npm'], 0, stdout=f'{prefix}\n', stderr='')
with patch.object(extensions.shutil, 'which', side_effect=which), \
patch.object(extensions.subprocess, 'run', return_value=prefix_result):
found = extensions.find_executable('mcporter')
self.assertEqual(Path(found).resolve(), tool.resolve())
def test_missing_cli_stays_missing_without_npm(self):
with patch.object(extensions.shutil, 'which', return_value=None):
self.assertIsNone(extensions.find_executable('mcporter'))
if __name__ == '__main__':
unittest.main()