{"record":{"id":"505fe27d12d6d106","repo":"larksuite/cli","slug":"pnpm-not-found-in-path-w","errorCode":null,"errorMessage":"pnpm not found in PATH: %w","messagePattern":"pnpm not found in PATH: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/selfupdate/updater.go","lineNumber":266,"sourceCode":"\tcmd := exec.CommandContext(ctx, npmPath, \"install\", \"-g\", NpmPackage+\"@\"+version)\n\tcmd.Stdout = &r.Stdout\n\tcmd.Stderr = &r.Stderr\n\tr.Err = cmd.Run()\n\tif ctx.Err() == context.DeadlineExceeded {\n\t\tr.Err = fmt.Errorf(\"npm install timed out after %s\", npmInstallTimeout)\n\t}\n\treturn r\n}\n\n// RunPnpmInstall executes pnpm add -g @larksuite/cli@<version>.\nfunc (u *Updater) RunPnpmInstall(version string) *NpmResult {\n\tif u.PnpmInstallOverride != nil {\n\t\treturn u.PnpmInstallOverride(version)\n\t}\n\tr := &NpmResult{}\n\tpnpmPath, err := exec.LookPath(\"pnpm\")\n\tif err != nil {\n\t\tr.Err = fmt.Errorf(\"pnpm not found in PATH: %w\", err)\n\t\treturn r\n\t}\n\tctx, cancel := context.WithTimeout(context.Background(), npmInstallTimeout)\n\tdefer cancel()\n\tcmd := exec.CommandContext(ctx, pnpmPath, \"add\", \"-g\", NpmPackage+\"@\"+version)\n\tcmd.Stdout = &r.Stdout\n\tcmd.Stderr = &r.Stderr\n\tr.Err = cmd.Run()\n\tif ctx.Err() == context.DeadlineExceeded {\n\t\tr.Err = fmt.Errorf(\"pnpm install timed out after %s\", npmInstallTimeout)\n\t}\n\treturn r\n}\n\nfunc (u *Updater) FetchSkillsIndex(source string) *NpmResult {\n\tif u.SkillsIndexFetchOverride != nil {\n\t\treturn u.SkillsIndexFetchOverride()\n\t}","sourceCodeStart":248,"sourceCodeEnd":284,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/internal/selfupdate/updater.go#L248-L284","documentation":"RunPnpmInstall first resolves `pnpm` via exec.LookPath before running `pnpm add -g`. If pnpm is not on PATH, the returned NpmResult.Err wraps the LookPath error with this message, so the pnpm-based update path cannot proceed.","triggerScenarios":"Calling Updater.RunPnpmInstall(version) (directly or via the pnpm install-method detection) when pnpm is not installed or is not in the process's PATH environment variable.","commonSituations":"pnpm never installed on the machine; pnpm installed via a version manager (corepack, volta, asdf) whose shims are not on the PATH of the process invoking the CLI; PATH differs under cron/CI/systemd; user switched from npm to pnpm or vice versa after install.","solutions":["Install pnpm (`npm install -g pnpm` or `corepack enable pnpm`) and retry the update","Verify with `which pnpm` / `where pnpm` that pnpm resolves in the same shell/environment running the CLI","Add the pnpm install bin directory (e.g. corepack/volta shims) to PATH for the environment invoking lark-cli","Fall back to the npm update path (`npm install -g @larksuite/cli@latest`) or run the CLI's built-in update with npm"],"exampleFix":"// before\nres := updater.RunPnpmInstall(\"1.2.3\")\nif res.Err != nil { log.Fatal(res.Err) }\n// after\nif _, err := exec.LookPath(\"pnpm\"); err != nil {\n\tlog.Print(\"pnpm unavailable; falling back to npm\")\n\tres := updater.RunNpmInstall(\"1.2.3\")\n\tif res.Err != nil { log.Fatal(res.Err) }\n} else {\n\tres := updater.RunPnpmInstall(\"1.2.3\")\n\tif res.Err != nil { log.Fatal(res.Err) }\n}","handlingStrategy":"validation","validationCode":"if _, err := exec.LookPath(\"pnpm\"); err != nil {\n\t// pnpm missing: choose npm path or install pnpm before calling RunPnpmInstall\n}","typeGuard":"func pnpmAvailable() bool { _, err := exec.LookPath(\"pnpm\"); return err == nil }","tryCatchPattern":null,"preventionTips":["Install pnpm and confirm `pnpm --version` works in the shell that launches lark-cli","Add version-manager shim dirs (corepack/volta) to PATH in non-interactive environments","Check PATH inside cron/CI jobs, which often differ from your login shell","Keep the CLI's detected install method consistent with the manager actually installed"],"tags":["pnpm","path","selfupdate","environment"],"backgroundTag":"executable-not-found-in-path","analyzedSha":"7fd6ef3c07182257ce776cdc5a614e122d5bd4b3","analyzedAt":"2026-09-04T21:17:44.649Z","contentChangedAt":"2026-09-04T21:17:44.649Z","schemaVersion":2},"datasetVersion":"2026-09-12T02:17:10.037Z"}