{"record":{"id":"a139bcacc712708b","repo":"pulumi/pulumi","slug":"could-not-determine-current-cloud-w-a139bc","errorCode":null,"errorMessage":"could not determine current cloud: %w","messagePattern":"could not determine current cloud: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/cmd/pulumi/auth/logout.go","lineNumber":105,"sourceCode":"\t\t\t\tif cloudURL == \"\" {\n\t\t\t\t\tcwd, err := os.Getwd()\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn fmt.Errorf(\"getting current working directory: %w\", err)\n\t\t\t\t\t}\n\n\t\t\t\t\t// Try to read the current project\n\t\t\t\t\tproject, _, err := ws.ReadProject(cwd)\n\t\t\t\t\tif err != nil && !errors.Is(err, workspace.ErrProjectNotFound) {\n\t\t\t\t\t\treturn err\n\t\t\t\t\t}\n\n\t\t\t\t\tcloudURL, err = pkgWorkspace.GetCurrentCloudURLWithAgentFallback(ws, env.Global(), project)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t// Removing everything does not require reading the file.\n\t\t\t\t\t\tif workspace.IsUndecryptableCredentials(err) {\n\t\t\t\t\t\t\treturn logOutOfEverything()\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn fmt.Errorf(\"could not determine current cloud: %w\", err)\n\t\t\t\t\t}\n\n\t\t\t\t\t// Default to the default cloud URL. This means a `pulumi logout` will delete the\n\t\t\t\t\t// credentials for pulumi.com if there's no \"current\" user set in the credentials file.\n\t\t\t\t\tcloudURL = httpstate.ValueOrDefaultURL(ws, cloudURL)\n\t\t\t\t}\n\n\t\t\t\terr = deleteAccount(cloudURL)\n\t\t\t\tif workspace.IsUndecryptableCredentials(err) {\n\t\t\t\t\treturn logOutOfEverything()\n\t\t\t\t}\n\t\t\t\tfmt.Fprintf(cmd.OutOrStdout(), \"Logged out of %s\\n\", cloudURL)\n\t\t\t}\n\n\t\t\treturn err\n\t\t},\n\t}\n","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/pulumi/pulumi/blob/793f7b2e160db4321fb7fb6b0607461e01cb251e/pkg/cmd/pulumi/auth/logout.go#L87-L123","documentation":"With no URL/flag, logout infers the current cloud from the project and credentials via GetCurrentCloudURLWithAgentFallback. If that inference fails for any reason other than undecryptable credentials, the error is wrapped as 'could not determine current cloud'.","triggerScenarios":"Running `pulumi logout` outside a Pulumi project with no default cloud URL set in the credentials file (e.g. never ran `pulumi login`), or a backend that errors while resolving the current cloud (PULUMI_BACKEND_URL issues, corrupted credentials file).","commonSituations":"Fresh machines or CI containers with no `pulumi login` state; running in a non-project directory; stale PULUMI_BACKEND_URL pointing at an unreachable backend.","solutions":["Log in first (`pulumi login`) or pass the URL explicitly: `pulumi logout <url>`","Use `pulumi logout --all` to clear all stored credentials without needing to resolve a current cloud","cd into a valid Pulumi project directory so the cloud can be inferred from Pulumi.yaml","Unset or fix PULUMI_BACKEND_URL if it points somewhere invalid"],"exampleFix":"// before\npulumi logout   # in a non-project dir with no login state\n// after\npulumi logout --all","handlingStrategy":"fallback","validationCode":"// shell: verify login state before bare logout\nif [ ! -f ~/.pulumi/credentials.json ] && [ ! -f Pulumi.yaml ]; then\n  echo \"no login state and no project; use: pulumi logout <url> or --all\"; exit 1\nfi","typeGuard":null,"tryCatchPattern":"// fallback to explicit URL when current cloud can't be determined\nif ! pulumi logout; then\n  pulumi logout \"${PULUMI_URL:-https://api.pulumi.com}\"\nfi","preventionTips":["Run `pulumi login` before relying on inferred cloud state","Keep a project (Pulumi.yaml) present when calling bare `pulumi logout`","Check PULUMI_BACKEND_URL points at a reachable backend","Use `pulumi logout --all` in CI where no project context exists"],"tags":["cli","backend","logout","cloud-url"],"backgroundTag":"no-backend-configured","analyzedSha":"793f7b2e160db4321fb7fb6b0607461e01cb251e","analyzedAt":"2026-08-31T09:36:43.099Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}