pulumi / pulumi/pulumi-java

"failed to discover package requirements" when using PULUMI_RUN_PROGRAM=true

Open
#1,938 12 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

kind/bug
Dominant language
Java
Stars
85
Forks
26
Avg merge
11h 49m
Merged PRs (30d)
22

Description

What happened?

I have recreated my problem here: Se https://github.com/anderius/pulumi-run-program/blob/main/src/main/kotlin/org/example/App.kt#L30

I am new to Pulumi, and I am using it to configure resources in GitHub (and other places). My users can configure stuff in a user interface, and I save the configuration in a database. Then I use Pulumi to apply that configuration to the cloud infrastructure.

To support changing the credentials used, I have understood that I have to use PULUMI_RUN_PROGRAM=true (see https://github.com/pulumi/pulumi/issues/4981). This fails, see the attached example.

Example

Se here: https://github.com/anderius/pulumi-run-program

In short, this is how I run the program:

val program = PulumiProgram()

            LocalWorkspace.createOrSelectStack(
                "inline_project_java", "my_stack", program::program,
                LocalWorkspaceOptions.builder()
                    .environmentVariables(
                        mapOf(
                            "PULUMI_BACKEND_URL" to "file:./pulumi_backend",
                            "PULUMI_CONFIG_PASSPHRASE" to "we-don't-care-about-encryption-here",
                            // Change this to "true" to re-create the error:
                            "PULUMI_RUN_PROGRAM" to "false",
                        ),
                    )
                    .build(),
            ).use { stack ->
                stack.refresh(
                    RefreshOptions.builder()
                        .onStandardOutput(::println)
                        .onStandardError(::println)
                        .build(),
                )
            }

This works:

Refreshing (my_stack):

Resources:

Duration: 1s

Changing PULUMI_RUN_PROGRAM to "true" (needed when I run with credentials), it fails with the following error:

Refreshing (my_stack):
error: failed to discover package requirements: language host could not determine Pulumi packages: could not find ./sbt, sbt on the $PATH: exec: "sbt": executable file not found in $PATH
2 actionable tasks: 1 executed, 1 from cache
Exception in thread "main" com.pulumi.automation.CommandException: code: 255
stdout: Refreshing (my_stack):

stderr: error: failed to discover package requirements: language host could not determine Pulumi packages: could not find ./sbt, sbt on the $PATH: exec: "sbt": executable file not found in $PATH


	at com.pulumi.automation.LocalPulumiCommand.createExceptionFromResult(LocalPulumiCommand.java:336)
	at com.pulumi.automation.LocalPulumiCommand.runInternal(LocalPulumiCommand.java:245)
	at com.pulumi.automation.LocalPulumiCommand.run(LocalPulumiCommand.java:157)
	at com.pulumi.automation.Workspace.runCommand(Workspace.java:562)
	at com.pulumi.automation.WorkspaceStack.runCommand(WorkspaceStack.java:913)
	at com.pulumi.automation.WorkspaceStack.refresh(WorkspaceStack.java:696)
	at org.example.App.main(App.kt:35)
Output of pulumi about

CLI
Version 3.209.0
Go Version go1.25.4
Go Compiler gc

Host
OS darwin
Version 15.7.2
Arch arm64

Additional context

No response

Contributing

Vote on this issue by adding a 👍 reaction.
To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the reproduction in src/main/kotlin/org/example/App.kt, especially the LocalWorkspace.createOrSelectStack call and the PULUMI_RUN_PROGRAM=true path. Run the example and trace the package-requirements discovery that reports the missing sbt executable. Done means the refresh succeeds with PULUMI_RUN_PROGRAM=true in the provided reproduction without requiring an unavailable sbt command.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, kotlin
Domain
infrastructure, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.