Sandbox blocks tmux (psmux) when cwd is home directory on Windows
Bug Description
When Claude Code is launched from the user's home directory (C:\Users\<user>), the sandbox command resolver dA6 blocks tmux (psmux) execution, causing team agent spawn to fail with:
[TmuxBackend] Failed to get current window target (exit 127): Command 'tmux' not found or is in an unsafe location (current directory)
Root Cause
The dA6 function uses where.exe to resolve command paths, then filters out any executable whose resolved path starts with cwd + path.sep:
function dA6(H) {
// ...
for (let A of results) {
let z = path.resolve(A).toLowerCase();
if (path.dirname(z).toLowerCase() === f || z.startsWith(f + path.sep)) continue;
return A;
}
return null; // all results filtered → command "not found"
}
When cwd = C:\Users\my:
tmux.exeis atC:\Users\my\AppData\Local\Microsoft\WinGet\Packages\marlocarlo.psmux_...\tmux.exez.startsWith("c:\users\my\\")→true→ filtered as "unsafe"- Function returns
null→ exit code 127
When cwd = C:\Users\my\workspace:
- Same tmux.exe path does NOT start with
c:\users\my\workspace\ - Function returns the path → works correctly
Impact
- Team agent spawning completely broken when Claude Code is launched from home directory
teammateMode: "auto"(tmux/pane mode) fails; onlyin-processmode works as workaround- Affects any WinGet-installed tool (not just psmux) since WinGet installs to
AppData\Local\Microsoft\WinGet\Packages\
Expected Behavior
AppData\Local is a standard system-managed installation directory and should not be treated as "current directory" / "unsafe location". The safety check should only block executables in the exact cwd, not in deeply nested subdirectories under the user's home.
Suggested Fix
Exclude well-known system paths from the cwd filter:
const systemDirs = ['appdata', 'program files', 'program files (x86)', '.local'];
const isSystemPath = systemDirs.some(d => z.includes(path.sep + d + path.sep));
if (!isSystemPath && (path.dirname(z) === f || z.startsWith(f + path.sep))) continue;
Or more simply, only filter when the executable is in the exact cwd directory (not subdirectories):
if (path.dirname(z).toLowerCase() === f) continue; // remove the startsWith check
Environment
- Claude Code: 2.1.92
- OS: Windows 11 Pro (10.0.26200)
- psmux: 3.3.1 (installed via WinGet)
- tmux.exe location:
C:\Users\my\AppData\Local\Microsoft\WinGet\Packages\marlocarlo.psmux_Microsoft.Winget.Source_8wekyb3d8bbwe\tmux.exe
Steps to Reproduce
- Install psmux via WinGet (
winget install marlocarlo.psmux) - Start psmux session
- Launch Claude Code from home directory:
cd ~; claude - Create a team:
TeamCreate - Spawn a teammate with
team_nameparameter - Observe: "Could not determine current tmux pane/window"
- Repeat from a subdirectory (e.g.,
cd ~/workspace; claude) → works
Debug Log
[BackendRegistry] Selected: tmux (running inside tmux session)
[TmuxBackend] Failed to get current window target (exit 127): Command 'tmux' not found or is in an unsafe location (current directory)
Agent tool error (96ms): Could not determine current tmux pane/windowThis issue has 3 comments on GitHub. Read the full discussion on GitHub ↗