google-gemini/gemini-cli · error · Error
Access to the default Cloud Shell Gemini project was denied.
Error message
Access to the default Cloud Shell Gemini project was denied. Please set your own Google Cloud project by running: gcloud config set project [PROJECT_ID] or setting export GOOGLE_CLOUD_PROJECT=...
What it means
Thrown by CodeAssistServer.loadCodeAssist() when the API returns a permission-denied error specifically for the default Cloud Shell project 'cloudshell-gca'. Google Cloud Shell provisions a shared default project for Gemini Code Assist; if the user's account lacks access to it (e.g., org policy restrictions, project disabled, or the user should use their own project), this error directs them to set a personal project via gcloud or the GOOGLE_CLOUD_PROJECT env var.
Source
Thrown at packages/core/src/code_assist/server.ts:284
async loadCodeAssist(
req: LoadCodeAssistRequest,
): Promise<LoadCodeAssistResponse> {
try {
return await this.requestPost<LoadCodeAssistResponse>(
'loadCodeAssist',
req,
);
} catch (e) {
if (isVpcScAffectedUser(e)) {
return {
currentTier: { id: UserTierId.STANDARD },
};
} else if (
isPermissionDeniedError(e) &&
req.cloudaicompanionProject === 'cloudshell-gca'
) {
throw new Error(
'Access to the default Cloud Shell Gemini project was denied.\n' +
'Please set your own Google Cloud project by running:\n' +
'gcloud config set project [PROJECT_ID]\n' +
'or setting export GOOGLE_CLOUD_PROJECT=...',
);
} else {
throw e;
}
}
}
async refreshAvailableCredits(): Promise<void> {
if (!this.paidTier) {
return;
}
const res = await this.loadCodeAssist({
cloudaicompanionProject: this.projectId,
metadata: {View on GitHub (pinned to 5024443c72)
Solutions
- Set your own project: run 'gcloud config set project YOUR_PROJECT_ID'.
- Alternatively, set export GOOGLE_CLOUD_PROJECT=YOUR_PROJECT_ID in your shell.
- Ensure your Google account has the Gemini Code Assist API enabled on your chosen project.
- If in Cloud Shell, verify your project has the necessary APIs enabled via the Cloud Console.
Example fix
# Set your own project before running the CLI gcloud config set project my-project-123 export GOOGLE_CLOUD_PROJECT=my-project-123 # Or set the env var directly export GOOGLE_CLOUD_PROJECT=my-project-123 gemini
Defensive patterns
Strategy: validation
Validate before calling
// Ensure a non-default project is set before using Code Assist in Cloud Shell
function resolveProjectId(): string | undefined {
return (
process.env['GOOGLE_CLOUD_PROJECT'] ||
process.env['GOOGLE_CLOUD_PROJECT_ID'] ||
undefined
);
}
const projectId = resolveProjectId();
if (!projectId || projectId === 'cloudshell-gca') {
throw new Error('Set GOOGLE_CLOUD_PROJECT to your own project ID.');
} Try / catch
try {
await server.loadCodeAssist(req);
} catch (e) {
if (e instanceof Error && e.message.includes('cloudshell-gca')) {
console.error('Cloud Shell default project denied. Run: gcloud config set project YOUR_PROJECT_ID');
process.exit(2);
}
throw e;
} Prevention
- Always set GOOGLE_CLOUD_PROJECT to a personal project in Cloud Shell.
- Run 'gcloud config set project PROJECT_ID' in shell init scripts.
- Ensure the project has the Gemini Code Assist API enabled.
- Avoid relying on the shared 'cloudshell-gca' default project.
When it happens
Trigger: loadCodeAssist() is called with req.cloudaicompanionProject === 'cloudshell-gca' and the API responds with a PERMISSION_DENIED error. The catch block checks isPermissionDeniedError(e) and the project name; if both match, this error is thrown with remediation instructions.
Common situations: Google Cloud Shell users whose organization restricts access to the shared 'cloudshell-gca' project; the default project was quota-capped or disabled; org policies prevent cross-project access; user is in a VPC-SC perimeter that blocks the shared project (though that case is handled separately by isVpcScAffectedUser).
Related errors
- projectId is not defined for CodeAssistServer.
- Invalid Google Cloud Project ID: "${projectId}". The GOOGLE_
- COMPUTE_ADC failed: ${adcMessage}. (LOGIN_WITH_GOOGLE fallba
- ${originalMessage}. The initial COMPUTE_ADC attempt also fai
- Exiting due to a confirmation prompt requested by the comman
AI-assisted analysis of google-gemini/gemini-cli@5024443c72 (2026-08-12).
Data as JSON: /api/errors/b8f0cd1baa8023f1.
Report an issue: GitHub.