Skip to content

Conversation

@echoVic
Copy link
Owner

@echoVic echoVic commented Feb 9, 2026

Problem

blade unconditionally blocks any root user (uid === 0), preventing execution in:

  • Docker containers
  • CI pipelines (GitHub Actions, etc.)
  • Sandbox environments (OpenClaw, etc.)

Root Cause

blade.tsx line 43 checks process.getuid() === 0 and exits immediately, without distinguishing between sudo escalation and native root environments.

Solution

Distinguish between:

Scenario SUDO_USER Behavior
sudo blade ✅ set ❌ Blocked (protects config file permissions)
Docker/sandbox/CI root ❌ unset ✅ Allowed
BLADE_ALLOW_ROOT=1 sudo blade ✅ set ✅ Allowed (escape hatch)

Also detects container environments via container, DOCKER_CONTAINER, KUBERNETES_SERVICE_HOST, and CI env vars.

Changes

  • packages/cli/src/blade.tsx: Refined root detection logic in main()

Testing

# Native root (container) - should work
blade --version  # ✅ 0.2.3

# Sudo escalation - should block
sudo blade --version  # ❌ blocked

# Escape hatch
BLADE_ALLOW_ROOT=1 sudo blade --version  # ✅ works

Previously, blade unconditionally blocked any root user (uid === 0),
which prevented running in Docker containers, CI pipelines, and
sandbox environments where root is the default user.

Now we distinguish between:
- sudo escalation (SUDO_USER set) → still blocked for safety
- native root (containers/CI) → allowed

Added BLADE_ALLOW_ROOT=1 escape hatch for edge cases.
@echoVic echoVic merged commit e7ca53d into main Feb 9, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant