Skip to content

Commit 1730be4

Browse files
committed
fix(gemini): resolve nested .gemini directory and fix configuration paths
1 parent 17bbbe2 commit 1730be4

File tree

1 file changed

+14
-2
lines changed
  • packages/lib/src/core/templates-entrypoint

1 file changed

+14
-2
lines changed

packages/lib/src/core/templates-entrypoint/gemini.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,18 @@ docker_git_link_gemini_file() {
4949
# Link .api-key, .env, and .gemini directory from central auth storage to container home
5050
docker_git_link_gemini_file "$GEMINI_CONFIG_DIR/.api-key" "$GEMINI_HOME_DIR/.api-key"
5151
docker_git_link_gemini_file "$GEMINI_CONFIG_DIR/.env" "$GEMINI_HOME_DIR/.env"
52-
docker_git_link_gemini_file "$GEMINI_CONFIG_DIR/.gemini" "$GEMINI_HOME_DIR/.gemini"
52+
53+
# Special case for .gemini folder: we want the folder itself to be the link if it doesn't exist
54+
# or its content to be linked if we want to manage it.
55+
if [[ -d "$GEMINI_CONFIG_DIR/.gemini" ]]; then
56+
if [[ -L "$GEMINI_HOME_DIR" ]]; then
57+
rm -f "$GEMINI_HOME_DIR"
58+
elif [[ -d "$GEMINI_HOME_DIR" ]]; then
59+
# If it's a real directory, move it aside if it's empty or just has our managed files
60+
mv "$GEMINI_HOME_DIR" "$GEMINI_HOME_DIR.bak-$(date +%s)" || true
61+
fi
62+
ln -sfn "$GEMINI_CONFIG_DIR/.gemini" "$GEMINI_HOME_DIR"
63+
fi
5364
5465
docker_git_refresh_gemini_env() {
5566
# If .api-key exists, export it as GEMINI_API_KEY
@@ -73,10 +84,11 @@ const renderGeminiAuthConfig = (config: TemplateConfig): string =>
7384

7485
const renderGeminiPermissionSettingsConfig = (config: TemplateConfig): string =>
7586
String.raw`# Gemini CLI: keep trust settings in sync with docker-git defaults
76-
GEMINI_SETTINGS_DIR="${config.geminiHome}/.gemini"
87+
GEMINI_SETTINGS_DIR="${config.geminiHome}"
7788
GEMINI_TRUST_SETTINGS_FILE="$GEMINI_SETTINGS_DIR/trustedFolders.json"
7889
GEMINI_CONFIG_SETTINGS_FILE="$GEMINI_SETTINGS_DIR/settings.json"
7990
91+
# Wait for symlink to be established by the auth config step
8092
mkdir -p "$GEMINI_SETTINGS_DIR" || true
8193
8294
# Disable folder trust prompt in settings.json

0 commit comments

Comments
 (0)