fix(cli): "EACCES: Permission denied" on 'cdk init'#22111
Merged
mergify[bot] merged 5 commits intomainfrom Sep 20, 2022
Merged
Conversation
Naumel
approved these changes
Sep 19, 2022
Historically, `cdk init` used to create a dedicated temporary directory for hook scripts and copy `*.hook.*` scripts into there. In #21049, the logic was changed to create that temporary directory inside the CLI source directory. If that CLI source directory is mounted in a read-only location (say, `/usr/lib/node_modules`) then that directory could not be created and `cdk init` would fail. It looks like historically we might copy and postprocess hook scripts so that they could have variables replaced... but given that hook scripts are code, they could just read the variables directly, so we don't have to copy them into a temporary directory at all: we can directly run them from the source location. Fixes #22090.
d25cf01 to
3cd8635
Compare
Contributor
|
crying on the inside |
Contributor
|
On the other hand, my original fix for this, before revisions, would not have this issue. It wasn't ideal, by any means, but I think I can revise it to be slightly better and not cause this error. |
Contributor
|
but still , crying on the inside |
Contributor
|
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
Collaborator
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
Contributor
|
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
homakk
pushed a commit
to homakk/aws-cdk
that referenced
this pull request
Dec 1, 2022
Historically, `cdk init` used to create a dedicated temporary directory for hook scripts and copy `*.hook.*` scripts into there. In aws#21049, the logic was changed to create that temporary directory inside the CLI source directory. If that CLI source directory is mounted in a read-only location (say, `/usr/lib/node_modules`) then that directory could not be created and `cdk init` would fail. Historically, hook scripts were arbitrary scripts outside the scope of the CLI, but the previous change tried to reuse code from the CLI. That does not work because the CLI is now being bundled (all code and dependencies in one giant `.js` file), so reusing from the outside using a different entry point cannot work. (It's not clear that this is happening because we leave the source files in the original location inside the NPM package, to try and halfway not break people using the CLI in ways that are unsupported but happen to work). Instead, bundle the hook logic into the CLI itself, so it all uses the same mechanism. Fixes aws#22090. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Historically,
cdk initused to create a dedicated temporary directory for hook scripts and copy*.hook.*scripts into there.In #21049, the logic was changed to create that temporary directory inside the CLI source directory. If that CLI source directory is mounted in a read-only location (say,
/usr/lib/node_modules) then that directory could not be created andcdk initwould fail.Historically, hook scripts were arbitrary scripts outside the scope of the CLI, but the previous change tried to reuse code from the CLI. That does not work because the CLI is now being bundled (all code and dependencies in one giant
.jsfile), so reusing from the outside using a different entry point cannot work. (It's not clear that this is happening because we leave the source files in the original location inside the NPM package, to try and halfway not break people using the CLI in ways that are unsupported but happen to work).Instead, bundle the hook logic into the CLI itself, so it all uses the same mechanism.
Fixes #22090.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license