claude-code - 💡(How to fix) Fix [BUG] Sandbox doesn't work when ~/.claude/settings.json is read-only symlink to nix-store [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#52525Fetched 2026-04-24 06:04:52
View on GitHub
Comments
0
Participants
1
Timeline
3
Reactions
0
Author
Participants
Timeline (top)
labeled ×3

Error Message

● Bash(curl -s https://github.com | head -5) ⎿  Error: Exit code 1 bwrap: Can't create file at /home/arian/.claude/settings.json: No such file or directory

● Blocked by the sandbox — bwrap (bubblewrap) denied the network access. That confirms the distinction: local Bash calls are sandboxed, WebFetch is not.

❯ nah it fails for antoehr reason

● Right — the actual error is bwrap: Can't create file at /home/arian/.claude/settings.json: No such file or directory. The bubblewrap sandbox setup itself is failing because /home/arian/.claude/settings.json doesn't exist, which bwrap needs to set up the sandbox. That's the real blocker, not a network rule for github.com.

! ls ~/.claude/settings.json ⎿  /home/arian/.claude/settings.json

! ls -la ~/.claude/settings.json ⎿  lrwxrwxrwx 1 arian users 84 Apr 23 21:43 /home/arian/.claude/settings.json -> /nix/store/9gfvbr7vmj2vsqisakvi9vxs7p3i0lzl-home-manager-files/.claude/settings.json

❯ ● Right — the actual error is bwrap: Can't create file at /home/arian/.claude/settings.json: No such file or directory. The bubblewrap sandbox setup itself is failing because /home/arian/.claude/settings.json doesn't exist, which bwrap needs to set up the sandbox. That's the real blocker, not a network rule for github.com.

! ls ~/.claude/settings.json ⎿  /home/arian/.claude/settings.json

! ls -la ~/.claude/settings.json ⎿  lrwxrwxrwx 1 arian users 84 Apr 23 21:43 /home/arian/.claude/settings.json -> /nix/store/9gfvbr7vmj2vsqisakvi9vxs7p3i0lzl-home-manager-files/.claude/settings.json but it does

● The file exists but it's a symlink into /nix/store (read-only). bwrap likely tries to bind-mount or create an overlay for that path as part of sandbox setup, but can't because the target is in the immutable Nix store. That's what causes the failure.

Root Cause

bwrap fails to setup because it can't write to ~/.claude/settings/json

Code Example

! ls -la  ~/.claude/settings.json
  ⎿  lrwxrwxrwx 1 arian users 84 Apr 23 21:43 /home/arian/.claude/settings.json -> /nix/store/9gfvbr7vmj2vsqisakvi9vxs7p3i0lzl-home-manager-files/.claude/settings.json

! cat ~/.claude/settings.json
  ⎿  {
       "$schema": "https://json.schemastore.org/claude-code-settings.json",
       "permissions": {
         "allow": [
           "Bash(jj log)",
           "Bash(jj st)",
           "Bash(jj diff)",
     "Bash(jj root)"
         ],
         "deny": [
     "Bash(git *)"
         ]
       },
       "sandbox": {
         "enabled": true,
         "failIfUnavailable": true,
         "filesystem": {
           "allowRead": [
             ".",
             "/nix/store",
     "/nix/var/nix/daemon-socket/socket"
           ],
           "allowWrite": [
             ".",
     "/nix/var/nix/daemon-socket/socket"
           ],
           "denyRead": [
     "/"
           ],
           "denyWrite": [
     "/"
           ]
         },
         "network": {
           "allowAllUnixSockets": true,
           "allowedDomains": [
             "cache.nixos.org",
     "channels.nixos.org"
           ]
         }
       }
     }

---

Bash(curl -s https://github.com | head -5)
  ⎿  Error: Exit code 1
     bwrap: Can't create file at /home/arian/.claude/settings.json: No such file or directory

Blocked by the sandbox — bwrap (bubblewrap) denied the network access. That confirms the distinction: local Bash calls are sandboxed, WebFetch is not.

 nah it fails for antoehr reason

Right — the actual error is bwrap: Can't create file at /home/arian/.claude/settings.json: No such file or directory. The bubblewrap sandbox setup itself is failing
  because /home/arian/.claude/settings.json doesn't exist, which bwrap needs to set up the sandbox. That's the real blocker, not a network rule for github.com.

! ls ~/.claude/settings.json
  ⎿  /home/arian/.claude/settings.json

! ls -la  ~/.claude/settings.json
  ⎿  lrwxrwxrwx 1 arian users 84 Apr 23 21:43 /home/arian/.claude/settings.json -> /nix/store/9gfvbr7vmj2vsqisakvi9vxs7p3i0lzl-home-manager-files/.claude/settings.json

❯ ● Right — the actual error is bwrap: Can't create file at /home/arian/.claude/settings.json: No such file or directory. The bubblewrap sandbox setup itself is
  failing
    because /home/arian/.claude/settings.json doesn't exist, which bwrap needs to set up the sandbox. That's the real blocker, not a network rule for github.com.

  ! ls ~/.claude/settings.json
    ⎿  /home/arian/.claude/settings.json

  ! ls -la  ~/.claude/settings.json
    ⎿  lrwxrwxrwx 1 arian users 84 Apr 23 21:43 /home/arian/.claude/settings.json ->
  /nix/store/9gfvbr7vmj2vsqisakvi9vxs7p3i0lzl-home-manager-files/.claude/settings.json
   but it does

The file exists but it's a symlink into /nix/store (read-only). bwrap likely tries to bind-mount or create an overlay for that path as part of sandbox setup, but
  can't because the target is in the immutable Nix store. That's what causes the failure.

---

{ pkgs, lib, ... }:
{
  programs.claude-code = {
    enable = true;
    settings = {
      sandbox = {
        enabled = true;
        failIfUnavailable = true;
        filesystem = {
          denyWrite = [ "/" ];
          denyRead = [ "/" ];
          allowRead = [
            "."
            "/nix/store"
            "/nix/var/nix/daemon-socket/socket"
          ];
          allowWrite = [
            "."
            "/nix/var/nix/daemon-socket/socket"
          ];
        };
        network = {
          allowUnixSockets = lib.mkIf pkgs.stdenv.hostPlatform.isDarwin [ "/nix/var/nix/daemon-socket/socket" ];
          allowAllUnixSockets = pkgs.stdenv.hostPlatform.isLinux;
          allowedDomains = [
            "cache.nixos.org"
            "channels.nixos.org"
          ];
        };
      };
      permissions = {
        deny = [ "Bash(git *)" ];
        allow = [
          "Bash(jj log)"
          "Bash(jj st)"
          "Bash(jj diff)"
          "Bash(jj root)"
        ];
      };
    };
  };
}
RAW_BUFFERClick to expand / collapse

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • I am using the latest version of Claude Code

What's Wrong?

bwrap fails to setup because it can't write to ~/.claude/settings/json

contents:

! ls -la  ~/.claude/settings.json
  ⎿  lrwxrwxrwx 1 arian users 84 Apr 23 21:43 /home/arian/.claude/settings.json -> /nix/store/9gfvbr7vmj2vsqisakvi9vxs7p3i0lzl-home-manager-files/.claude/settings.json

! cat ~/.claude/settings.json
  ⎿  {
       "$schema": "https://json.schemastore.org/claude-code-settings.json",
       "permissions": {
         "allow": [
           "Bash(jj log)",
           "Bash(jj st)",
           "Bash(jj diff)",
     "Bash(jj root)"
         ],
         "deny": [
     "Bash(git *)"
         ]
       },
       "sandbox": {
         "enabled": true,
         "failIfUnavailable": true,
         "filesystem": {
           "allowRead": [
             ".",
             "/nix/store",
     "/nix/var/nix/daemon-socket/socket"
           ],
           "allowWrite": [
             ".",
     "/nix/var/nix/daemon-socket/socket"
           ],
           "denyRead": [
     "/"
           ],
           "denyWrite": [
     "/"
           ]
         },
         "network": {
           "allowAllUnixSockets": true,
           "allowedDomains": [
             "cache.nixos.org",
     "channels.nixos.org"
           ]
         }
       }
     }

What Should Happen?

It shouldn't fail.

Error Messages/Logs

● Bash(curl -s https://github.com | head -5)
  ⎿  Error: Exit code 1
     bwrap: Can't create file at /home/arian/.claude/settings.json: No such file or directory

● Blocked by the sandbox — bwrap (bubblewrap) denied the network access. That confirms the distinction: local Bash calls are sandboxed, WebFetch is not.

❯ nah it fails for antoehr reason

● Right — the actual error is bwrap: Can't create file at /home/arian/.claude/settings.json: No such file or directory. The bubblewrap sandbox setup itself is failing
  because /home/arian/.claude/settings.json doesn't exist, which bwrap needs to set up the sandbox. That's the real blocker, not a network rule for github.com.

! ls ~/.claude/settings.json
  ⎿  /home/arian/.claude/settings.json

! ls -la  ~/.claude/settings.json
  ⎿  lrwxrwxrwx 1 arian users 84 Apr 23 21:43 /home/arian/.claude/settings.json -> /nix/store/9gfvbr7vmj2vsqisakvi9vxs7p3i0lzl-home-manager-files/.claude/settings.json

❯ ● Right — the actual error is bwrap: Can't create file at /home/arian/.claude/settings.json: No such file or directory. The bubblewrap sandbox setup itself is
  failing
    because /home/arian/.claude/settings.json doesn't exist, which bwrap needs to set up the sandbox. That's the real blocker, not a network rule for github.com.

  ! ls ~/.claude/settings.json
    ⎿  /home/arian/.claude/settings.json

  ! ls -la  ~/.claude/settings.json
    ⎿  lrwxrwxrwx 1 arian users 84 Apr 23 21:43 /home/arian/.claude/settings.json ->
  /nix/store/9gfvbr7vmj2vsqisakvi9vxs7p3i0lzl-home-manager-files/.claude/settings.json
   but it does

● The file exists but it's a symlink into /nix/store (read-only). bwrap likely tries to bind-mount or create an overlay for that path as part of sandbox setup, but
  can't because the target is in the immutable Nix store. That's what causes the failure.

Steps to Reproduce

Make settings.json a read-only symlink to /nix/store path.

This happens when using home-manager

{ pkgs, lib, ... }:
{
  programs.claude-code = {
    enable = true;
    settings = {
      sandbox = {
        enabled = true;
        failIfUnavailable = true;
        filesystem = {
          denyWrite = [ "/" ];
          denyRead = [ "/" ];
          allowRead = [
            "."
            "/nix/store"
            "/nix/var/nix/daemon-socket/socket"
          ];
          allowWrite = [
            "."
            "/nix/var/nix/daemon-socket/socket"
          ];
        };
        network = {
          allowUnixSockets = lib.mkIf pkgs.stdenv.hostPlatform.isDarwin [ "/nix/var/nix/daemon-socket/socket" ];
          allowAllUnixSockets = pkgs.stdenv.hostPlatform.isLinux;
          allowedDomains = [
            "cache.nixos.org"
            "channels.nixos.org"
          ];
        };
      };
      permissions = {
        deny = [ "Bash(git *)" ];
        allow = [
          "Bash(jj log)"
          "Bash(jj st)"
          "Bash(jj diff)"
          "Bash(jj root)"
        ];
      };
    };
  };
}

Claude Model

Opus

Is this a regression?

I don't know

Last Working Version

No response

Claude Code Version

2.1.112 (Claude Code)

Platform

Anthropic API

Operating System

Other Linux

Terminal/Shell

Other

Additional Information

No response

extent analysis

TL;DR

The issue can be resolved by changing the settings.json file to a regular file instead of a read-only symlink to a /nix/store path, allowing bwrap to write to it.

Guidance

  • The error occurs because bwrap tries to create a file at /home/arian/.claude/settings.json, but it's a symlink to a read-only location in the Nix store.
  • To fix this, you can try creating a regular file at /home/arian/.claude/settings.json with the desired contents, instead of a symlink.
  • You can also consider modifying your home-manager configuration to create a writable settings.json file.
  • Verify that the settings.json file is writable by running ls -la ~/.claude/settings.json and checking the permissions.

Example

No code example is provided as the issue is related to file system permissions and configuration.

Notes

The issue is specific to the Nix store and home-manager configuration, so the solution may vary depending on your specific setup.

Recommendation

Apply a workaround by creating a regular settings.json file, as the root cause is related to the read-only nature of the Nix store.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix [BUG] Sandbox doesn't work when ~/.claude/settings.json is read-only symlink to nix-store [1 participants]