pulumi/pulumi · error
project name (--name %s) and stack reference project name (-
Error message
project name (--name %s) and stack reference project name (--stack %s) must be the same
What it means
`pulumi new` lets you pass both `--name` for the project name and `--stack` as a fully qualified stack reference containing its own project component. The CLI requires the project portion of the stack reference to match `--name`, otherwise the generated project and stack would be inconsistent. It refuses to proceed when they differ.
Source
Thrown at pkg/cmd/pulumi/project/newcmd/new.go:896
// No potential for conflicting project names.
return nil
}
// Catch the case where the user has specified a fully qualified stack reference.
ref, err := b.ParseStackReference(stackName)
if err != nil {
// If we can't parse the stack reference, we can't compare the project names.
// We assume the project names don't conflict and that this parsing issue will be handled downstream.
return nil
}
stackProjectName, hasProject := ref.Project()
if !hasProject {
return nil
}
if projectName == stackProjectName.String() {
return nil
}
return fmt.Errorf("project name (--name %s) and stack reference project name (--stack %s) must be the same",
projectName, stackProjectName)
}
View on GitHub (pinned to 793f7b2e16)
Solutions
- Make the project part of `--stack` identical to `--name`, e.g. `--name myproj --stack myorg/myproj/dev`
- Drop `--name` and let it default from the stack reference
- Drop `--stack` and use `--name` alone, choosing the stack interactively
Example fix
// before pulumi new typescript --name myapp --stack myorg/legacy-app/prod // after pulumi new typescript --name myapp --stack myorg/myapp/prod
Defensive patterns
Strategy: validation
Validate before calling
// Validate before invoking the CLI
const stack = "myorg/myapp/dev";
const name = "myapp";
const stackProject = stack.split("/")[1];
if (name !== stackProject) {
throw new Error(`--name (${name}) must match project in --stack (${stackProject})`);
} Try / catch
out, err := exec.Command("pulumi", "new", tpl, "--name", name, "--stack", stack).CombinedOutput()
if err != nil && strings.Contains(string(out), "must be the same") {
// fix args: derive name from stack reference
parts := strings.Split(stack, "/")
name = parts[1]
// retry with corrected name
} Prevention
- Derive --name from the --stack project segment instead of hardcoding both
- Never mix an old stack reference with a renamed project
- Assert name/stack consistency in wrapper scripts before calling pulumi
When it happens
Trigger: Running e.g. `pulumi new <template> --name myproj --stack myorg/otherproj/dev` — the project segment of `--stack` (otherproj) does not equal the `--name` value (myproj).
Common situations: Copy-pasting an existing stack reference while also setting a custom project name; renaming a project but reusing an old `--stack` value; scripting `pulumi new` with independently sourced name/stack values.
Related errors
- unexpected prompt type: %v
- no template selected; please use `pulumi new` to choose one
- no templates
- stack name must not be empty
- organization name must be 'organization'
AI-assisted analysis of pulumi/pulumi@793f7b2e16 (2026-08-31).
Data as JSON: /api/errors/c80d9e7b61a8ebcc.
Report an issue: GitHub.