question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

cli: synth fails if cdk.out does not exist

See original GitHub issue

🐛 Bug Report

What is the problem?

cdk synth returns ENOENT: no such file or directory, open 'cdk.out/manifest.json' when the cdk.out directory is not present.

However, this results in the creation of a default manifest.json, and subsequent calls to synth succeed

Reproduction Steps

from cdk project directory:

  1. mvn clean
  2. rm -rf cdk.out
  3. mvn compile
  4. cdk synth

Verbose Log

xxxxxxxxx:cdk xxxxxxxx$ ls
cdk.json        cdk.out         pom.xml         src             target
xxxxxxxxx:cdk xxxxxxxx$ mvn clean
[INFO] Scanning for projects...
[INFO] 
[INFO] -------------------< com.xxx.xxx:project >--------------------
[INFO] Building project 0.1
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ project ---
[INFO] Deleting /Users/xxxxxxxx/workspace/xxxxxxxx/cdk/target
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.303 s
[INFO] Finished at: 2019-08-19T16:27:07-07:00
[INFO] ------------------------------------------------------------------------
xxxxxxxxx:cdk xxxxxxxx$ rm -rf cdk.out
xxxxxxxxx:cdk xxxxxxxx$ mvn compile
[INFO] Scanning for projects...
[INFO] 
[INFO] -------------------< com.xxx.xxx:project >--------------------
[INFO] Building project 0.1
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ project ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/xxxxxxxx/workspace/xxxxxxxx/cdk/src/main/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.7.0:compile (default-compile) @ project ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 3 source files to /Users/xxxxxxxx/workspace/xxxxxxxx/cdk/target/classes
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.835 s
[INFO] Finished at: 2019-08-19T16:27:24-07:00
[INFO] ------------------------------------------------------------------------
xxxxxxxxx:cdk xxxxxxxx$ cdk synth
[INFO] Scanning for projects...
[INFO] 
[INFO] -------------------< com.xxx.xxx:project >--------------------
[INFO] Building project 0.1
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- exec-maven-plugin:1.6.0:java (default-cli) @ project ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.574 s
[INFO] Finished at: 2019-08-19T16:27:31-07:00
[INFO] ------------------------------------------------------------------------
ENOENT: no such file or directory, open 'cdk.out/manifest.json'

Environment

  • CDK CLI Version: 1.4.0 (build 175471f)
  • Module Version:
  • OS: OSX Mojave
  • Language: Java

Other information

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:12
  • Comments:16 (5 by maintainers)

github_iconTop GitHub Comments

10reactions
nija-atcommented, Jan 8, 2020

Thanks to @ivoanjo who also had this problem, I’m able to reproduce this in Java.

I was able to reproduce this using our standard sample-app package from cdk init -l=java and modify the code to drop app.synth(). Running cdk synth on this when there’s no cdk.out/ folder gets this error.

There seems to be some race condition between the cdk.out/ folder being generated and when the CLI expects it to be present for parsing. This specifically happens when the app does not call app.synth().

For those encountering this issue, the workaround is for your app to call app.synth() at the end of the program.

6reactions
thekevinbrowncommented, Feb 3, 2020

For me the issue was that I had missed the difference between the file in bin and the file in lib, so I was missing:

const app = new cdk.App();
new MyStack(app, 'MyStack');

As soon as I added that back in I stopped getting the error about the missing file. It’d be great if we could improve the error message in this case.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshooting common AWS CDK issues
npx aws-cdk runs the local version of the AWS CDK Toolkit if one exists. It falls back to the global version when a...
Read more >
awslabs/aws-cdk - Gitter
Hi all, does anyone have any recommendations for making the CDK constructs provided by AWS-CDK compliant to a specific company? Should I use...
Read more >
aws-cdk yarn synth -o /tmp/artifacts returning error ENOENT
A couple of errors existed: Firstable cdk.json app entry needed to point to index.ts "app": "npx ts-node --prefer-ts-exts src/cdk/index.ts".
Read more >
AWS CDK Pipelines: Real-World Tips and Tricks (Part 2)
They are not chronological, nor do they explain the basics of CDK Pipelines. ... There are two main types, one is the CDK...
Read more >
AWS CDK Toolkit - npm
If there are multiple stacks in your application, cdk synth will synthesize the cloud assembly to cdk.out . $ # Synthesize cloud assembly...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found