somratpro commited on
Commit
2ba784e
Β·
1 Parent(s): 08ebfa3

fix: add explicit environment variables to gemini wrapper in Dockerfile to prevent sandbox and trust prompt failures

Browse files
Files changed (2) hide show
  1. Dockerfile +11 -1
  2. start.sh +0 -23
Dockerfile CHANGED
@@ -61,7 +61,7 @@ RUN npm install -g @google/gemini-cli @anthropic-ai/claude-code @openai/codex
61
  # 1. Drop cloudflare-proxy.js NODE_OPTIONS (would conflict with their HTTP)
62
  # 2. Pre-set --max-old-space-size=4096 so gemini doesn't trigger heap-size
63
  # self-relaunch (the spawn fails in HF Spaces containers)
64
- RUN for cmd in claude gemini codex; do \
65
  if [ -e /usr/local/bin/$cmd ]; then \
66
  mv /usr/local/bin/$cmd /usr/local/bin/${cmd}-real && \
67
  printf '#!/bin/sh\nunset NODE_OPTIONS\nexport NODE_OPTIONS="--max-old-space-size=4096 --no-deprecation --no-warnings"\nexec /usr/local/bin/%s-real "$@"\n' "$cmd" > /usr/local/bin/$cmd && \
@@ -69,6 +69,16 @@ RUN for cmd in claude gemini codex; do \
69
  fi; \
70
  done
71
 
 
 
 
 
 
 
 
 
 
 
72
  # Install Python dependencies for sync
73
  RUN pip install --no-cache-dir --break-system-packages huggingface_hub PyYAML
74
 
 
61
  # 1. Drop cloudflare-proxy.js NODE_OPTIONS (would conflict with their HTTP)
62
  # 2. Pre-set --max-old-space-size=4096 so gemini doesn't trigger heap-size
63
  # self-relaunch (the spawn fails in HF Spaces containers)
64
+ RUN for cmd in claude codex; do \
65
  if [ -e /usr/local/bin/$cmd ]; then \
66
  mv /usr/local/bin/$cmd /usr/local/bin/${cmd}-real && \
67
  printf '#!/bin/sh\nunset NODE_OPTIONS\nexport NODE_OPTIONS="--max-old-space-size=4096 --no-deprecation --no-warnings"\nexec /usr/local/bin/%s-real "$@"\n' "$cmd" > /usr/local/bin/$cmd && \
 
69
  fi; \
70
  done
71
 
72
+ # Gemini wrapper: also hard-code headless env vars so they survive even when
73
+ # Paperclip spawns gemini with a custom env object (no env inheritance fallback).
74
+ # GEMINI_SANDBOX=false β€” skip Docker sandbox attempt in containers
75
+ # GEMINI_CLI_TRUST_WORKSPACE=true β€” skip interactive trust prompt (causes relaunch)
76
+ RUN if [ -e /usr/local/bin/gemini ]; then \
77
+ mv /usr/local/bin/gemini /usr/local/bin/gemini-real && \
78
+ printf '#!/bin/sh\nunset NODE_OPTIONS\nexport NODE_OPTIONS="--max-old-space-size=4096 --no-deprecation --no-warnings"\nexport GEMINI_SANDBOX=false\nexport GEMINI_CLI_TRUST_WORKSPACE=true\nexec /usr/local/bin/gemini-real "$@"\n' > /usr/local/bin/gemini && \
79
+ chmod +x /usr/local/bin/gemini; \
80
+ fi
81
+
82
  # Install Python dependencies for sync
83
  RUN pip install --no-cache-dir --break-system-packages huggingface_hub PyYAML
84
 
start.sh CHANGED
@@ -325,29 +325,6 @@ if [ "$PAPERCLIP_READY" = true ]; then
325
  echo "Admin account already configured"
326
  fi
327
 
328
- # ── Agent CLI diagnostic (helps debug adapter failures) ──────────────────
329
- echo ""
330
- echo "=== Agent CLI Diagnostic ==="
331
- echo "[wrapper script content]"
332
- cat /usr/local/bin/gemini 2>&1 || true
333
- echo ""
334
- echo "[node sees these flags via NODE_OPTIONS]"
335
- HOME=/home/paperclip runuser -u paperclip -- /usr/local/bin/gemini-real -e "console.log('execArgv:', process.execArgv); console.log('NODE_OPTIONS:', process.env.NODE_OPTIONS);" 2>&1 || echo "FAILED: node flags check"
336
- echo ""
337
- echo "[gemini --version]"
338
- HOME=/home/paperclip runuser -u paperclip -- /usr/local/bin/gemini --version 2>&1
339
- echo "exit=$?"
340
- echo ""
341
- echo "[gemini hello probe β€” full output]"
342
- HOME=/home/paperclip runuser -u paperclip -- /usr/local/bin/gemini --output-format json "Respond with hello." > /tmp/gemini-probe.out 2> /tmp/gemini-probe.err
343
- PROBE_EXIT=$?
344
- echo "exit=$PROBE_EXIT"
345
- echo "--- stdout ---"
346
- cat /tmp/gemini-probe.out 2>/dev/null | head -40 || true
347
- echo "--- stderr ---"
348
- cat /tmp/gemini-probe.err 2>/dev/null | head -40 || true
349
- echo "=== End diagnostic ==="
350
- echo ""
351
  else
352
  echo "Warning: Paperclip did not become ready in 90s"
353
  fi
 
325
  echo "Admin account already configured"
326
  fi
327
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
328
  else
329
  echo "Warning: Paperclip did not become ready in 90s"
330
  fi