fix(cli): Exit CLI when trust save unsuccessful during launch (#11968)

This commit is contained in:
shrutip90
2025-11-14 11:56:39 -08:00
committed by GitHub
parent 6d83d3440c
commit d683e1c0db
7 changed files with 174 additions and 30 deletions
+14 -1
View File
@@ -14,6 +14,7 @@ import {
} from '../../config/trustedFolders.js';
import * as process from 'node:process';
import { type HistoryItemWithoutId, MessageType } from '../types.js';
import { coreEvents } from '@google/gemini-cli-core';
export const useFolderTrust = (
settings: LoadedSettings,
@@ -67,7 +68,19 @@ export const useFolderTrust = (
return;
}
trustedFolders.setValue(cwd, trustLevel);
try {
trustedFolders.setValue(cwd, trustLevel);
} catch (_e) {
coreEvents.emitFeedback(
'error',
'Failed to save trust settings. Exiting Gemini CLI.',
);
setTimeout(() => {
process.exit(1);
}, 100);
return;
}
const currentIsTrusted =
trustLevel === TrustLevel.TRUST_FOLDER ||
trustLevel === TrustLevel.TRUST_PARENT;