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

+21 -2
View File
@@ -34,7 +34,7 @@ class FakeRunner:
return self.node
if arguments[-1:] == ['set-models']:
return json.dumps({'previous': self.previous}) + chr(10)
if self.fail_pull and arguments[:2] == ['qmd', 'pull']:
if self.fail_pull and arguments[0] == 'node' and arguments[-1:] == ['pull']:
raise ValueError('pull failed')
if 'npm list' in joined and self.list_output is not None:
return self.list_output
@@ -115,7 +115,8 @@ class SetupTest(unittest.TestCase):
(self.home / '.my-ai-configuration/qmd/collections.json').write_text(json.dumps(['repo-abcdefabcdef']))
setup.disable(['claude'])
self.assertFalse(model.exists())
self.assertIn(['qmd', 'collection', 'remove', 'repo-abcdefabcdef'], runner.calls)
self.assertTrue(any(call[0] == 'node' and call[1].endswith('qmd.js') and call[2:] == ['collection', 'remove', 'repo-abcdefabcdef']
for call in runner.calls), runner.calls)
self.assertIn(['npm', 'uninstall', '--global', '@tobilu/qmd'], runner.calls)
def test_benchmark_unsuitable_cleans_up(self):
@@ -220,6 +221,24 @@ class SetupTest(unittest.TestCase):
self.assertTrue(self.setup(FakeRunner(list_output='{"dependencies": {"@tobilu/qmd": {}}, "error": {}}')).package_installed())
self.assertFalse(self.setup(FakeRunner(list_output='{"dependencies": {}}')).package_installed())
def test_qmd_cli_runs_through_node_without_relying_on_path(self):
# npm's global bin directory is often missing from PATH on Windows right after install.
runner = FakeRunner()
runner_root = str(self.home / 'npm-root')
original = runner.__call__
def call(arguments, env=None, timeout=None, check=True):
if arguments == ['npm', 'root', '--global']:
runner.calls.append(list(arguments))
return runner_root + '\n'
return original(arguments, env=env, timeout=timeout, check=check)
setup = self.setup(call)
setup.qmd_cli('pull')
expected = str(Path(runner_root) / '@tobilu' / 'qmd' / 'dist' / 'cli' / 'qmd.js')
self.assertIn(['node', expected, 'pull'], runner.calls)
self.assertFalse(any(call[0] == 'qmd' for call in runner.calls))
def test_package_installed_treats_missing_global_prefix_as_not_installed(self):
# npm reports ENOENT for the global prefix before anything was ever installed globally.
output = '{"error": {"code": "ENOENT", "summary": "ENOENT: no such file or directory, lstat \'C:\\\\Users\\\\me\\\\AppData\\\\Roaming\\\\npm\'"}}'