pulumi module shows no stack on Pulumi v3.256.0 and later
Bug Report
Current Behavior
The pulumi module renders an empty $stack on Pulumi v3.256.0 and later.
Expected Behavior
$stack shows the selected stack, as it does on Pulumi v3.255.0 and earlier.
Additional context/Screenshots
pulumi/pulumi#23974 ("fix(cli): scope current stack selection to the active backend", first released in v3.256.0) changed the workspace settings file so that the selected stack is scoped to the backend it belongs to:
// ~/.pulumi/workspaces/<project>-<sha1>-workspace.json, before
{
"stack": "acme/infra/dev"
}
// after
{
"stacks": {
"https://api.pulumi.com": "acme/infra/dev"
}
}
The old stack key is still read by Pulumi for backwards compatibility, but it is no longer written — from the comment on Settings in pkg/workspace/settings.go:
Deprecated: Prefer Stacks[backendURL]. Kept so older workspace.json files continue to load; new writes use Stacks.
So the prompt keeps working after the upgrade until the first pulumi stack select, and then goes quiet.
src/modules/pulumi.rs only knows about the old key:
workspace
.as_object()?
.get("stack")?
.as_str()
.map(ToString::to_string)
Possible Solution
Read stacks[<backend url>], resolving the active backend the way the CLI does (PULUMI_BACKEND_URL, then the project's backend.url, then current in credentials.json), and keep the old stack key as a fallback for workspace files that have not been rewritten yet. Happy to open a PR.
Environment
- Starship version: 1.26.0
- Shell type: zsh
- Shell version: 5.9
- Shell plugin manager: none
- Terminal emulator: n/a — the module is shell and terminal independent
- Operating system: macOS 26.5.2
- Pulumi version: 3.256.0+
Relevant Shell Configuration
eval "$(starship init zsh)"
Starship Configuration
[pulumi]
format = '[$symbol$stack\(@$username\)]($style) '
style = 'bold fg:#F4B321'
Source: starship/starship