preview_start (Claude_Preview MCP) fails with sandbox getcwd error on Rails dev server
Open 💬 0 comments Opened Jul 8, 2026 by fercreek
Bug
preview_start (Claude_Preview MCP tool) fails with a sandbox error when launching a local Rails dev server, regardless of whether the target port is free or in use.
Error
shell-init: error retrieving current directory: getcwd: cannot access parent directories: Operation not permitted
shell-init: error retrieving current directory: getcwd: cannot access parent directories: Operation not permitted
job-working-directory: error retrieving current directory: getcwd: cannot access parent directories: Operation not permitted
/opt/homebrew/Cellar/rbenv/1.3.2/libexec/rbenv-version-file-read: line 11: <repo>/.ruby-version: Operation not permitted
ruby: Operation not permitted -- bin/rails (LoadError)
Repro
.claude/launch.json:
{
"version": "0.0.1",
"configurations": [
{
"name": "studio-link",
"runtimeExecutable": "/Users/fernandocastaneda/.rbenv/shims/ruby",
"runtimeArgs": ["/Users/fernandocastaneda/Documents/studio-link/bin/rails", "server", "-p", "3010"],
"port": 3010,
"cwd": "/Users/fernandocastaneda/Documents/studio-link",
"env": {
"SKIP_TAILWIND_PLUGIN": "1",
"RAILS_ENV": "development"
}
}
]
}
- Call
preview_startwithname: "studio-link". - Fails every time with the getcwd sandbox error above — even with the target port confirmed free beforehand.
Workaround
Running the exact same command via the Bash tool with dangerouslyDisableSandbox: true works without any issue:
SKIP_TAILWIND_PLUGIN=1 RAILS_ENV=development bin/rails server -p 3010
This strongly suggests the Claude_Preview MCP server spawns its child process under a stricter/different sandbox profile than the Bash tool, and that profile doesn't grant read access to the parent directories needed for getcwd() to resolve — even though the same cwd works fine for Bash.
Environment
- macOS (Darwin 24.1.0)
- Shell: zsh
- Ruby via rbenv (
rbenv-version-file-readalso fails with the same "Operation not permitted")