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
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:
1 parent
a89be2604b
commit
6fad45105f
7 files changed
+101
-7
No files matched your search
@@ -55,8 +55,27 @@ def atomic_write(path, data):
|
||||
temporary.unlink(missing_ok=True)
|
||||
|
||||
|
||||
def find_executable(name):
|
||||
found = shutil.which(name)
|
||||
if found or name == 'npm':
|
||||
return found
|
||||
# npm's global bin directory is often missing from PATH right after a Node.js setup on Windows,
|
||||
# so a CLI this setup just installed globally (such as mcporter) would not be found otherwise.
|
||||
npm = shutil.which('npm')
|
||||
if npm is None:
|
||||
return None
|
||||
try:
|
||||
prefix = subprocess.run([npm, 'prefix', '--global'], stdin=subprocess.DEVNULL, capture_output=True,
|
||||
text=True, timeout=60).stdout.strip()
|
||||
except (OSError, subprocess.SubprocessError):
|
||||
return None
|
||||
if not prefix:
|
||||
return None
|
||||
return shutil.which(name, path=prefix if os.name == 'nt' else os.path.join(prefix, 'bin'))
|
||||
|
||||
|
||||
def run_command(arguments, summary=False, home=None):
|
||||
executable = shutil.which(arguments[0])
|
||||
executable = find_executable(arguments[0])
|
||||
if executable is None:
|
||||
raise ValueError(f'{arguments[0]} CLI is required to manage plugins.')
|
||||
environment = os.environ.copy()
|
||||
|
||||
Reference in new issue
Block a user