Sandbox allowWrite treats absolute paths as relative to ~/.claude/

Status Fixed / completed
Maintainer reply None cached
Activity 4 comments · opened Mar 11, 2026 · closed Mar 11, 2026

Bug Description

When configuring custom sandbox filesystem write paths in ~/.claude/settings.json, absolute paths are resolved as if they are relative to ~/.claude/, resulting in doubled/incorrect paths at runtime.

Steps to Reproduce

  1. Add absolute paths to ~/.claude/settings.json:
"sandbox": {
    "enabled": true,
    "filesystem": {
        "allowWrite": [
            "/home/user/.claude/learning",
            "/home/user/.claude/knowledge/projects"
        ]
    }
}
  1. Start a Claude Code session
  2. Observe the runtime sandbox restrictions in the system prompt — the write allowlist shows:
"/home/user/.claude/home/user/.claude/learning"
"/home/user/.claude/home/user/.claude/knowledge/projects"
  1. Any tool attempting to write to /home/user/.claude/learning/ fails with permission errors because the sandbox is looking for the doubled path.

Expected Behavior

Absolute paths in allowWrite should be honored as-is. /home/user/.claude/learning should appear as /home/user/.claude/learning in the runtime sandbox, not /home/user/.claude/home/user/.claude/learning.

Workaround

Use relative paths instead of absolute paths. These get correctly resolved when the base is prepended:

"allowWrite": [
    "learning",
    "knowledge/projects"
]

Environment

  • Claude Code CLI (latest as of 2025-03-11)
  • Linux (Ubuntu)
  • Sandbox enabled via settings.json

View original on GitHub ↗

4 Comments

github-actions[bot] · 7 months ago

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/32757
  2. https://github.com/anthropics/claude-code/issues/28206
  3. https://github.com/anthropics/claude-code/issues/22947

This issue will be automatically closed as a duplicate in 3 days.

  • If your issue is a duplicate, please close it and 👍 the existing issue instead
  • To prevent auto-closure, add a comment or 👎 this comment

🤖 Generated with Claude Code

laniakea001 · 7 months ago

The issue with absolute paths being treated as relative to ~.claude/ is a common path resolution bug in sandboxed environments.

Solution approach:

  1. Explicit path validation - Normalize all paths to absolute form before any sandbox operation
  2. Sandbox configuration - Use allowlist patterns that explicitly handle both relative and absolute paths:
{
  "allowWrite": [
    "/**",
    "~/.claude/projects//**"
  ]
}
  1. Error messaging - When path resolution fails, provide clear feedback about the expected format

OpenClaw's sandbox implementation uses a command validation layer that normalizes paths before execution - this prevents the relative/absolute confusion entirely by enforcing a canonical path representation.

m66se · 7 months ago

Not a bug — sandbox paths need a ~/ or // prefix to be treated as home-relative or absolute. Without a prefix, paths resolve relative to the settings file's directory (~/.claude/), which caused the doubling. Documented behavior, just unintuitive. Closing.

github-actions[bot] · 6 months ago

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.