summaryrefslogtreecommitdiff
path: root/packages/cli/src/config/config.ts
diff options
context:
space:
mode:
authorJack Wotherspoon <[email protected]>2025-07-07 01:13:13 -0400
committerGitHub <[email protected]>2025-07-07 05:13:13 +0000
commitb70fba5b09b274c8a751d3c579fc31fe847f497f (patch)
tree3f84e4b5e0704b8c1c1676db1010b77d7fcaa2fa /packages/cli/src/config/config.ts
parent87a44ec4689b352a16467701e4bff9894c5afb84 (diff)
fix: respect env variables in .env for settings.json variable substitution (#3416)
Diffstat (limited to 'packages/cli/src/config/config.ts')
-rw-r--r--packages/cli/src/config/config.ts43
1 files changed, 0 insertions, 43 deletions
diff --git a/packages/cli/src/config/config.ts b/packages/cli/src/config/config.ts
index cecf904b..7eed1db7 100644
--- a/packages/cli/src/config/config.ts
+++ b/packages/cli/src/config/config.ts
@@ -13,7 +13,6 @@ import {
setGeminiMdFilename as setServerGeminiMdFilename,
getCurrentGeminiMdFilename,
ApprovalMode,
- GEMINI_CONFIG_DIR as GEMINI_DIR,
DEFAULT_GEMINI_MODEL,
DEFAULT_GEMINI_EMBEDDING_MODEL,
FileDiscoveryService,
@@ -23,10 +22,6 @@ import { Settings } from './settings.js';
import { Extension } from './extension.js';
import { getCliVersion } from '../utils/version.js';
-import * as dotenv from 'dotenv';
-import * as fs from 'node:fs';
-import * as path from 'node:path';
-import * as os from 'node:os';
import { loadSandboxConfig } from './sandboxConfig.js';
// Simple console logger for now - replace with actual logger if available
@@ -166,8 +161,6 @@ export async function loadCliConfig(
extensions: Extension[],
sessionId: string,
): Promise<Config> {
- loadEnvironment();
-
const argv = await parseArguments();
const debugMode = argv.debug || false;
@@ -279,39 +272,3 @@ function mergeExcludeTools(
}
return [...allExcludeTools];
}
-
-function findEnvFile(startDir: string): string | null {
- let currentDir = path.resolve(startDir);
- while (true) {
- // prefer gemini-specific .env under GEMINI_DIR
- const geminiEnvPath = path.join(currentDir, GEMINI_DIR, '.env');
- if (fs.existsSync(geminiEnvPath)) {
- return geminiEnvPath;
- }
- const envPath = path.join(currentDir, '.env');
- if (fs.existsSync(envPath)) {
- return envPath;
- }
- const parentDir = path.dirname(currentDir);
- if (parentDir === currentDir || !parentDir) {
- // check .env under home as fallback, again preferring gemini-specific .env
- const homeGeminiEnvPath = path.join(os.homedir(), GEMINI_DIR, '.env');
- if (fs.existsSync(homeGeminiEnvPath)) {
- return homeGeminiEnvPath;
- }
- const homeEnvPath = path.join(os.homedir(), '.env');
- if (fs.existsSync(homeEnvPath)) {
- return homeEnvPath;
- }
- return null;
- }
- currentDir = parentDir;
- }
-}
-
-export function loadEnvironment(): void {
- const envFilePath = findEnvFile(process.cwd());
- if (envFilePath) {
- dotenv.config({ path: envFilePath, quiet: true });
- }
-}