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.

‼️ NOTICE: 'Error: ENOTDIR invalid cwd' on `cdk deploy` in 1.90.0

See original GitHub issue

Please add your +1 👍 to let us know you have encountered this

Update

Version 1.90.1 which includes a fix is now released.


There is an issue with the way the CDK assets mechanism identifies already .zip file. Currently it will try to zip the already zipped file that will throw an error. We are working on a fix.

Workaround

TL;DR: delete the cdk.out folder before executing cdk deploy

The issue occurs when executing cdk deploy when there is a .zip file in the cdk.out folder. This happens when executing cdk synth - which creates the cdk.out folder, followed by cdk deploy (which is a completely normal cdk flow). To workaround this, delete the cdk.out folder before executing cdk deploy.

Repro

Any application which includes an asset with a .zip file will fail to deploy:

new lambda.Function(this, 'MyLambda', {
      code: lambda.Code.fromAsset(path.join(__dirname, '../my-zip.zip')),
      handler: 'index.handler',
      runtime: lambda.Runtime.NODEJS_12_X
 })

important: execute cdk synth before executing cdk deploy

cdk deploy will throw:

UnhandledPromiseRejectionWarning: Error: ENOTDIR invalid cwd 

Status: Working on a patch release

Overview:

When running cdk deploy in version 1.90.0 on a Stack that contains assets, you might see an error like 'Error: ENOTDIR invalid cwd.

Complete Error Message:

$ npx cdk deploy --require-approval=never 
Bug13131Stack: deploying...
[0%] start: Publishing e9882ab123687399f934da0d45effe675ecc8ce13b40cb946f3e1d6141fe8d68:current
(node:81012) UnhandledPromiseRejectionWarning: Error: ENOTDIR invalid cwd /Users/adamruka/workplace/cdk/on-call/bug-13131/cdk.out/asset.e9882ab123687399f934da0d45effe675ecc8ce13b40cb946f3e1d6141fe8d68.zip
    at GlobSync._readdirError (/Users/adamruka/workplace/cdk/on-call/bug-13131/node_modules/aws-cdk/node_modules/glob/sync.js:324:21)
    at GlobSync._readdir (/Users/adamruka/workplace/cdk/on-call/bug-13131/node_modules/aws-cdk/node_modules/glob/sync.js:290:10)
    at GlobSync._processGlobStar (/Users/adamruka/workplace/cdk/on-call/bug-13131/node_modules/aws-cdk/node_modules/glob/sync.js:350:22)
    at GlobSync._process (/Users/adamruka/workplace/cdk/on-call/bug-13131/node_modules/aws-cdk/node_modules/glob/sync.js:130:10)
    at new GlobSync (/Users/adamruka/workplace/cdk/on-call/bug-13131/node_modules/aws-cdk/node_modules/glob/sync.js:48:10)
    at Function.globSync [as sync] (/Users/adamruka/workplace/cdk/on-call/bug-13131/node_modules/aws-cdk/node_modules/glob/sync.js:26:10)
    at Promise (/Users/adamruka/workplace/cdk/on-call/bug-13131/node_modules/aws-cdk/node_modules/cdk-assets/lib/private/archive.ts:17:24)
    at new Promise (<anonymous>)
    at Object.zipDirectory (/Users/adamruka/workplace/cdk/on-call/bug-13131/node_modules/aws-cdk/node_modules/cdk-assets/lib/private/archive.ts:7:10)
    at FileAssetHandler.packageFile (/Users/adamruka/workplace/cdk/on-call/bug-13131/node_modules/aws-cdk/node_modules/cdk-assets/lib/private/handlers/files.ts:78:13)
(node:81012) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:81012) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Original bug report

My CDK script was all right, but was failing with the latest 1.90.0 version

Reproduction Steps

Run the CDK script via gitlab pipeline

What did you expect to happen?

No errors

What actually happened?

See the error message as below:

xxxx- infra-Dev: deploying...
[0%] start: Publishing 45f6bfc57a7695260616f2916fbef2dd77200af18743d956a59c8db9c3816b3f:current
(node:55) UnhandledPromiseRejectionWarning: Error: ENOTDIR invalid cwd /builds/xxxx/cdk.out/asset.45f6bfc57a7695260616f2916fbef2dd77200af18743d956a59c8db9c3816b3f.sh
    at GlobSync._readdirError (/usr/local/lib/node_modules/aws-cdk/node_modules/glob/sync.js:324:21)
    at GlobSync._readdir (/usr/local/lib/node_modules/aws-cdk/node_modules/glob/sync.js:290:10)
    at GlobSync._processGlobStar (/usr/local/lib/node_modules/aws-cdk/node_modules/glob/sync.js:350:22)
    at GlobSync._process (/usr/local/lib/node_modules/aws-cdk/node_modules/glob/sync.js:130:10)
    at new GlobSync (/usr/local/lib/node_modules/aws-cdk/node_modules/glob/sync.js:48:10)
    at Function.globSync [as sync] (/usr/local/lib/node_modules/aws-cdk/node_modules/glob/sync.js:26:10)
    at /usr/local/lib/node_modules/aws-cdk/node_modules/cdk-assets/lib/private/archive.ts:17:24
    at new Promise (<anonymous>)
    at Object.zipDirectory (/usr/local/lib/node_modules/aws-cdk/node_modules/cdk-assets/lib/private/archive.ts:7:10)
    at FileAssetHandler.packageFile (/usr/local/lib/node_modules/aws-cdk/node_modules/cdk-assets/lib/private/handlers/files.ts:78:13)
(node:55) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:55) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Environment
  • CDK CLI Version : 1.90.0
  • **Framework Version: **1.90.0
  • **Node.js Version: **12
  • OS : Docker
  • Language (Version): Python (3.8)
Other

Rollback to 1.89.0 fixed the problem


This is 🐛 Bug Report

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:30
  • Comments:35 (14 by maintainers)

github_iconTop GitHub Comments

6reactions
NetaNircommented, Feb 19, 2021

Added a workaround to the issue description, TL;DR: delete the cdk.out folder before executing cdk deploy.

A patch is on the way!

6reactions
skinny85commented, Feb 18, 2021

Confirming I was able to reproduce this. We’re working on a fix.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshooting common AWS CDK issues
When deploying my AWS CDK stack, I receive a NoSuchBucket error ... The AWS CDK issues a warning if your stack exceeds 80%...
Read more >
"ENOTDIR invalid cwd" when running a new Jupyter notebook ...
Recently, when I create a new Jupyter Notebook, I have an error "ENOTDIR invalid cwd" on Visual Studio Code and I cannot run...
Read more >
aws-cdk | Yarn - Package Manager
The AWS Cloud Development Kit (AWS CDK) is an open-source software development framework to define cloud infrastructure in code and provision it through...
Read more >
AWS CDK Toolkit - npm
Deploys a stack of your CDK app to its environment. During the deployment, the toolkit will output progress indications, similar to what can...
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