claude-code - 💡(How to fix) Fix [BUG] Sandbox startup error on Linux shows unrendered `${j$}` instead of the failing sandbox component [1 comments, 2 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#53081Fetched 2026-04-25 06:12:51
View on GitHub
Comments
1
Participants
2
Timeline
7
Reactions
1
Timeline (top)
labeled ×4cross-referenced ×2commented ×1

Error Message

Error: sandbox required but unavailable: ${j$} sandbox.failIfUnavailable is set — refusing to start without a working sandbox.

Root Cause

The error blocks startup completely — no project loads, no --help from inside the REPL, nothing. Without the missing variable there's no signal pointing at:

  • Which sandbox component failed
  • What the underlying syscall / exit code was
  • Where to look for the fix

In my case the actual cause was Ubuntu 24.04's kernel.apparmor_restrict_unprivileged_userns=1 default blocking bwrap from creating user namespaces (well-documented in #17727, fix in this comment). I only worked it out by SSH'ing in from another tool and asking it to diagnose. A first-time user without a backup would be stuck.

Code Example

Error: sandbox required but unavailable: ${j$}
sandbox.failIfUnavailable is set — refusing to start without a working sandbox.
RAW_BUFFERClick to expand / collapse

What's Wrong?

When Claude Code v2.1.98+ refuses to start because the sandbox can't initialise on Linux, the error message contains an unrendered JavaScript template literal:

Error: sandbox required but unavailable: ${j$}
sandbox.failIfUnavailable is set — refusing to start without a working sandbox.

The ${j$} is a minified variable name (j$) that should have been interpolated — presumably the failing sandbox component (bwrap, landlock, seccomp, etc.) or its exit detail. Users see literal ${j$} instead of useful context.

Why This Matters

The error blocks startup completely — no project loads, no --help from inside the REPL, nothing. Without the missing variable there's no signal pointing at:

  • Which sandbox component failed
  • What the underlying syscall / exit code was
  • Where to look for the fix

In my case the actual cause was Ubuntu 24.04's kernel.apparmor_restrict_unprivileged_userns=1 default blocking bwrap from creating user namespaces (well-documented in #17727, fix in this comment). I only worked it out by SSH'ing in from another tool and asking it to diagnose. A first-time user without a backup would be stuck.

Suggested Fixes

Two scoped, separable asks:

  1. Fix the template literal substitution so ${j$} becomes the actual failing-component name. Whatever's stopping the variable from being interpolated (minifier interaction? closure capture? String.raw somewhere?) is itself the bug — the surrounding error path looks correct.

  2. Make the error actionable on Linux. When bwrap exits with Permission denied during uid map setup and /proc/sys/kernel/apparmor_restrict_unprivileged_userns reads 1 (both cheap to detect at startup), include a one-line pointer in the error message — e.g. "On Ubuntu 24.04+, bubblewrap requires an AppArmor profile to create user namespaces — see [docs link]."

Reproduction

  1. Fresh Ubuntu 24.04 LTS with the default apparmor_restrict_unprivileged_userns=1
  2. apt install bubblewrap (yields 0.9.0)
  3. Install Claude Code v2.1.98+ (reproduced on v2.1.120)
  4. Run claude from any directory
  5. Observe error with unrendered ${j$} and no recovery hint

Environment

  • Claude Code: 2.1.120
  • OS: Ubuntu 24.04 LTS
  • Kernel: 6.8.0-110-generic
  • bubblewrap: 0.9.0
  • AppArmor LSM: enabled
  • kernel.apparmor_restrict_unprivileged_userns: 1 (Ubuntu 24.04 default)
  • kernel.unprivileged_userns_clone: 1

Related

  • #17727 — broad Linux sandbox issues; AppArmor fix posted as a comment on 2026-03-27 but still buried in a long thread
  • #46168 — sandbox initialisation failures on Linux (apply-seccomp helper missing in v2.1.98+)
  • #50781 — bwrap sandbox fails with read-only filesystem error

extent analysis

TL;DR

Fix the template literal substitution to display the actual failing-component name instead of ${j$} and consider adding a specific error message for the AppArmor restriction on Ubuntu 24.04.

Guidance

  • Investigate the minification process to determine why the variable j$ is not being interpolated correctly in the error message.
  • Check the code for any potential issues with closure capture or String.raw that could be preventing the variable substitution.
  • Consider adding a conditional check for the AppArmor restriction on Ubuntu 24.04 and include a helpful error message with a link to the relevant documentation.
  • Review related issues (#17727, #46168, #50781) for potential connections to the current problem.

Example

No specific code example can be provided without more context, but the fix might involve modifying the error message template to correctly substitute the j$ variable, such as using a different templating engine or adjusting the minification settings.

Notes

The issue seems to be related to the interaction between the minifier and the error message template. The AppArmor restriction on Ubuntu 24.04 is a known issue, and providing a clear error message can help users diagnose and fix the problem.

Recommendation

Apply a workaround by adding a conditional check for the AppArmor restriction and providing a helpful error message, as this can help users diagnose and fix the issue while the template literal substitution is being investigated.

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