( specificVersion?: string | null, )
| 454 | } |
| 455 | |
| 456 | export async function installGlobalPackage( |
| 457 | specificVersion?: string | null, |
| 458 | ): Promise<InstallStatus> { |
| 459 | if (!(await acquireLock())) { |
| 460 | logError( |
| 461 | new AutoUpdaterError('Another process is currently installing an update'), |
| 462 | ) |
| 463 | // Log the lock contention |
| 464 | logEvent('tengu_auto_updater_lock_contention', { |
| 465 | pid: process.pid, |
| 466 | currentVersion: |
| 467 | MACRO.VERSION as AnalyticsMetadata_I_VERIFIED_THIS_IS_NOT_CODE_OR_FILEPATHS, |
| 468 | }) |
| 469 | return 'in_progress' |
| 470 | } |
| 471 | |
| 472 | try { |
| 473 | await removeClaudeAliasesFromShellConfigs() |
| 474 | // Check if we're using npm from Windows path in WSL |
| 475 | if (!env.isRunningWithBun() && env.isNpmFromWindowsPath()) { |
| 476 | logError(new Error('Windows NPM detected in WSL environment')) |
| 477 | logEvent('tengu_auto_updater_windows_npm_in_wsl', { |
| 478 | currentVersion: |
| 479 | MACRO.VERSION as AnalyticsMetadata_I_VERIFIED_THIS_IS_NOT_CODE_OR_FILEPATHS, |
| 480 | }) |
| 481 | // biome-ignore lint/suspicious/noConsole:: intentional console output |
| 482 | console.error(` |
| 483 | Error: Windows NPM detected in WSL |
| 484 | |
| 485 | You're running Claude Code in WSL but using the Windows NPM installation from /mnt/c/. |
| 486 | This configuration is not supported for updates. |
| 487 | |
| 488 | To fix this issue: |
| 489 | 1. Install Node.js within your Linux distribution: e.g. sudo apt install nodejs npm |
| 490 | 2. Make sure Linux NPM is in your PATH before the Windows version |
| 491 | 3. Try updating again with 'claude update' |
| 492 | `) |
| 493 | return 'install_failed' |
| 494 | } |
| 495 | |
| 496 | const { hasPermissions } = await checkGlobalInstallPermissions() |
| 497 | if (!hasPermissions) { |
| 498 | return 'no_permissions' |
| 499 | } |
| 500 | |
| 501 | // Use specific version if provided, otherwise use latest |
| 502 | const packageSpec = specificVersion |
| 503 | ? `${MACRO.PACKAGE_URL}@${specificVersion}` |
| 504 | : MACRO.PACKAGE_URL |
| 505 | |
| 506 | // Run from home directory to avoid reading project-level .npmrc/.bunfig.toml |
| 507 | // which could be maliciously crafted to redirect to an attacker's registry |
| 508 | const packageManager = env.isRunningWithBun() ? 'bun' : 'npm' |
| 509 | const installResult = await execFileNoThrowWithCwd( |
| 510 | packageManager, |
| 511 | ['install', '-g', packageSpec], |
| 512 | { cwd: homedir() }, |
| 513 | ) |
no test coverage detected