Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
saste opened this issue Nov 26, 2022 · 3 comments
Labels
bug This issue is a bug. effort/small Small work item – less than a day of effort p1 package/tools Related to AWS CDK Tools or CLI

Comments

@saste
Copy link

saste commented Nov 26, 2022

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

@saste saste added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Nov 26, 2022
@github-actions github-actions bot added the package/tools Related to AWS CDK Tools or CLI label Nov 26, 2022
@peterwoodworth
Copy link
Contributor

This issue appears to be the same, it is reported here that the issue is that node is in Program Files directory #9384

@peterwoodworth peterwoodworth added p2 effort/small Small work item – less than a day of effort and removed needs-triage This issue or PR still needs to be triaged. labels Nov 28, 2022
@saste
Copy link
Author

saste commented Nov 28, 2022

This issue appears to be the same, it is reported here that the issue is that node is in Program Files directory #9384

Confirm it looks the same, still the issue is still existing (feel free to close this one and reopen the old one). It might be that the problem is not really about cdk but about node itself, but this needs to be root-caused.

Also, do you have advice about this?

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?

@edwardaskew
Copy link

edwardaskew commented Nov 30, 2022

I ran into this and did some digging through the source code and git history:

I think this is actually a regression caused by #17176 which seemed to ignore the big scary comment right above the childProcess.spawn call that explained why they originally used an array of arguments rather than a string...

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?

exec.ts is the original typescript source file, it gets transpiled into exec.js as part of the build process.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. effort/small Small work item – less than a day of effort p1 package/tools Related to AWS CDK Tools or CLI
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants