{"record":{"id":"02a5a47e880a6a66","repo":"pulumi/pulumi","slug":"could-not-detect-project-stack-path-w","errorCode":null,"errorMessage":"could not detect project stack path: %w","messagePattern":"could not detect project stack path: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/cmd/pulumi/stack/io.go","lineNumber":64,"sourceCode":"\t\"github.com/pulumi/pulumi/sdk/v3/go/common/util/cmdutil\"\n\t\"github.com/pulumi/pulumi/sdk/v3/go/common/util/contract\"\n\t\"github.com/pulumi/pulumi/sdk/v3/go/common/version\"\n\t\"github.com/pulumi/pulumi/sdk/v3/go/common/workspace\"\n)\n\nfunc LoadProjectStack(\n\tctx context.Context,\n\tsink diag.Sink,\n\tproject *workspace.Project,\n\tstack backend.Stack,\n\tconfigFile string,\n) (*workspace.ProjectStack, error) {\n\tif configFile != \"\" {\n\t\treturn workspace.LoadProjectStack(sink, project, configFile)\n\t}\n\tproject, configFilePath, err := workspace.DetectProjectStackPath(stack.Ref().Name().Q())\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"could not detect project stack path: %w\", err)\n\t}\n\tif stack.ConfigLocation().IsRemote {\n\t\t// Check if the config file also exists and warn if it does.\n\t\t_, err = os.Stat(configFilePath)\n\t\tif err != nil && !os.IsNotExist(err) {\n\t\t\treturn nil, fmt.Errorf(\"checking if config file %s exists: %v\", configFilePath, err)\n\t\t}\n\t\tif err == nil {\n\t\t\tsink.Warningf(\n\t\t\t\tdiag.Message(\"\", \"config file %s exists but will be ignored because this stack uses remote config\"),\n\t\t\t\tconfigFilePath,\n\t\t\t)\n\t\t}\n\t\treturn stack.LoadRemoteConfig(ctx, project)\n\t}\n\treturn workspace.LoadProjectStack(sink, project, configFilePath)\n}\n","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/pulumi/pulumi/blob/793f7b2e160db4321fb7fb6b0607461e01cb251e/pkg/cmd/pulumi/stack/io.go#L46-L82","documentation":"When loading a project stack without an explicit --config-file, Pulumi calls workspace.DetectProjectStackPath to locate the stack's YAML file by searching upward for Pulumi.yaml and matching the stack name. Failure (no project file found, malformed project, or unresolvable stack) is wrapped as 'could not detect project stack path'. The command cannot proceed without knowing where the stack's configuration lives.","triggerScenarios":"Running a stack command (e.g. `pulumi config`, `pulumi stack export`) outside a Pulumi project directory, with a corrupt/invalid Pulumi.yaml, or referencing a stack name that cannot be mapped to a file when no configFile flag was supplied.","commonSituations":"Running the CLI in a subdirectory outside the project root without Pulumi.yaml present upward; CI checkout that omits Pulumi.yaml; renamed project/stack so detection no longer matches; typo'd stack name.","solutions":["cd into the project directory (or a subdirectory of it) that contains Pulumi.yaml.","Pass the config file explicitly with --config-file path/to/Pulumi.<stack>.yaml.","Fix or restore Pulumi.yaml if it is malformed or missing (`pulumi new` or git restore).","Verify the stack name with `pulumi stack ls` and select the correct one."],"exampleFix":"// before\n$ cd /tmp && pulumi config\ncould not detect project stack path: no Pulumi.yaml found\n// after\n$ cd ~/my-project   # contains Pulumi.yaml\n$ pulumi config","handlingStrategy":"validation","validationCode":"# run commands from the project root or verify Pulumi.yaml exists upward\n[ -f Pulumi.yaml ] || { echo 'run from a Pulumi project directory'; exit 1; }","typeGuard":null,"tryCatchPattern":"if ! pulumi config 2>err.log; then\n  grep -q 'could not detect project stack path' err.log && echo 'cd to project root or pass --config-file'\nfi","preventionTips":["Always run pulumi commands from inside the project directory","Commit Pulumi.yaml so CI checkouts include it","Pass --config-file explicitly in scripts that may run from other directories","Verify stack names with `pulumi stack ls` before referencing them"],"tags":["cli","stack","project-detection","workspace","config"],"backgroundTag":"project-not-found","analyzedSha":"793f7b2e160db4321fb7fb6b0607461e01cb251e","analyzedAt":"2026-08-31T09:36:43.099Z","schemaVersion":2},"datasetVersion":"2026-09-01T08:17:40.651Z"}