Skip to content

fix(hooks): skip hook injection when /bin/sh is absent - #274

Merged
jeff-r2026 merged 1 commit into
Tencent:mainfrom
m0Nst3r873:fix/codebuddy-hook-enoent
Aug 3, 2026
Merged

fix(hooks): skip hook injection when /bin/sh is absent#274
jeff-r2026 merged 1 commit into
Tencent:mainfrom
m0Nst3r873:fix/codebuddy-hook-enoent

Conversation

@m0Nst3r873

Copy link
Copy Markdown
Collaborator

Summary

  • In remote container environments (e.g. CloudStudio AI inference nodes), /bin/sh may not exist
  • CodeBuddy executes hooks via spawn('/bin/sh', ...), so every hook invocation fails with ENOENT (error 1001), blocking all user input
  • Detect /bin/sh availability at install time and skip hook injection for shell-dependent tools (CodeBuddy/WorkBuddy) when absent, with a clear warning
  • Other tools (Claude Code, Cursor) are unaffected

Changes

  • src/builtin-hooks.ts: Add hasShell() detection (cached), SHELL_DEPENDENT_TOOLS shared constant, ensureWrapperIfShellAvailable() helper, _resetShellCache() for tests
  • src/hooks.ts: injectHooksToAllTools and reconcileHooksToAllTools skip shell-dependent tools when /bin/sh is absent and warn the user
  • src/__tests__/hooks-shell-check.test.ts: 6 tests covering hasShell() caching and no-shell skip behavior

Test plan

  • npx tsc --noEmit — type check passes
  • npx vitest run — 1891 tests pass (144 files), including golden tests
  • npm run build — build succeeds
  • Deploy to a remote container without /bin/sh, run teamai init or teamai pull, verify warning is printed and CodeBuddy settings.json has no hook entries
  • On normal environment (with /bin/sh), verify hooks are injected normally (no behavioral change)

🤖 Generated with Claude Code

In remote container environments (e.g. CloudStudio AI inference nodes),
/bin/sh may not exist. CodeBuddy executes hooks via spawn('/bin/sh'),
so every hook invocation fails with ENOENT (error 1001), blocking all
user input.

Detect /bin/sh availability at install time and skip hook injection for
shell-dependent tools (CodeBuddy/WorkBuddy) when absent, with a clear
warning. Other tools (Claude Code, Cursor) are unaffected.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@jeff-r2026
jeff-r2026 merged commit 507e5b1 into Tencent:main Aug 3, 2026
7 checks passed
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.

2 participants