preview_start fails when project path contains a space (macOS)

Open 💬 0 comments Opened Jul 6, 2026 by bries-judy

preview_start (Claude Preview MCP server) fails to spawn its dev-server when the project's absolute path contains a space character. The failure happens at bash's shell-init phase — before any -c argument is executed — indicating the cwd is passed to spawn(bash, …) without proper shell-quoting or with a whitespace-truncation somewhere in the pipeline.

Reproduction

  1. Project at a path with a space, e.g. /Users/name/Documents/Claude/Projects/Olita AI/code/olita-ai.
  2. .claude/launch.json:

``json
{
"version": "0.0.1",
"configurations": [
{
"name": "olita-ai",
"runtimeExecutable": "npm",
"runtimeArgs": ["run", "dev"],
"port": 3001,
"autoPort": true
}
]
}
``

  1. Call preview_start with name: "olita-ai".

Actual output

Failed to start preview server:
shell-init: error retrieving current directory: getcwd: cannot access parent directories: Operation not permitted
chdir: error retrieving current directory: getcwd: cannot access parent directories: Operation not permitted
/bin/bash: line 0: cd: /Users/name/Documents/Claude/Projects/Olita/code/olita-ai: No such file or directory

Notice the third line: bash is trying to cd to .../Olita/code/olita-ai — the space in Olita AI has been silently truncated, so bash lands on a non-existent path. The Operation not permitted on getcwd() is a downstream effect of bash being spawned with an invalid cwd, not a TCC/permission issue.

What did not fix it

  • Full Disk Access for the Claude Code app in System Settings → Privacy & Security. Same error.
  • Symlink workaroundln -s "/Users/name/Documents/Claude/Projects/Olita AI" ~/olita-projects and updating runtimeArgs to ["-c", "cd /Users/name/olita-projects/code/olita-ai && exec npm run dev"]. Same error, because the shell-init failure precedes the -c argument.
  • bash -c "cd <quoted-path> && …" in runtimeArgs. Same reason — bash fails at init before evaluating -c.

Because the error surface is pre-shell-init, no configuration in .claude/launch.json can rescue it. The bug must be in how the MCP-preview server derives and passes cwd to Node's spawn().

Suspected root cause

Somewhere in the MCP-preview server, the project's absolute path (from session state) is being tokenised on whitespace (perhaps path.split(' ')[0], an unquoted shell interpolation, or child_process.exec used where spawn would be safer). The truncated path becomes the cwd argument to spawn(bash, …), and bash's shell-init fails with the observed error.

Impact

Any user whose project sits under a path with a space — a common pattern on macOS where ~/Documents/… or ~/Desktop/… regularly contain vendor/product names with spaces — cannot use preview_start, preview_screenshot, preview_snapshot, preview_inspect, preview_click, preview_fill, or preview_eval. Development still works via Bash run_in_background + curl as a fallback, but the entire visual/interactive verification loop is offline.

Environment

  • macOS 26.4.1 (Sequoia)
  • Node v25.9.0
  • gh 2.89.0 (for context, unrelated)
  • Claude Code — latest as of 2026-07-05

Happy to help test a fix against this project once a candidate lands. Thanks!

View original on GitHub ↗