Skip to content

Permission denied error on worktree index.lock when committing from VS Code (Electron sandbox issue with git) #1301

@cedricvidal

Description

@cedricvidal

Describe the bug

In a VS Code window opened on a Git worktree, I'm getting a permissions error when trying to commit staged changes. The error message is:

[0204/181621.495272:ERROR:electron/shell/app/node_main.cc:146] Node.js environment variables are disabled because this process is invoked by other apps.
fatal: Unable to create '/Users/cv/Documents/Projects/GEO-Skunkworks/geo-experiments-new/.git/worktrees/exp-azure-hosted-agent-claude-code/index.lock': Operation not permitted

This prevents committing from that window. The files are already staged, and committing from the terminal outside VS Code works as expected.

Affected version

No response

Steps to reproduce the behavior

  1. Open a VS Code window on a Git worktree (not the main repo).
  2. Stage changes to files in the worktree.
  3. Attempt to commit using the built-in Git tools in VS Code or via the integrated terminal.
  4. Observe the error:
    [0204/181621.495272:ERROR:electron/shell/app/node_main.cc:146] Node.js environment variables are disabled because this process is invoked by other apps.
    fatal: Unable to create '/path/to/.git/worktrees/worktree-name/index.lock': Operation not permitted

Expected behavior

I expected to be able to commit staged changes from the VS Code window on the worktree without permission errors, similar to committing from the main repo or an external terminal.

Additional context

Screenshot showing error and terminal output
  • macOS
  • VS Code, using built-in Git support
  • Problem occurs only in worktrees
  • External terminal can commit successfully
  • Error mentions Electron, possibly points to a Node.js/electron/VSC sandbox issue
  • Path permissions appear correct
  • No visible lock files blocking the process

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions