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

Synthesis fails with the error ENAMETOOLONG #164

Closed
otaviomacedo opened this issue Aug 3, 2022 · 3 comments · Fixed by #206
Closed

Synthesis fails with the error ENAMETOOLONG #164

otaviomacedo opened this issue Aug 3, 2022 · 3 comments · Fixed by #206
Assignees
Labels
bug Something isn't working p1

Comments

@otaviomacedo
Copy link
Contributor

Describe the bug

For some templates, the synthesis fails with the error ENAMETOOLONG.

Expected behavior

Synthesize the template successfully.

Current behavior

Running decdk on some templates leads to the error:

Error: ENAMETOOLONG: name too long, mkdir '/Users/otaviom/projects/decdk/examples/cdk.out/asset.5205744804b6ed271bb4809a866fc56a2c53383a68ce2919e707afc0730cd523/cdk.out/asset.15689ac064b611030f942500c2748f742e64ae1901db7bec75f6fbcb5924f628/cdk.out/asset.15689ac064b611030f942500c2748f742e64ae1901db7bec75f6fbcb5924f628/cdk.out/asset.15689ac064b611030f942500c2748f742e64ae1901db7bec75f6fbcb5924f628/cdk.out/asset.15689ac064b611030f942500c2748f742e64ae1901db7bec75f6fbcb5924f628/cdk.out/asset.15689ac064b611030f942500c2748f742e64ae1901db7bec75f6fbcb5924f628/cdk.out/asset.15689ac064b611030f942500c2748f742e64ae1901db7bec75f6fbcb5924f628/cdk.out/asset.15689ac064b611030f942500c2748f742e64ae1901db7bec75f6fbcb5924f628/cdk.out/asset.15689ac064b611030f942500c2748f742e64ae1901db7bec75f6fbcb5924f628/cdk.out/asset.15689ac064b611030f942500c2748f742e64ae1901db7bec75f6fbcb5924f628/cdk.out/asset.15689ac064b611030f942500c2748f742e64ae1901db7bec75f6fbcb5924f628/cdk.out/asset.15689ac064b611030f942500c2748f742e64ae1901db7bec75f6fbcb5924f628/cdk.out/asset.15689ac064b611030f942500c2748f742e64ae1901db7bec75f6fbcb5924f628'

It seems it's producing a symlink that points to the directory that contains it.

Reproduction steps

Run cdk -a "decdk lambda-topic.json" synth on the examples folder of this repo.

@otaviomacedo otaviomacedo added the bug Something isn't working label Aug 5, 2022
@mrgrain mrgrain self-assigned this Aug 23, 2022
@mrgrain
Copy link
Contributor

mrgrain commented Aug 23, 2022

Currently failing with this error:

examples/apigw.json
examples/lambda-events.json
examples/lambda-role-removed.json
examples/lambda-topic.json

All are using "fromAsset": { "path": "." }

@mrgrain
Copy link
Contributor

mrgrain commented Aug 23, 2022

Reproduced with classic CDK. Error messages is basically the same an equally unusable.

new lambda.Function(this, "Function", {
  runtime: lambda.Runtime.NODEJS_16_X,
  handler: "lambda.handler",
  code: Code.fromAsset("."),
});

I don't think this is producing a symlink, but rather an issue with the recursive implementation of copyDirectory algorithm. The . path will include cdk.out, which we are also copying files to. So any file that is copied to the asset is immediately discovered as a new file that needs copying.

@mrgrain
Copy link
Contributor

mrgrain commented Aug 23, 2022

Related aws-cdk issue aws/aws-cdk#3899

@mergify mergify bot closed this as completed in #206 Aug 23, 2022
mergify bot pushed a commit that referenced this issue Aug 23, 2022
Resolves #164 

Note this changes removes running (some) tests in a temporary working dir. Changing the working directory breaks assumptions about the CWD for file paths. There was no apparent reason why this was introduced in the first place in #110.

There is an open question about how we want to deal with relative file paths. The two options are:
- relative to the CWD
- relative to the template

There is a comment in [deconstruction.ts](https://github.com/cdklabs/decdk/blob/ee07573d61a470288890d14d739dfb88092b51b8/src/deconstruction.ts#L853-L854) that indicates it should be relative to the template file. However the current implementation in [decdk.ts](https://github.com/cdklabs/decdk/blob/145238a53f1f9f8db5c1808500e6bac4c8a0d4a1/src/decdk.ts#L25) does NOT do that (note the missing `workingDirectory` prop).

I've left it at the current implementation (relative to the CWD) for now, which I think is also closer to how imperative CDK behaves. In future the most transparent might be a command line option. Related #200
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working p1
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants