Skip to content

aws-cdk: cdk synth/deploy command fails with "C:\Program" is not recognized as an internal or external command #636

Open
@saste

Description

@saste

Describe the bug

Short log:

PS1> cdk synth --all --app MyApp\dist\bin\app.js

'C:\Program' is not recognized as an internal or external command,
operable program or batch file.

Subprocess exited with error 1

This happens every time I try to run cdk from a Powershell terminal, same happens when run from a cmd terminal.

Debug log:

PS1> cdk --version
2.43.1 (build c1ebb85)
PS1> node --version
v16.15.0
PS1> npm --version
8.13.1
PS1> cdk --verbose --debug synth --all --app C:\Users\sabatin\MyApp\dist\bin\app.js
CDK toolkit version: 2.43.1 (build c1ebb85)
Command line arguments: {
  _: [ 'synth' ],
  verbose: 1,
  v: 1,
  debug: true,
  all: true,
  app: 'C:\\Users\\sabatin\\MyApp\\dist\\bin\\app.js',
  a: 'C:\\Users\\sabatin\\MyApp\\dist\\bin\\app.js',
  lookups: true,
  'ignore-errors': false,
  ignoreErrors: false,
  json: false,
  j: false,
  ec2creds: undefined,
  i: undefined,
  'version-reporting': undefined,
  versionReporting: undefined,
  'path-metadata': true,
  pathMetadata: true,
  'asset-metadata': true,
  assetMetadata: true,
  'role-arn': undefined,
  r: undefined,
  roleArn: undefined,
  staging: true,
  'no-color': false,
  noColor: false,
  ci: false,
  validation: true,
  quiet: false,
  q: false,
  '$0': '..\\..\\AppData\\Roaming\\npm\\node_modules\\aws-cdk\\bin\\cdk'
}
cdk.json: {
  "app": "node dist/bin/app",
  "context": {
    "@aws-cdk/core:newStyleStackSynthesis": true,
    "@aws-cdk/aws-ec2:uniqueImdsv2TemplateName": true
  },
  "output": "cdk.out"
}
merged settings: {
  versionReporting: true,
  pathMetadata: true,
  output: 'cdk.out',
  app: 'C:\\Users\\sabatin\\MyApp\\dist\\bin\\app.js',
  context: {
    '@aws-cdk/core:newStyleStackSynthesis': true,
    '@aws-cdk/aws-ec2:uniqueImdsv2TemplateName': true
  },
  debug: true,
  assetMetadata: true,
  toolkitBucket: {},
  staging: true,
  bundlingStacks: [ '*' ],
  lookups: true
}
Determining if we're on an EC2 instance.
Reading cached notices from C:\Users\sabatin\.cdk\cache\notices.json
Does not look like an EC2 instance.
Toolkit stack: CDKToolkit
Setting "CDK_DEFAULT_REGION" environment variable to eu-west-1
Resolving default credentials
Retrieved account ID XXXXX from disk cache
Setting "CDK_DEFAULT_ACCOUNT" environment variable to XXXXX
context: {
  '@aws-cdk/core:newStyleStackSynthesis': true,
  '@aws-cdk/aws-ec2:uniqueImdsv2TemplateName': true,
  'aws:cdk:enable-path-metadata': true,
  'aws:cdk:enable-asset-metadata': true,
  'aws:cdk:version-reporting': true,
  'aws:cdk:bundling-stacks': [ '*' ]
}
outdir: cdk.out
env: {
  CDK_DEFAULT_REGION: 'eu-west-1',
  CDK_DEFAULT_ACCOUNT: 'XXXXX',
  CDK_DEBUG: 'true',
  CDK_CONTEXT_JSON: '{"@aws-cdk/core:newStyleStackSynthesis":true,"@aws-cdk/aws-ec2:uniqueImdsv2TemplateName":true,"aws:cdk:enable-path-metadata":true,"aws:cdk:enable-asset-metadata":true,"aws:cdk:version-reporting":true,"aws:cdk:bundling-stacks":["*"]}',
  CDK_OUTDIR: 'cdk.out',
  CDK_CLI_ASM_VERSION: '21.0.0',
  CDK_CLI_VERSION: '2.43.1'
}
'C:\Program' is not recognized as an internal or external command,
operable program or batch file.
Reading cached notices from C:\Users\sabatin\.cdk\cache\notices.json

Subprocess exited with error 1
Error: Subprocess exited with error 1
    at ChildProcess.<anonymous> (C:\Users\sabatin\AppData\Roaming\npm\node_modules\aws-cdk\lib\api\cxapp\exec.ts:131:23)
    at ChildProcess.emit (node:events:527:28)
    at ChildProcess.emit (node:domain:475:12)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12)

Note also that the exec.ts file is missing:

C:\Users\sabatin\AppData\Roaming\npm\node_modules\aws-cdk\lib\api\cxapp\exec.ts

although the corresponding exec.js file is there (tried to edit but it's not affecting the output of the command). What is this exec.ts file about and why is it missing?

Possibly related to:
sst/sst#73

BTW adding more logs would be useful to diagnose the issue.

Expected Behavior

The command should not fail.

Current Behavior

The command fail.

Reproduction Steps

See above.

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.43.1 (build c1ebb85)

Framework Version

No response

Node.js Version

v16.15.0

OS

Windows

Language

Typescript

Language Version

No response

Other information

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions