Skip to content

preview_start fails with EPERM: uv_cwd on macOS #34032

Description

@sobradob

Bug Description

preview_start consistently fails with EPERM: operation not permitted, uv_cwd when attempting to start a dev server. The subprocess spawned by the preview tool cannot resolve its working directory, even though the CWD is valid and accessible from the shell.

Environment

  • OS: macOS (Darwin 25.2.0)
  • Node.js: v22.17.0 (via nvm)
  • Claude Code: latest (CLI)
  • Shell: zsh

Steps to Reproduce

  1. Navigate to a Next.js project directory
  2. Ensure .claude/launch.json exists with a valid config:
    {
      "version": "0.0.1",
      "configurations": [
        {
          "name": "dev",
          "runtimeExecutable": "npx",
          "runtimeArgs": ["next", "dev"],
          "port": 3000,
          "autoPort": true
        }
      ]
    }
  3. Use preview_start with name: "dev"

Expected Behavior

The dev server starts and preview tools become available.

Actual Behavior

The subprocess immediately crashes with:

Error: EPERM: operation not permitted, uv_cwd
    at process.wrappedCwd [as cwd] (node:internal/bootstrap/switches/does_own_process_state:142:28)
    ...

Troubleshooting Done

  • Verified CWD exists and is accessible (pwd, ls -la both work)
  • Verified npx is available and functional (which npx, npx --version)
  • Tried using node_modules/.bin/next directly instead of npx — same error
  • The error occurs before any project code runs — Node.js itself cannot call process.cwd() in the spawned subprocess
  • Running npx next dev directly from the same shell works fine

Analysis

The issue appears to be in how the preview infrastructure spawns child processes. The subprocess inherits a CWD context that is stale or has restricted permissions, even though the parent process's CWD is valid. This is a process-management issue in the preview tool, not a project configuration problem.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:sandboxbugSomething isn't workingduplicateThis issue or pull request already existsplatform:macosIssue specifically occurs on macOS

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions