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

cdk synth: spawnSync docker ENOENT because cdk is not looking at the right directory #30570

Open
damshenas opened this issue Jun 17, 2024 · 5 comments
Labels
bug This issue is a bug. cli Issues related to the CDK CLI effort/small Small work item – less than a day of effort os/mac Related specifically to MacOS behavior p2 package/tools Related to AWS CDK Tools or CLI

Comments

@damshenas
Copy link

Describe the bug

When using cdk synth to bundle my lambda code (in python) CDK throws spawnSync docker ENOENT

Expected Behavior

cdk to look in the right location /Applications/Docker.app/Contents/Resources/bin/docker or look into possible locations.

Current Behavior

Currently cdk is looking at the wrong directory which caused the confusing error of spawnSync docker ENOENT

Reproduction Steps

OS: Macos 13.6.7 (22G720)
Docker: Docker Desktop 4.31.0 (153195)
CDK: 2.146.0 (b368c78)

new lambda.Function(this, 'myFn', {
      runtime: lambda.Runtime.PYTHON_3_12,
      handler: 'main.handler',
      code: lambda.Code.fromAsset(path.join(__dirname, './src'), {
        bundling: {
          image: lambda.Runtime.PYTHON_3_12.bundlingImage,
          command: [
            'bash', '-c',
            'pip install -r requirements.txt -t /asset-output && cp -au . /asset-output'
          ],
        },
      }),
    });

Possible Solution

ln -s '/Applications/Docker.app/Contents/Resources/bin/docker' '/usr/local/bin/docker'

This will solve the issue.

Additional Information/Context

No response

CDK CLI Version

2.146.0

Framework Version

No response

Node.js Version

v22.1.0

OS

Macos 13.6.7 (22G720)

Language

TypeScript

Language Version

No response

Other information

Searching for this message can be misleading as 99% of people suggesting installing esbuild and things related to that. But the point is this spawnSync xyz ENOENT just means the xyz is missing. I hope this will save some people some time. And the issue is fixed in future.

@damshenas damshenas added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jun 17, 2024
@github-actions github-actions bot added the package/tools Related to AWS CDK Tools or CLI label Jun 17, 2024
@khushail
Copy link
Contributor

Hi @damshenas , thanks for reaching out. I found previously filed similar issue-

Issue - #22997
Suggested solution - #22997 (comment)

Could you please check if this is the exact condition you are running into and the solution might help ??

@khushail khushail added response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. p2 cli Issues related to the CDK CLI and removed needs-triage This issue or PR still needs to be triaged. labels Jun 17, 2024
@khushail khushail self-assigned this Jun 17, 2024
@damshenas
Copy link
Author

Hi @khushail, thanks for the follow up. Short answer is no, it does not help. Long answer is that, unfortunately the solution in the other issue does not fix my problem. In my case, there is nothing needed to be installed. Docker is already there but cdk can not find it. I also posted the solution that worked for me, but I think CDK can do better.

@khushail
Copy link
Contributor

Thanks @damshenas for the confirmation.

@khushail khushail added os/mac Related specifically to MacOS behavior package/tools Related to AWS CDK Tools or CLI effort/small Small work item – less than a day of effort and removed response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. package/tools Related to AWS CDK Tools or CLI labels Jun 17, 2024
@khushail khushail removed their assignment Jun 17, 2024
@pahud
Copy link
Contributor

pahud commented Jun 18, 2024

@damshenas

I guess this is how CDK finds the docker CLI

function getDockerCmd(): string {
return process.env.CDK_DOCKER ?? 'docker';
}

Looks like it won't search /Applications/Docker.app/Contents/Resources/bin/docker

Can you try which docker and see if it returns /Applications/Docker.app/Contents/Resources/bin/docker?

And, is /Applications/Docker.app/Contents/Resources/bin in your $PATH?

@pahud pahud added the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Jun 18, 2024
@damshenas
Copy link
Author

@pahud indeed that path is what which docker returns. It is not in the $PATH. I checked with another laptop (arm) and it also did not have it in the $PATH (but cdk worked fine there). Seems adding those directories to $PATH is not common in Mac.

Logically, adding the path to $PATH should also fix the issue. But ideally CDK should be able to work out of the box on all Macs.

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. cli Issues related to the CDK CLI effort/small Small work item – less than a day of effort os/mac Related specifically to MacOS behavior p2 package/tools Related to AWS CDK Tools or CLI
Projects
None yet
3 participants