Spaces:
Running
Running
fix: bypass gemini CLI relaunch mechanism using GEMINI_CLI_NO_RELAUNCH environment variable
Browse files- Dockerfile +13 -27
- start.sh +5 -2
Dockerfile
CHANGED
|
@@ -69,37 +69,23 @@ RUN for cmd in claude codex; do \
|
|
| 69 |
fi; \
|
| 70 |
done
|
| 71 |
|
| 72 |
-
# Gemini wrapper —
|
| 73 |
#
|
| 74 |
-
# ROOT CAUSE:
|
| 75 |
-
#
|
| 76 |
-
#
|
| 77 |
#
|
| 78 |
-
# FIX:
|
| 79 |
-
#
|
| 80 |
-
#
|
| 81 |
#
|
| 82 |
-
# Also bake in headless
|
| 83 |
-
# gemini with a custom env object
|
| 84 |
-
# GEMINI_SANDBOX=false — skip Docker-sandbox attempt
|
| 85 |
# GEMINI_CLI_TRUST_WORKSPACE=true — skip interactive workspace-trust prompt
|
| 86 |
-
RUN
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
const bin = pkg.bin; \
|
| 90 |
-
const entry = typeof bin === 'string' ? bin : (bin.gemini || bin[Object.keys(bin)[0]]); \
|
| 91 |
-
console.log(require('path').resolve('$GEMINI_PKG', entry)); \
|
| 92 |
-
") && \
|
| 93 |
-
echo "Gemini JS entry: $GEMINI_JS" && \
|
| 94 |
-
mv /usr/local/bin/gemini /usr/local/bin/gemini-real && \
|
| 95 |
-
{ \
|
| 96 |
-
echo '#!/bin/sh'; \
|
| 97 |
-
echo 'unset NODE_OPTIONS'; \
|
| 98 |
-
echo 'export NODE_OPTIONS="--no-deprecation --no-warnings"'; \
|
| 99 |
-
echo 'export GEMINI_SANDBOX=false'; \
|
| 100 |
-
echo 'export GEMINI_CLI_TRUST_WORKSPACE=true'; \
|
| 101 |
-
echo "exec node --max-old-space-size=4096 $GEMINI_JS \"\$@\""; \
|
| 102 |
-
} > /usr/local/bin/gemini && \
|
| 103 |
chmod +x /usr/local/bin/gemini && \
|
| 104 |
echo "=== gemini wrapper ===" && cat /usr/local/bin/gemini
|
| 105 |
|
|
|
|
| 69 |
fi; \
|
| 70 |
done
|
| 71 |
|
| 72 |
+
# Gemini wrapper — fix for "Failed to relaunch the CLI process":
|
| 73 |
#
|
| 74 |
+
# ROOT CAUSE: relaunch.ts::relaunchAppInChildProcess() spawns a child process
|
| 75 |
+
# with stdio IPC. That spawn fails when Paperclip pipes gemini's stdio.
|
| 76 |
+
# Source: packages/cli/src/utils/relaunch.ts
|
| 77 |
#
|
| 78 |
+
# FIX: GEMINI_CLI_NO_RELAUNCH=1 — documented kill-switch in relaunch.ts that
|
| 79 |
+
# makes relaunchAppInChildProcess() return early (skip spawn entirely).
|
| 80 |
+
# The process then runs as the main process without a child.
|
| 81 |
#
|
| 82 |
+
# Also bake in other headless vars so they survive even if Paperclip spawns
|
| 83 |
+
# gemini with a custom env object:
|
| 84 |
+
# GEMINI_SANDBOX=false — skip Docker-sandbox attempt
|
| 85 |
# GEMINI_CLI_TRUST_WORKSPACE=true — skip interactive workspace-trust prompt
|
| 86 |
+
RUN mv /usr/local/bin/gemini /usr/local/bin/gemini-real && \
|
| 87 |
+
printf '#!/bin/sh\nunset NODE_OPTIONS\nexport NODE_OPTIONS="--max-old-space-size=4096 --no-deprecation --no-warnings"\nexport GEMINI_CLI_NO_RELAUNCH=1\nexport GEMINI_SANDBOX=false\nexport GEMINI_CLI_TRUST_WORKSPACE=true\nexec /usr/local/bin/gemini-real "$@"\n' \
|
| 88 |
+
> /usr/local/bin/gemini && \
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 89 |
chmod +x /usr/local/bin/gemini && \
|
| 90 |
echo "=== gemini wrapper ===" && cat /usr/local/bin/gemini
|
| 91 |
|
start.sh
CHANGED
|
@@ -180,9 +180,12 @@ fi
|
|
| 180 |
# Disable sandbox (would try to start Docker inside Docker)
|
| 181 |
export GEMINI_SANDBOX=false
|
| 182 |
# Trust the workspace — paperclip user runs from /app/paperclip (root-owned).
|
| 183 |
-
# Without this, gemini's relaunch child fails the trust check and parent reports
|
| 184 |
-
# "Failed to relaunch the CLI process."
|
| 185 |
export GEMINI_CLI_TRUST_WORKSPACE=true
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 186 |
|
| 187 |
# ── Background sync loop ──────────────────────────────────────────────────────
|
| 188 |
if [ -n "${HF_TOKEN:-}" ]; then
|
|
|
|
| 180 |
# Disable sandbox (would try to start Docker inside Docker)
|
| 181 |
export GEMINI_SANDBOX=false
|
| 182 |
# Trust the workspace — paperclip user runs from /app/paperclip (root-owned).
|
|
|
|
|
|
|
| 183 |
export GEMINI_CLI_TRUST_WORKSPACE=true
|
| 184 |
+
# Kill-switch for relaunch.ts::relaunchAppInChildProcess() — the spawn inside
|
| 185 |
+
# fails when Paperclip pipes gemini's stdio (IPC channel setup fails).
|
| 186 |
+
# With this set, relaunchAppInChildProcess() returns early and gemini runs
|
| 187 |
+
# as the main process without spawning a child.
|
| 188 |
+
export GEMINI_CLI_NO_RELAUNCH=1
|
| 189 |
|
| 190 |
# ── Background sync loop ──────────────────────────────────────────────────────
|
| 191 |
if [ -n "${HF_TOKEN:-}" ]; then
|