larksuite/cli · error

%s not found in PATH: %w

Error message

%s not found in PATH: %w

What it means

runSkillsCommandInDir resolves the launcher binary (chosen by DetectInstallMethod and skillsInvocation — npm or pnpm variants) with exec.LookPath before spawning the skills command. If the launcher is missing from PATH, it returns this error wrapping the LookPath failure.

Source

Thrown at internal/selfupdate/updater.go:410

}

func (u *Updater) runSkillsCommand(args ...string) *NpmResult {
	return u.runSkillsCommandInDir("", args...)
}

func (u *Updater) runSkillsCommandInDir(dir string, args ...string) *NpmResult {
	if u.SkillsCommandInDirOverride != nil {
		return u.SkillsCommandInDirOverride(dir, args...)
	}
	if u.SkillsCommandOverride != nil {
		return u.SkillsCommandOverride(args...)
	}
	r := &NpmResult{}
	det := u.DetectInstallMethod()
	launcher, cmdArgs := skillsInvocation(det.Method, det.PnpmAvailable, args)
	binPath, err := exec.LookPath(launcher)
	if err != nil {
		r.Err = fmt.Errorf("%s not found in PATH: %w", launcher, err)
		return r
	}
	ctx, cancel := context.WithTimeout(context.Background(), skillsUpdateTimeout)
	defer cancel()
	cmd := exec.CommandContext(ctx, binPath, cmdArgs...)
	cmd.Dir = dir
	cmd.Stdout = &r.Stdout
	cmd.Stderr = &r.Stderr
	r.Err = cmd.Run()
	if ctx.Err() == context.DeadlineExceeded {
		r.Err = fmt.Errorf("skills update timed out after %s", skillsUpdateTimeout)
	}
	return r
}

// VerifyBinary checks that the installed binary reports the expected version
// by running "lark-cli --version" and comparing the version token exactly.
// Output format is "lark-cli version X.Y.Z"; the last field is extracted and

View on GitHub (pinned to 7fd6ef3c07)

Solutions

  1. Ensure the detected launcher (`npm` or `pnpm`) is installed and on PATH of the environment running lark-cli
  2. Run `which npm pnpm` in the same environment (shell/CI job) to confirm resolution
  3. Fix PATH for non-interactive environments (cron/CI) to include the node/package-manager bin directories
  4. Reinstall the CLI with the package manager you actually use so DetectInstallMethod matches reality

Example fix

// before (cron job with minimal PATH)
0 3 * * * /usr/local/bin/lark-cli skills update
// after
0 3 * * * PATH=/usr/local/bin:/usr/bin:/home/me/.local/share/pnpm:$PATH /usr/local/bin/lark-cli skills update
Defensive patterns

Strategy: validation

Validate before calling

method := "npm" // or from DetectInstallMethod
if _, err := exec.LookPath(method); err != nil { /* install the launcher or fix PATH before skills commands */ }

Type guard

func launcherAvailable(name string) bool { _, err := exec.LookPath(name); return err == nil }

Try / catch

res := stageResult // NpmResult from StageSuite/runSkillsCommand
if res.Err != nil {
	if strings.Contains(res.Err.Error(), "not found in PATH") {
		// install missing npm/pnpm or export correct PATH, then retry
	} else {
		return res.Err
	}
}

Prevention

When it happens

Trigger: Calling code paths StageSuite or runSkillsCommand that reach runSkillsCommandInDir when the detected launcher (npm or pnpm) cannot be found via exec.LookPath in the current process environment.

Common situations: Package manager removed or installed via a version manager whose shims are absent from PATH; running the CLI under cron/CI/systemd with a minimal PATH; method detection said pnpm was available at startup but it disappeared or vice versa.

Related errors


AI-assisted analysis of larksuite/cli@7fd6ef3c07 (2026-09-04). Data as JSON: /api/errors/fbe3704750a1009e. Report an issue: GitHub.