Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Failed to pull the backend. - ENOENT: no such file or directory, realpath #10032

Open
5 tasks done
iyz91 opened this issue Mar 21, 2022 · 18 comments
Open
5 tasks done

Failed to pull the backend. - ENOENT: no such file or directory, realpath #10032

iyz91 opened this issue Mar 21, 2022 · 18 comments
Labels
bug Something isn't working dependency-issue Issue with another dependency used p2 windows Issues tied to running the CLI on Windows

Comments

@iyz91
Copy link

iyz91 commented Mar 21, 2022

Before opening, please confirm:

  • I have installed the latest version of the Amplify CLI (see above), and confirmed that the issue still persists.
  • I have searched for duplicate or closed issues.
  • I have read the guide for submitting bug reports.
  • I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
  • I have removed any sensitive information from my code snippets and submission.

How did you install the Amplify CLI?

npm

If applicable, what version of Node.js are you using?

16.14.2

Amplify CLI Version

7.6.25

What operating system are you using?

Windows 11

Did you make any manual changes to the cloud resources managed by Amplify? Please describe the changes made.

No manual changes made.

Amplify Categories

auth, storage, function, api

Amplify Commands

pull

Describe the bug

Project was previously worked on a different device. Setting this up on a new device for the first time created this issue.

The ENOENT error appears to involve a function lambda layer looking for the file/directory realpath in "function<layerName>\lib\nodejs\node_modules\browser-resolve\node_modules\resolve\test\pathfilter\deep_ref\node_modules\deep\deeper". It appears the sub-directory "deep_ref" does not exist but the sub-directories after that do exist.

Deleting any files related to amplify does not solve the issue.

Expected behavior

Amplify should be able to pull the project environment without error, including for any lambda layers.

Reproduction steps

Not sure if this will be reproducible for others as it appears to involve a lambda layer issue.

  1. Using an existing backend with a lambda layer in the function category, pull an environment on a new device

GraphQL schema(s)

No response

Log output

Backend environment 'dev' found. Initializing...
Failed to pull the backend.
ENOENT: no such file or directory, realpath 'C:\...\amplify\.temp\#current-cloud-backend\function\<layerName>\lib\nodejs\node_modules\browser-resolve\node_modules\resolve\test\pathfilter\deep_ref\node_modules\deep\deeper'


Additional information

No response

@iyz91
Copy link
Author

iyz91 commented Mar 21, 2022

It seems that there's been numerous updates to the CLI since I last used it, such as for lambda layers and the gql transformer. At this point, I cannot follow the recommended steps to update lambda layers since I cannot run amplify push as the project cannot be properly initialized. What would be the recommended steps to resolve this?

@0afcode
Copy link

0afcode commented Mar 22, 2022

I am also experiencing the same issue on same version of cli. I also tried reverting as far back as 7.6.20 and still persisting. I have diagnosed that this is happening due to a windows limitation for file path length. My project pulls fine on a linux machine but does not work on windows anymore after we updated and installed more node packages in one of our lambda layers in our amplify project.

I tried enabling long file path on windows but that did not seem to help, however I was able to find a work around by moving the project root folder into a short path (ex: C:\MyProject..) and that allowed me to pull successfully.

@marcvberg marcvberg added windows Issues tied to running the CLI on Windows platform Issues tied to the general CLI platform pending-triage Issue is pending triage labels Mar 22, 2022
@josefaidt
Copy link
Contributor

To add on to @0afcode 's comment, there appears to be a MAX_PATH variable we can set to increase the path constraint from 260. First, can you confirm whether the printed path exceeds 260 characters, and if so can you try increasing this constraint via the variable or move the project up a few levels?

reference: https://docs.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation?tabs=cmd

@josefaidt josefaidt added the pending-response Issue is pending response from the issue author label Mar 22, 2022
@iyz91
Copy link
Author

iyz91 commented Mar 23, 2022

@josefaidt The path is indeed quite long but long paths were already enabled in W11 so not sure why the issue still happened. I've decided to reinitialize the amplify stack since we had a lot of refactoring to do anyways and to take advantage of the toolchain changes. That exact same lambda layer with the same folder depth in the new stack does not have the issue, so it doesn't actually appear to be an issue with the path length limit in the OS, it's something with the framework. Again, looking at my original post above, the framework added a subdirectory that doesn't exist, "deep_ref" so maybe the issue lies there.

@josefaidt
Copy link
Contributor

Hey @iyz91 👋 unfortunately I have not been able to reproduce this by using a Lambda Layer with browser-resolve as a dependency among many others. I have a few follow-up questions:

  • was the layer modified in the cloud?
  • can you post the full path of the npm module that was causing issues? the path in the original post seems obfuscated
  • how was this project initialized on the separate device?

@iyz91
Copy link
Author

iyz91 commented Mar 25, 2022

@josefaidt

  • The layer was not modified in the cloud
  • The full path would have been something akin to C:\Users\Abc\Documents\Projects\Abcdefgh\Abcdefghijk\Code\Abcdefghijklmn\amplify\backend\function<layerName>\lib\nodejs\node_modules\browser-resolve\node_modules\resolve\test\pathfilter\deep_ref\node_modules\deep\deeper
  • The project was first pulled from a repo and then I ran amplify pull

It's important to note I think that the lambda layer was created using an older CLI version before the lambda layer changes that I linked in the first comment.

@josefaidt
Copy link
Contributor

Hey @iyz91 thanks for the clarification!

The project was first pulled from a repo and then I ran amplify pull

Does this issue occur each time we attempt to clone the repo and pull? Does this also occur with init?

@iyz91
Copy link
Author

iyz91 commented Mar 30, 2022

@josefaidt As far as I remember it occurred with both pull and init.

@josefaidt
Copy link
Contributor

Hey @iyz91 👋 unfortunately I have not been able to reproduce this issue. Have you continuously experienced this? Re-reading this note from an earlier reply

I've decided to reinitialize the amplify stack since we had a lot of refactoring to do anyways and to take advantage of the toolchain changes. That exact same lambda layer with the same folder depth in the new stack does not have the issue

Was this project recreated from scratch or was it pulled into an empty directory?

@josefaidt josefaidt added the not-reproducible Not able to reproduce the issue label Apr 5, 2022
@iyz91
Copy link
Author

iyz91 commented Apr 7, 2022

@josefaidt The issue came up when the project repo was pulled into another device and then amplify pull was run. I remember trying different approaches to initializing it etc. (can't say for certain what they were at this point) but everything gave me the same error.

When I decided to recreate the stack from scratch I didn't have this problem at all even with the exact same folder structure and nesting depth. The key difference though is the recreation was done using the latest CLI version, while the earlier errored attempts were using the latest CLI on an amplify backend that was previously created probably 2 major CLI versions ago.

@josefaidt josefaidt self-assigned this Apr 13, 2022
@josefaidt
Copy link
Contributor

Hey @iyz91 given my inability to reproduce this issue and since you were able to mitigate the issue I will close this for now, however if this occurs again please reply back to this thread and we can re-open to investigate further.

@iyz91
Copy link
Author

iyz91 commented Apr 20, 2022

Hey @josefaidt Looks like this issue popped up again... I created a seperate repo for an admin interface on our project and following the instructions here. This gave the error below:

Failed to pull the backend.
🛑 ENOENT: no such file or directory, realpath 'C:\Users\<user>\Documents\Projects\stuff\stuff\Code\stuff\amplify\.temp\#current-cloud-backend\function\stuffv3GeneratorLayer\lib\nodejs\node_modules\browser-resolve\node_modules\resolve\test\pathfilter\deep_ref\node_modules\deep\deeper'

To be clear, this was done in a brand new repo, pulling from an already existing and pushed amplify backend that was created with the amplify CLI v8.

@iyz91
Copy link
Author

iyz91 commented Apr 20, 2022

@josefaidt Seems to be a bug with node's fs.promises.realpath, see actions/upload-artifact#240 and nodejs/node#39721

@josefaidt
Copy link
Contributor

Hey @iyz91 great callout on the Node issue. I will re-open this and mark this as a dependency issue

@josefaidt josefaidt reopened this Apr 20, 2022
@josefaidt josefaidt removed their assignment Apr 20, 2022
@josefaidt josefaidt added bug Something isn't working dependency-issue Issue with another dependency used p2 and removed platform Issues tied to the general CLI platform pending-response Issue is pending response from the issue author pending-triage Issue is pending triage not-reproducible Not able to reproduce the issue labels Apr 20, 2022
@kylekirkby
Copy link
Contributor

@josefaidt - any update on this? Got hit by this again today :/ The weird thing is that everything has been going great with the CLI and then suddenly this old issue is back.

Learn more at: https://docs.amplify.aws/cli/project/troubleshooting/

ZipExtractFault: Failed to extract zip file:
    at extractZip (C:\snapshot\amplify-cli\build\node_modules\@aws-amplify\amplify-provider-awscloudformation\lib\zip-util.js:43:11)
    at async Object.run (C:\snapshot\amplify-cli\build\node_modules\@aws-amplify\amplify-provider-awscloudformation\lib\initialize-env.js:44:25)

ENOENT: no such file or directory, realpath 'C:\Users\kylek\Documents\XXX\amplify\.temp\#current-cloud-backend\function\XXXXXXX\lib\nodejs\node_modules\@aws-sdk\s3-presigned-post\node_modules\@aws-sdk\credential-provider-ini\node_modules\@smithy\shared-ini-file-loader\node_modules\@smithy'
Error: ENOENT: no such file or directory, realpath 'C:\Users\kylek\Documents\XXX\amplify\.temp\#current-cloud-backend\function\XXXXXXX\lib\nodejs\node_modules\@aws-sdk\s3-presigned-post\node_modules\@aws-sdk\credential-provider-ini\node_modules\@smithy\shared-ini-file-loader\node_modules\@smithy'

@naedx
Copy link
Contributor

naedx commented Mar 11, 2024

I'm also having this issue now.

PullBackendFault: Failed to pull the backend.
    at attachBackend (C:\snapshot\amplify-cli\build\node_modules\@aws-amplify\cli-internal\lib\attach-backend.js:55:15)
    at async Object.run (C:\snapshot\amplify-cli\build\node_modules\@aws-amplify\cli-internal\lib\commands\pull.js:64:9)
    at async Object.executeAmplifyCommand (C:\snapshot\amplify-cli\build\node_modules\@aws-amplify\cli-internal\lib\index.js:194:9)
    at async executePluginModuleCommand (C:\snapshot\amplify-cli\build\node_modules\@aws-amplify\cli-internal\lib\execution-manager.js:139:5)
    at async executeCommand (C:\snapshot\amplify-cli\build\node_modules\@aws-amplify\cli-internal\lib\execution-manager.js:37:9)
    at async Object.run (C:\snapshot\amplify-cli\build\node_modules\@aws-amplify\cli-internal\lib\index.js:121:5)

ENOENT: no such file or directory, realpath 'C:\Users\windowsuser\Projects\XXXXXXXXXXX\packages\lib_package_name_xxxxxxxxx\amplify\.temp\#current-cloud-backend\function\apinameLayer1473473xxxxxxxxxxxxxxxxxxxxx\lib\nodejs\node_modules\@aws-crypto\ie11-detection\node_modules\tslib\test\validateModuleExportsMatchCommonJS'  
Error: ENOENT: no such file or directory, realpath 'C:\Users\windowsuser\Projects\XXXXXXXXXXX\packages\lib_package_name_xxxxxxxxx\amplify\.temp\#current-cloud-backend\function\apinameLayer1473473xxxxxxxxxxxxxxxxxxxxx\lib\nodejs\node_modules\@aws-crypto\ie11-detection\node_modules\tslib\test\validateModuleExportsMatchCommonJS'

Amplify version: 12.10.1 (latest)

@THARUE
Copy link

THARUE commented Apr 22, 2024

Having this issue as well. Amplify version: 12.11.1

@THARUE
Copy link

THARUE commented Apr 22, 2024

no such file or directory, realpath 'DynamodbStreamsLambdaLayer\lib\nodejs\node_modules@aws-sdk\client-cognito-identity-provider\node_modules@aws-crypto\sha256-browser\node_modules\tslib\test\validateModuleExportsMatchCommonJS''

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working dependency-issue Issue with another dependency used p2 windows Issues tied to running the CLI on Windows
Projects
None yet
Development

No branches or pull requests

7 participants