* If the user explicitly enabled sandbox (sandbox.enabled: true in settings) * but it cannot actually run, return a human-readable reason. Otherwise * return undefined. * * Fix for #34044: previously isSandboxingEnabled() silently returned false * when dependencies were missing, giving users ze
()
| 560 | * Does not cover the case where the user never enabled sandbox (no noise). |
| 561 | */ |
| 562 | function getSandboxUnavailableReason(): string | undefined { |
| 563 | // Only warn if user explicitly asked for sandbox. If they didn't enable |
| 564 | // it, missing deps are irrelevant. |
| 565 | if (!getSandboxEnabledSetting()) { |
| 566 | return undefined |
| 567 | } |
| 568 | |
| 569 | if (!isSupportedPlatform()) { |
| 570 | const platform = getPlatform() |
| 571 | if (platform === 'wsl') { |
| 572 | return 'sandbox.enabled is set but WSL1 is not supported (requires WSL2)' |
| 573 | } |
| 574 | return `sandbox.enabled is set but ${platform} is not supported (requires macOS, Linux, or WSL2)` |
| 575 | } |
| 576 | |
| 577 | if (!isPlatformInEnabledList()) { |
| 578 | return `sandbox.enabled is set but ${getPlatform()} is not in sandbox.enabledPlatforms` |
| 579 | } |
| 580 | |
| 581 | const deps = checkDependencies() |
| 582 | if (deps.errors.length > 0) { |
| 583 | const platform = getPlatform() |
| 584 | const hint = |
| 585 | platform === 'macos' |
| 586 | ? 'run /sandbox or /doctor for details' |
| 587 | : 'install missing tools (e.g. apt install bubblewrap socat) or run /sandbox for details' |
| 588 | return `sandbox.enabled is set but dependencies are missing: ${deps.errors.join(', ')} · ${hint}` |
| 589 | } |
| 590 | |
| 591 | return undefined |
| 592 | } |
| 593 | |
| 594 | /** |
| 595 | * Get glob patterns that won't work fully on Linux/WSL |
nothing calls this directly
no test coverage detected