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 commands fail with error "Subprocess exited with error null" #28637

Closed
ddev1122 opened this issue Jan 9, 2024 · 15 comments
Closed

aws cdk commands fail with error "Subprocess exited with error null" #28637

ddev1122 opened this issue Jan 9, 2024 · 15 comments
Labels
bug This issue is a bug. effort/medium Medium work item – several days of effort p2 python Pull requests that update Python code

Comments

@ddev1122
Copy link

ddev1122 commented Jan 9, 2024

Describe the bug

When I run any cdk command, it fails with the following error and exit code 1:
Subprocess exited with error null
No extra helpful information is printed out.
However, when I use --verbose it raises the following info
Example running cdk ls --verbose
:

[14:56:39] Reading cached notices from /Users/{user}/.cdk/cache/notices.json

Subprocess exited with error null
[14:56:39] Error: Subprocess exited with error null
    at ChildProcess.<anonymous> (/Users/{user}/.nvm/versions/node/v18.19.0/lib/node_modules/aws-cdk/lib/index.js:423:50595)
    at ChildProcess.emit (node:events:517:28)
    at ChildProcess.emit (node:domain:489:12)
    at ChildProcess._handle.onexit (node:internal/child_process:292:12)

Expected Behavior

List stacks or show a more helpful error message.

Current Behavior

Fails with subprocess exited with error null

Reproduction Steps

I have been able to run cdk ls, synth and deploy in other repository's, but not this one

Possible Solution

No response

Additional Information/Context

I have tried different combinations of version of node (20, 14) , npm, and aws-cdk but still running into the same issue.
I am able to run cdk and deploy this same code/repo on a windows machine
I am using pyenv and nvm for version management, and running these cdk commands within a python poetry environment

CDK CLI Version

2.118

Framework Version

No response

Node.js Version

18.19.0

OS

Mac Sonoma 14.2.1

Language

Python

Language Version

3.8.10

Other information

No response

@ddev1122 ddev1122 added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jan 9, 2024
@github-actions github-actions bot added the package/tools Related to AWS CDK Tools or CLI label Jan 9, 2024
@ddev1122 ddev1122 changed the title (module name): (short issue description) aws cdk commands fail with error "Subprocess exited with error null" Jan 9, 2024
@pahud
Copy link
Contributor

pahud commented Jan 10, 2024

I am not sure if this is related to the notice cache(/Users/{user}/.cdk/cache/notices.json) but it should be safe to delete it and run cdk ls -vvv again.

Can you try that and see if it is fixed?

@pahud pahud added p2 effort/medium Medium work item – several days of effort and removed needs-triage This issue or PR still needs to be triaged. labels Jan 10, 2024
@ddev1122
Copy link
Author

Hi, just tried it and still getting the same error. The notices.json just gets recreated each time

@mrgrain
Copy link
Contributor

mrgrain commented Jan 10, 2024

Please run with --debug

The line about notices might be misleading. That's likely just the last thing that worked.

@ddev1122
Copy link
Author

Still immediately exiting with error when running cdk commands
ex.
cdk ls --debug or cdk synth --debug
Subprocess exited with error null

@mrgrain
Copy link
Contributor

mrgrain commented Jan 11, 2024

Still immediately exiting with error when running cdk commands ex. cdk ls --debug or cdk synth --debug Subprocess exited with error null

Sorry I didn't clearly state this before @ddev1122 : Running with --debug will still fail, but can you please post the stack trace when running cdk ls --debug. The --debug stack trace will point us to the actual code point to identify what is going wrong (as opposed to the pretty useless standard stack trace).

@ddev1122
Copy link
Author

Hi Mrgrain, I am not seeing any stack trace.
Immediately after entering those commands
the next line output is
Subprocess exited with error null

@mrgrain
Copy link
Contributor

mrgrain commented Jan 11, 2024

Hmm, @ddev1122 so in your first post you got this stack trace:

[14:56:39] Error: Subprocess exited with error null
    at ChildProcess.<anonymous> (/Users/{user}/.nvm/versions/node/v18.19.0/lib/node_modules/aws-cdk/lib/index.js:423:50595)
    at ChildProcess.emit (node:events:517:28)
    at ChildProcess.emit (node:domain:489:12)
    at ChildProcess._handle.onexit (node:internal/child_process:292:12)

Are you still getting this? But with --debug you get no stack trace?

@ddev1122
Copy link
Author

Correct - if i use --verbose, I get that stack trace, but with --debug, no output is given

@mrgrain
Copy link
Contributor

mrgrain commented Jan 11, 2024

Alright, so apparently you need to run cdk ls -vvv --debug - Apologies, I wrongly assumed that --debug implies verbosity. Could you try that again and post the output?

@ddev1122
Copy link
Author

Sure, here is the output running
cdk ls -vvv -debug

[13:05:54] outdir: cdk.out
[13:05:54] env: {
  CDK_DEFAULT_REGION: 'us-west-2',
  CDK_DEFAULT_ACCOUNT: 'ACCTNUMBER',
  CDK_DEBUG: 'true',
  CDK_OUTDIR: 'cdk.out',
  CDK_CLI_ASM_VERSION: '36.0.0',
  CDK_CLI_VERSION: '2.118.0'
}

[13:05:54] Notices refreshed
[13:05:58] Reading cached notices from /Users/{}/.cdk/cache/notices.json

Subprocess exited with error null
[13:05:59] Error: Subprocess exited with error null
    at ChildProcess.<anonymous> (/Users/{user}/.nvm/versions/node/v18.19.0/lib/node_modules/aws-cdk/lib/api/cxapp/exec.ts:121:23)
    at ChildProcess.emit (node:events:517:28)
    at ChildProcess.emit (node:domain:489:12)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:292:12)

I believe this is the code from the cdk lib thats raising that error (cxapp/exec.js)

    async function exec(commandAndArgs) {
        return new Promise((ok, fail) => {
            // We use a slightly lower-level interface to:
            //
            // - Pass arguments in an array instead of a string, to get around a
            //   number of quoting issues introduced by the intermediate shell layer
            //   (which would be different between Linux and Windows).
            //
            // - Inherit stderr from controlling terminal. We don't use the captured value
            //   anyway, and if the subprocess is printing to it for debugging purposes the
            //   user gets to see it sooner. Plus, capturing doesn't interact nicely with some
            //   processes like Maven.
            const proc = childProcess.spawn(commandAndArgs, {
                stdio: ['ignore', 'inherit', 'inherit'],
                detached: false,
                shell: true,
                env: {
                    ...process.env,
                    ...env,
                },
            });
            proc.on('error', fail);
            proc.on('exit', code => {
                if (code === 0) {
                    return ok();
                }
                else {
                    return fail(new Error(`Subprocess exited with error ${code}`));
                }
            });
        });
    }

@mrgrain
Copy link
Contributor

mrgrain commented Jan 12, 2024

Okay, I think your cdk app doesn't synthesize correctly. Obviously the error should be more helpful.

In the meantime:

  • What is the command for your CDK app? That's the app value in cdk.json.
  • If you run this command directly, does it work? If you get an error, is it more helpful?
  • Are you using a non default synthesizer? If so, can you provide the code snippets how you use it.

mergify bot pushed a commit that referenced this issue Jan 12, 2024
When executing the CDK app program fails, we don't print any useful debug information. This makes sense because we are passing all output from the program to the shell, expecting this would be enough to debug any faults. However the program might be faulty in a way that no (useful) output is printed. To help with this case print the failing command when `--debug` is enabled.

This might require a follow up with a better DX for the generic non debug case. For now this will improve the situation.

Related to #28637

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@ddev1122
Copy link
Author

  • The command being used is python app.py
  • If I run this directly, I am getting a Segmentation fault: 11 (not sure if this is any more helpful)
  • We are using the default synthesizer

@mrgrain
Copy link
Contributor

mrgrain commented Jan 12, 2024

  • If I run this directly, I am getting a Segmentation fault: 11 (not sure if this is any more helpful)

It tells us the following:

  • The issue is not with the AWS CDK CLI
  • The issue is within Python

I'm not a Python expert, but found this when googling, maybe it's https://blog.richard.do/2018/03/18/how-to-debug-segmentation-fault-in-python/

You can probably use standard debugging techniques to find the offending code.

I have been able to run cdk ls, synth and deploy in other repository's, but not this one

Do you know if this ever worked?

@mrgrain mrgrain added python Pull requests that update Python code and removed package/tools Related to AWS CDK Tools or CLI labels Jan 12, 2024
@ddev1122
Copy link
Author

Finally got the commands to run..
I upgraded python from 3.8.10 to 3.12 and updated some of the package dependencies...that seemed to do it
Thanks for your help.

Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

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/medium Medium work item – several days of effort p2 python Pull requests that update Python code
Projects
None yet
Development

No branches or pull requests

3 participants