Amplify-cli: An error occured during the push operation: EEXIST: file already exists, symlink

Created on 8 Dec 2019  Â·  6Comments  Â·  Source: aws-amplify/amplify-cli

Note: If your issue/bug is regarding the AWS Amplify Console service, please log it in the
Amplify Console GitHub Issue Tracker

*Bug description
I have a lambda function written in typescript. I have symlinked the src folder containing graphql autogenerated files. I'm not not able to pull backend or push. I receive this error:

➜ myProject git:(master) ✗ amplify push
✖ There was an error pulling the backend environment dev.
An error occured during the push operation: EEXIST: file already exists, symlink '../../../../../src/graphql' -> '/Users/myUser/Projects/myProject/amplify/.temp/#current-cloud-backend/function/myProjectSyncParkings/lib/graphql'

Amplify CLI Version
4.2.0

Am I doing something wrong? Now I'm not able to do anything, unless i recreate from scratch the entire stack..

Most helpful comment

@mdebo Did you try deleting the /Users/myUser/Projects/myProject/amplify/.temp/ directory and running amplify push again?

All 6 comments

UPDATE: I End up removing the symlink and recreate project from scratch, but now when doing amplify push i get this error when the cli try to get to pull :

✖ There was an error pulling the backend environment dev.
EEXIST: file already exists, symlink '../loose-envify/cli.js' -> '/Users/myUser/Projects/myProject/amplify/.temp/#current-cloud-backend/function/myFunction/lib/node_modules/.bin/loose-envify'

It seems that node_modules symlinks cause problems too. Is there a way to avoid that, and more important, how to bypass the probleme without deleting the entire stack?
At first glance, i was really impressed by the promises of amplify but now i don't feel comfortable to use it in production. Reading issues opened, Amplify push does not seem to be really reliable for the moment..

@mdebo Did you try deleting the /Users/myUser/Projects/myProject/amplify/.temp/ directory and running amplify push again?

Closing due to lack of requested information. Please feel free to comment on this issue if you're still stuck on this issue.

I have a similar issue:

1] I put a symlink inside the src directory of a Lambda function (created with the Amplify CLI).
2] I ran "amplify push" with no problems.
3] I removed the symlink.
4] I ran "amplify push" again:

✖ There was an error pulling the backend environment dev.
An error occured during the push operation: ENOENT: no such file or directory, stat '/Users/grue/Projects/vol/backend/amplify/.temp/#current-cloud-backend/function/prepAsset/src/volLib'

5] I put the symlink back.
6] I ran "amplify push" again:

✖ There was an error pulling the backend environment dev.
An error occured during the push operation: EEXIST: file already exists, symlink '../../../../../volLib' -> '/Users/grue/Projects/vol/backend/amplify/.temp/#current-cloud-backend/function/prepAsset/src/volLib'

(EDIT: Note that the errors are different.)

I've gone back and forth, removing and replacing the symlink. I've removed the amplify/.temp directory during many of these tests. I've even gone into the Lambda console and removed the volLib item from there. I always get one of the two errors above, no matter the combination of symlink, amplify/.temp, and the Lambda console.

It does occur to me that the actual function directory and the ./temp/#current-cloud-backend function directory are at different depths, so the ../ paths don't work in ./temp/#current-cloud-backend and may look like errors. That might be part of it. But I can't tell how to get out of this state.

EDIT: Even "amplify status" fails.

Ok, I'm unblocked, and I didn't have to rebuild the entire project. Here's what I did:

1] I put an empty "volLib" directory in the amplify directory. That makes the symlinks from inside amplify/.temp resolve to something.
2] I deleted the function in the Lambda console.
3] I removed the symlinks from the amplify/.temp/#current-cloud-backend directory, AND the amplify/#current-cloud-backend directory.
4] I removed the amplify/.temp/#current-cloud-backend.zip
5] I ran 'amplify function remove'
6] I ran 'amplify push'.

So I _think_ I'm working again.

Rule of thumb: DON'T USE SYMLINKS IN LAMBDA src/ DIRECTORIES.

Since symlinks are obviously not supported, my request for the amplify-cli team would be to add a check on "amplify push" to see if there are any symlinks in Lambda src directories, and bail out if there are.

Running into similar issues.
Deleting the Lambda manually got me in a worse state :scream:

I removed the erroring files from '#current-cloud-backend.zip' in s3://amplify-*-deployment bucket and delete all locally cached versions with git clean -ndx and rm amplify/.temp.

Was this page helpful?
0 / 5 - 0 ratings