Skip to content

Cloud Code in Devcontainer ignores mounted gcloud credentials and GOOGLE_APPLICATION_CREDENTIALS #1208

@udaya2899

Description

@udaya2899

Environment:
Version information

Cloud Code Extension version: 2.37.0

VSCode version: Version: 1.109.2 (Universal)
Commit: 591199df409fbf59b4b52d5ad4ee0470152a9b31

OS: Linux (Devcontainer) / Host: Linux (Google Cloudtop)

Cloud SDK: System installed (Managed from cloudtop)

Skaffold: N/A

Kubectl: v1.35.1

Description: I am running VS Code in a Devcontainer where I have mounted my host's valid gcloud configuration and authenticated credentials. Despite configuring the extension to use the system gcloud and explicitly setting GOOGLE_APPLICATION_CREDENTIALS, the extension fails to pick up the credentials at startup, remains in a "Not signed in" state, and spams 401 errors for its internal API calls.

Observed Behavior:

  • gcloud auth list inside the container shows the account is ACTIVE.
  • GOOGLE_APPLICATION_CREDENTIALS is set and points to a valid application_default_credentials.json file (verified readable).
  • Cloud Code logs immediately show a 401 error for cloudcode-pa.googleapis.com and the status bar asks to sign in.
[INFO]: Cloud Code version 2.37.0
[ERROR]: Unsuccessful http request to https://cloudcode-pa.googleapis.com/v1internal:listExperiments.
Response: {"error":{"code":401,"message":"Request is missing required authentication credential. Expected OAuth 2 access token...

Repro step:

  1. Setup a .devcontainer that mounts the host's ~/.config/gcloud to the container (e.g., via a bind mount to /etc/user-host-config and symlinking or setting env vars).
  2. Configure devcontainer.json to disable auto-dependencies:
    "customizations": {
       "vscode": {
        "settings": {
          "cloudcode.autoDependencies": "off",
          "cloudcode.dependencyPaths": { "gcloud": "/usr/bin/gcloud" }
        }
      }
    }
    
  3. Set the environment variable in devcontainer.json:
    "remoteEnv": {
      "GOOGLE_APPLICATION_CREDENTIALS": "/etc/user-host-config/gcloud/application_default_credentials.json"
    }
    
  4. Rebuild and open the Devcontainer.
  5. Observe that gcloud CLI works fine, but the Extension fails to authenticate.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions