nexus/server/src
Octasoft Ltd f843a45a84
fix: use sh instead of /bin/sh as shell fallback on Windows (#891)
## Thinking Path

> - Paperclip orchestrates AI agents for zero-human companies
> - Agents run shell commands during workspace provisioning (git
worktree creation, runtime services)
> - When `process.env.SHELL` is unset, the code falls back to `/bin/sh`
> - But on Windows with Git Bash, `/bin/sh` doesn't exist as an absolute
path — Git Bash provides `sh` on PATH instead
> - This causes `child_process.spawn` to throw `ENOENT`, crashing
workspace provisioning on Windows
> - This PR extracts a `resolveShell()` helper that uses `$SHELL` when
set, falls back to `sh` (bare) on Windows or `/bin/sh` on Unix
> - The benefit is that agents running on Windows via Git Bash can
provision workspaces without shell resolution errors
## Summary
- `workspace-runtime.ts` falls back to `/bin/sh` when
`process.env.SHELL` is unset
- On Windows, `/bin/sh` doesn't exist → `spawn /bin/sh ENOENT`
- Fix: extract `resolveShell()` helper that uses `$SHELL` when set,
falls back to `sh` on Windows (Git Bash PATH lookup) or `/bin/sh` on
Unix

Three call sites updated to use the new helper.

Fixes #892

## Root cause

When Paperclip spawns shell commands in workspace operations (e.g., git
worktree creation), it uses `process.env.SHELL` if set, otherwise
defaults to `/bin/sh`. On Windows with Git Bash, `$SHELL` is typically
unset and `/bin/sh` is not a valid path — Git Bash provides `sh` on PATH
but not at the absolute `/bin/sh` location. This causes
`child_process.spawn` to throw `ENOENT`.

## Approach

Rather than hard-coding a Windows-specific absolute path (e.g.,
`C:\Program Files\Git\bin\sh.exe`), we use the bare `"sh"` command which
relies on PATH resolution. This works because:
1. Git Bash adds its `usr/bin` directory to PATH, making `sh` resolvable
2. On Unix/macOS, `/bin/sh` remains the correct default (it's the POSIX
standard location)
3. `process.env.SHELL` takes priority when set, so this only affects the
fallback

## Test plan

- [x] 7 unit tests for `resolveShell()`: SHELL set, trimmed, empty,
whitespace-only, linux/darwin/win32 fallbacks
- [x] Run a workspace provision command on Windows with `git_worktree`
strategy
- [x] Verify Unix/macOS is unaffected

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-authored-by: Paperclip <noreply@paperclip.ing>
Co-authored-by: Devin Foley <devin@devinfoley.com>
2026-04-02 17:34:26 -07:00
..
__tests__ fix: use sh instead of /bin/sh as shell fallback on Windows (#891) 2026-04-02 17:34:26 -07:00
adapters Merge branch 'master' into add-gpt-5-4-xhigh-effort 2026-03-31 06:19:26 -05:00
auth fix: disable secure cookies for HTTP deployments 2026-03-08 22:00:51 -05:00
middleware fix: align telemetry client payload and dimensions with backend schema 2026-04-02 10:47:29 -05:00
onboarding-assets Preserve workspaces for follow-up issues 2026-03-30 14:10:36 -05:00
realtime update typing to node v24 from v20 2026-03-05 14:36:00 -03:00
routes fix(inbox): address Greptile review findings 2026-04-02 12:16:34 -05:00
secrets refactor: rename packages to @paperclipai and CLI binary to paperclipai 2026-03-03 08:45:26 -06:00
services fix: use sh instead of /bin/sh as shell fallback on Windows (#891) 2026-04-02 17:34:26 -07:00
storage refactor: rename packages to @paperclipai and CLI binary to paperclipai 2026-03-03 08:45:26 -06:00
types Add browser-based board CLI auth flow 2026-03-23 08:46:05 -05:00
agent-auth-jwt.ts Implement local agent JWT authentication for adapters 2026-02-18 16:46:45 -06:00
app.ts Add feedback voting and thumbs capture flow 2026-04-02 09:11:49 -05:00
attachment-types.ts feat(issues): add issue documents and inline editing 2026-03-13 21:30:48 -05:00
board-claim.ts refactor: rename packages to @paperclipai and CLI binary to paperclipai 2026-03-03 08:45:26 -06:00
config-file.ts refactor: rename packages to @paperclipai and CLI binary to paperclipai 2026-03-03 08:45:26 -06:00
config.ts feat: implement app-side telemetry sender 2026-04-02 10:47:29 -05:00
dev-server-status.ts Add guarded dev restart handling 2026-03-20 08:50:00 -05:00
dev-watch-ignore.ts Harden dev-watch excludes for nested UI outputs 2026-03-26 12:35:19 -05:00
errors.ts Add server routes for companies, approvals, costs, and dashboard 2026-02-17 09:07:27 -06:00
home-paths.ts Redesign project codebase configuration 2026-03-16 15:56:37 -05:00
index.ts fix: add periodic flush and graceful shutdown for server-side telemetry 2026-04-02 10:47:29 -05:00
log-redaction.ts Add username log censor setting 2026-03-20 08:50:00 -05:00
paths.ts feat(cli): add client commands and home-based local runtime defaults 2026-02-20 07:10:58 -06:00
redaction.ts Implement secrets service with local encryption, redaction, and runtime resolution 2026-02-19 15:43:52 -06:00
startup-banner.ts Add configurable automatic database backup scheduling 2026-03-04 18:03:23 -06:00
telemetry.ts fix: add periodic flush and graceful shutdown for server-side telemetry 2026-04-02 10:47:29 -05:00
ui-branding.ts Add worktree UI branding 2026-03-13 11:12:43 -05:00
version.ts add app version label 2026-03-17 09:40:07 +05:30
worktree-config.ts Avoid sibling worktree port collisions 2026-03-26 11:12:39 -05:00