Skip to content

Fix: detect agents installed via version managers (nvm, mise, etc.)#11

Merged
idoubi merged 1 commit into
fastclaw-ai:mainfrom
xianjianlf2:fix/detect-nvm-path
Mar 25, 2026
Merged

Fix: detect agents installed via version managers (nvm, mise, etc.)#11
idoubi merged 1 commit into
fastclaw-ai:mainfrom
xianjianlf2:fix/detect-nvm-path

Conversation

@xianjianlf2

@xianjianlf2 xianjianlf2 commented Mar 23, 2026

Copy link
Copy Markdown
Contributor

Closes #12

Problem

Daemon processes don't source shell profiles (.zshrc/.bashrc), so exec.LookPath fails for binaries installed via version managers like nvm, mise, etc. This causes DetectAndConfigure to miss claude even when it's installed — on a fresh/empty config, the agent is never detected.

Root Cause

exec.LookPath only searches the current process's PATH. When weclaw runs as a daemon (Setsid: true), the PATH doesn't include nvm's bin directory (e.g. ~/.nvm/versions/node/v24.11.1/bin/), because those paths are added in .zshrc which is only sourced for interactive shells.

Solution

Add a lookPath() helper that falls back to resolving via a login interactive shell (zsh -lic which <binary>) when the standard exec.LookPath fails. The -li flags ensure .zshrc/.bashrc are sourced, picking up version manager paths.

Test Plan

Added config/detect_test.go with 4 test cases:

  • TestLookPath_InPath — finds standard binaries already in PATH
  • TestLookPath_NotExist — returns error for missing binaries
  • TestLookPath_LoginShellFallback — reproduces daemon scenario: strips PATH to system-only dirs, verifies exec.LookPath fails but lookPath succeeds via login shell
  • TestDetectAndConfigure_StrippedPath — end-to-end: empty config + stripped PATH → claude detected as CLI agent

Daemon processes don't source shell profiles (.zshrc/.bashrc), so
exec.LookPath fails for binaries installed via nvm, mise, etc.

Add lookPath() that falls back to a login interactive shell
(zsh -lic which) when the standard PATH lookup fails.
@idoubi
idoubi merged commit b7a2a64 into fastclaw-ai:main Mar 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Agent detection fails for binaries installed via nvm/mise

2 participants