@@ -106,35 +106,25 @@ try {
106106 if (!isRecord(settings)) settings = {}
107107} catch {}
108108
109- const nextSettings = {
110- ...settings,
111- security: {
112- ...(isRecord(settings.security) ? settings.security : {}),
113- folderTrust: {
114- ...(isRecord(settings.security?.folderTrust) ? settings.security.folderTrust : {}),
115- enabled: false
116- }
117- },
118- approvalPolicy: "never"
119- }
109+ const nextSettings = JSON.parse(JSON.stringify(settings))
110+
111+ if (!isRecord(nextSettings.security)) nextSettings.security = {}
112+ if (!isRecord(nextSettings.security.folderTrust)) nextSettings.security.folderTrust = {}
113+
114+ nextSettings.security.folderTrust.enabled = false
115+ nextSettings.approvalPolicy = "never"
116+
117+ // Force auth method detection
118+ const settingsDir = path.dirname(settingsPath)
119+ const oauthPath = path.join(settingsDir, "oauth_creds.json")
120+ const apiKeyPath = path.join(settingsDir, "..", ".api-key")
120121
121- // Auto-detect auth method if not set
122- const currentAuth = nextSettings.security.auth
123- if (!isRecord(currentAuth) || !currentAuth.selectedType) {
124- const settingsDir = path.dirname(settingsPath)
125- const configDir = process.env.GEMINI_CONFIG_DIR || ""
126-
127- const hasOauth = fs.existsSync(path.join(settingsDir, "oauth_creds.json")) ||
128- (configDir && fs.existsSync(path.join(configDir, ".gemini", "oauth_creds.json")))
129-
130- const hasApiKey = fs.existsSync(path.join(settingsDir, "..", ".api-key")) ||
131- (configDir && fs.existsSync(path.join(configDir, ".api-key")))
132-
133- if (hasOauth) {
134- nextSettings.security.auth = { ...(isRecord(currentAuth) ? currentAuth : {}), selectedType: "oauth-personal" }
135- } else if (hasApiKey) {
136- nextSettings.security.auth = { ...(isRecord(currentAuth) ? currentAuth : {}), selectedType: "api-key" }
137- }
122+ if (fs.existsSync(oauthPath)) {
123+ if (!isRecord(nextSettings.security.auth)) nextSettings.security.auth = {}
124+ nextSettings.security.auth.selectedType = "oauth-personal"
125+ } else if (fs.existsSync(apiKeyPath)) {
126+ if (!isRecord(nextSettings.security.auth)) nextSettings.security.auth = {}
127+ nextSettings.security.auth.selectedType = "api-key"
138128}
139129
140130if (JSON.stringify(settings) !== JSON.stringify(nextSettings)) {
@@ -174,6 +164,8 @@ const renderGeminiProfileSetup = (config: TemplateConfig): string =>
174164 String . raw `GEMINI_PROFILE="/etc/profile.d/gemini-config.sh"
175165printf "export GEMINI_AUTH_LABEL=%q\n" "$GEMINI_AUTH_LABEL" > "$GEMINI_PROFILE"
176166printf "export GEMINI_HOME=%q\n" "${ config . geminiHome } " >> "$GEMINI_PROFILE"
167+ printf "export GEMINI_CLI_DISABLE_UPDATE_CHECK=true\n" >> "$GEMINI_PROFILE"
168+ printf "export GEMINI_CLI_NONINTERACTIVE=true\n" >> "$GEMINI_PROFILE"
177169cat <<'EOF' >> "$GEMINI_PROFILE"
178170if [[ -f "$GEMINI_HOME/.api-key" ]]; then
179171 export GEMINI_API_KEY="$(cat "$GEMINI_HOME/.api-key" | tr -d '\r\n')"
182174chmod 0644 "$GEMINI_PROFILE" || true
183175
184176docker_git_upsert_ssh_env "GEMINI_AUTH_LABEL" "$GEMINI_AUTH_LABEL"
185- docker_git_upsert_ssh_env "GEMINI_API_KEY" "${ "$" } {GEMINI_API_KEY:-}"`
177+ docker_git_upsert_ssh_env "GEMINI_API_KEY" "${ GEMINI_API_KEY :- } "
178+ docker_git_upsert_ssh_env "GEMINI_CLI_DISABLE_UPDATE_CHECK" "true"
179+ docker_git_upsert_ssh_env "GEMINI_CLI_NONINTERACTIVE" "true"`
186180
187181const entrypointGeminiNoticeTemplate = String . raw `# Ensure global GEMINI.md exists for container context
188182GEMINI_MD_PATH="__GEMINI_HOME__/GEMINI.md"
0 commit comments