https://pulumi.com logo
#general
Title
# general
s

salmon-match-99387

02/10/2023, 1:24 PM
[Solved] I’m trying to use Pulumi Automation API using NodeJS, but I can’t get past the following problem; namely when I run the automation part I get the error below. The “automation” script is more or less an exact copy of this https://github.com/pulumi/automation-api-examples/blob/main/nodejs/localProgram-tsnode/automation/index.ts For some reason Automation API fails to find pulumi executable (or that’s how I interpret this error). Running,
pulumi version --non-interactive
by hand works just fine. I got python based examples work, so it seems that the issue is somehow related to nodejs. Running macos.
Copy code
./node_modules/ts-node/dist/bin.js index.ts

❯ ./node_modules/ts-node/dist/bin.js index.ts
CommandError: code: -2
 stdout:
 stderr: Command failed with ENOENT: pulumi version --non-interactive
spawn /bin/sh ENOENT
 err?: Error: Command failed with ENOENT: pulumi version --non-interactive
spawn /bin/sh ENOENT

    at Object.createCommandError (/Users/massive/code/provisioner/provisioner/node_modules/@pulumi/automation/errors.ts:75:27)
    at Object.<anonymous> (/Users/massive/code/provisioner/provisioner/node_modules/@pulumi/automation/cmd.ts:79:15)
    at Generator.throw (<anonymous>)
    at rejected (/Users/massive/code/provisioner/provisioner/node_modules/@pulumi/pulumi/automation/cmd.js:19:65)
    at processTicksAndRejections (node:internal/process/task_queues:95:5) {
  commandResult: CommandResult {
    stdout: '',
    stderr: 'Command failed with ENOENT: pulumi version --non-interactive\n' +
      'spawn /bin/sh ENOENT',
    code: -2,
    err: Error: Command failed with ENOENT: pulumi version --non-interactive
    spawn /bin/sh ENOENT
        at Process.ChildProcess._handle.onexit (node:internal/child_process:283:19)
        at onErrorNT (node:internal/child_process:476:16)
        at processTicksAndRejections (node:internal/process/task_queues:82:21) {
      errno: -2,
      code: 'ENOENT',
      syscall: 'spawn /bin/sh',
      path: '/bin/sh',
      spawnargs: [Array],
      originalMessage: 'spawn /bin/sh ENOENT',
      shortMessage: 'Command failed with ENOENT: pulumi version --non-interactive\n' +
        'spawn /bin/sh ENOENT',
      command: 'pulumi version --non-interactive',
      escapedCommand: 'pulumi version --non-interactive',
      exitCode: undefined,
      signal: undefined,
      signalDescription: undefined,
      stdout: '',
      stderr: '',
      failed: true,
      timedOut: false,
      isCanceled: false,
      killed: false
    }
  }
}
🦆 Right after my message I made a last look at my script and realized that it had a
workDir
attribute pointing to a invalid directory. Fixing that got the script working. The error message was quite wild, because it had nothing to do with the actual problem.
233 Views