pulumi/pulumi · error
could not detect project stack path: %w
Error message
could not detect project stack path: %w
What it means
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.
Source
Thrown at pkg/cmd/pulumi/stack/io.go:64
"github.com/pulumi/pulumi/sdk/v3/go/common/util/cmdutil"
"github.com/pulumi/pulumi/sdk/v3/go/common/util/contract"
"github.com/pulumi/pulumi/sdk/v3/go/common/version"
"github.com/pulumi/pulumi/sdk/v3/go/common/workspace"
)
func LoadProjectStack(
ctx context.Context,
sink diag.Sink,
project *workspace.Project,
stack backend.Stack,
configFile string,
) (*workspace.ProjectStack, error) {
if configFile != "" {
return workspace.LoadProjectStack(sink, project, configFile)
}
project, configFilePath, err := workspace.DetectProjectStackPath(stack.Ref().Name().Q())
if err != nil {
return nil, fmt.Errorf("could not detect project stack path: %w", err)
}
if stack.ConfigLocation().IsRemote {
// Check if the config file also exists and warn if it does.
_, err = os.Stat(configFilePath)
if err != nil && !os.IsNotExist(err) {
return nil, fmt.Errorf("checking if config file %s exists: %v", configFilePath, err)
}
if err == nil {
sink.Warningf(
diag.Message("", "config file %s exists but will be ignored because this stack uses remote config"),
configFilePath,
)
}
return stack.LoadRemoteConfig(ctx, project)
}
return workspace.LoadProjectStack(sink, project, configFilePath)
}
View on GitHub (pinned to 793f7b2e16)
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.
Example fix
// before $ cd /tmp && pulumi config could not detect project stack path: no Pulumi.yaml found // after $ cd ~/my-project # contains Pulumi.yaml $ pulumi config
Defensive patterns
Strategy: validation
Validate before calling
# run commands from the project root or verify Pulumi.yaml exists upward
[ -f Pulumi.yaml ] || { echo 'run from a Pulumi project directory'; exit 1; } Try / catch
if ! pulumi config 2>err.log; then grep -q 'could not detect project stack path' err.log && echo 'cd to project root or pass --config-file' fi
Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- current stack and destination stack are the same
- could not detect current project: %w
- no Pulumi.yaml found; please run this command in a project d
- get Pulumi config: %w
- getting current working directory: %w
AI-assisted analysis of pulumi/pulumi@793f7b2e16 (2026-08-31).
Data as JSON: /api/errors/02a5a47e880a6a66.
Report an issue: GitHub.