{"record":{"id":"e56c331e748b473e","repo":"pulumi/pulumi","slug":"opening-environment-w","errorCode":null,"errorMessage":"opening environment: %w","messagePattern":"opening environment: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/cmd/pulumi/config/io.go","lineNumber":140,"sourceCode":"\n\tconfig, err := getStackConfigurationFromProjectStack(ctx, s, project, sm, workspaceStack, envOverrides)\n\tif err != nil {\n\t\treturn backend.StackConfiguration{}, nil, err\n\t}\n\treturn config, sm, nil\n}\n\nfunc getStackConfigurationFromProjectStack(\n\tctx context.Context,\n\tstack backend.Stack,\n\tproject *workspace.Project,\n\tsm secrets.Manager,\n\tworkspaceStack *workspace.ProjectStack,\n\tenvOverrides []string,\n) (backend.StackConfiguration, error) {\n\tenv, diags, err := openStackEnv(ctx, stack, workspaceStack, envOverrides)\n\tif err != nil {\n\t\treturn backend.StackConfiguration{}, fmt.Errorf(\"opening environment: %w\", err)\n\t}\n\tif len(diags) != 0 {\n\t\t// This is a non-command helper; we don't have a *cobra.Command writer\n\t\t// to thread through here. Writes go to the process streams directly.\n\t\tprintESCDiagnostics(os.Stderr, diags) //nolint:forbidigo\n\t\treturn backend.StackConfiguration{}, errors.New(\"opening environment: too many errors\")\n\t}\n\n\tvar pulumiEnv esc.Value\n\tif env != nil {\n\t\twarnOnNoEnvironmentEffects(os.Stdout, env) //nolint:forbidigo\n\n\t\tpulumiEnv = env.Properties[\"pulumiConfig\"]\n\n\t\t_, environ, secrets, _, err := cli.PrepareEnvironment(env, nil)\n\t\tif err != nil {\n\t\t\treturn backend.StackConfiguration{}, fmt.Errorf(\"preparing environment: %w\", err)\n\t\t}","sourceCodeStart":122,"sourceCodeEnd":158,"githubUrl":"https://github.com/pulumi/pulumi/blob/793f7b2e160db4321fb7fb6b0607461e01cb251e/pkg/cmd/pulumi/config/io.go#L122-L158","documentation":"getStackConfigurationFromProjectStack wraps any failure from openStackEnv with 'opening environment: %w'. It means the Pulumi Cloud/ESC environment referenced by the stack (via `environment:` in Pulumi.yaml or --env overrides) could not be opened — org not resolvable, backend lacks environment support, or the environment definition failed to load/compile.","triggerScenarios":"getStackConfigurationWithFallback → getStackConfigurationFromProjectStack with a stack whose workspaceStack defines an ESC environment: the stack's backend does not implement EnvironmentsBackend, the stack has no OrgName, the referenced YAML environment doesn't exist, or it fails YAML/ESC evaluation at open time.","commonSituations":"Using `pulumi config` commands against a stack in a backend (e.g. some self-hosted setups) without ESC environment support; typo'd or removed environment name in Pulumi.yaml; running against a stack not associated with an organization; network/permission failures fetching the environment from Pulumi Cloud.","solutions":["Check the `environment:` entry in Pulumi.yaml points to an existing ESC environment in the correct org (`pulumi env ls` in the org)","Verify you are logged into the Pulumi Cloud backend — ESC environments require it","Confirm the org the stack belongs to is correct; re-create or re-select the stack if OrgName cannot be determined","Inspect stderr diagnostics printed by printESCDiagnostics for the underlying ESC error"],"exampleFix":"// before (Pulumi.yaml)\nenvironment:\n  my-env-prod\n// after\nenvironment:\n  myorg/my-env-prod","handlingStrategy":"validation","validationCode":"# before running config commands\npulumi env ls --org myorg            # environment exists?\ngrep -A2 'environment:' Pulumi.yaml  # reference matches org/name","typeGuard":"func supportsEnvs(b backend.Backend) bool {\n    _, ok := b.(backend.EnvironmentsBackend)\n    return ok\n}","tryCatchPattern":"cfg, err := getStackConfigurationFromProjectStack(...)\nif err != nil && strings.HasPrefix(err.Error(), \"opening environment:\") {\n    return fmt.Errorf(\"check `environment:` in Pulumi.yaml and ESC access: %w\", err)\n}","preventionTips":["Only use ESC environments with the Pulumi Cloud backend","Reference environments as org/name and confirm they exist via `pulumi env ls`","Test environments standalone with `pulumi env open`","Confirm you are a member of the target org with environment access"],"tags":["esc","environment","config"],"backgroundTag":"esc-environment-open-failed","analyzedSha":"793f7b2e160db4321fb7fb6b0607461e01cb251e","analyzedAt":"2026-08-31T09:36:43.099Z","schemaVersion":2},"datasetVersion":"2026-09-01T08:17:40.651Z"}