amplify-cli icon indicating copy to clipboard operation
amplify-cli copied to clipboard

amplify env pull fails in Windows after adding a function

Open kstro21 opened this issue 7 years ago • 11 comments

Describe the bug amplify env pull fails in Windows after adding a function using amplify function add

To Reproduce Steps to reproduce the behavior:

  1. Add a function using amplify function add
  2. Run npm install inside the src/ folder in the function
  3. Run amplify env pull or amplify init
  4. There was an error initializing your environment. init failed { Error: EPERM: operation not permitted, symlink '..\mime\cli.js' -> 'app\amplify.temp#current-cloud-backend\function\myfunction\src\node_modules.bin\mime' errno: -4048, code: 'EPERM', syscall: 'symlink', path: '..\mime\cli.js', dest: '\app\amplify\.temp\#current-cloud-backend\function\myfunction\src\node_modules\.bin\mime' }

Expected behavior Be able to pull, checkout or init an existing environment after adding a function.

Desktop (please complete the following information):

  • OS: Windows 10
  • amplify-cli 1.1.7

Additional context Same error using windows cmd or a bash for Windows.

kstro21 avatar Mar 07 '19 02:03 kstro21

@kstro21 whats the version of CLI do you have installed?

yuth avatar Mar 08 '19 23:03 yuth

@yuth I've updated the issue and added that info, I'm using amplify-cli 1.1.7

kstro21 avatar Mar 09 '19 00:03 kstro21

@kstro21 what do you have in the dependency block of your package.json

Do you see more in the stack trace apart from what you already pasted in the issue?

yuth avatar Mar 11 '19 18:03 yuth

@yuth here is the complete stack trace

There was an error initializing your environment. 2019-03-11T18:40:55.173Z - error: uncaughtException: EPERM: operation not permitted, symlink '..\mime\cli.js' -> 'myapp\amplify.temp#current-cloud-backend\function\pgaapicourses\src\node_modules.bin\mime' date=Mon Mar 11 2019 14:40:55 GMT-0400 (Eastern Daylight Time), pid=14936, uid=null, gid=null, cwd=myapp, execPath=C:\Program Files (x86)\nodejs\node.exe, version=v8.11.4, argv=[C:\Program Files (x86)\nodejs\node.exe, C:\Users\MyUser\AppData\Roaming\npm\node_modules@aws-amplify\cli\bin\amplify, env, pull], rss=244527104, heapTotal=84357120, heapUsed=68813976, external=135429418, loadavg=[0, 0, 0], uptime=56806.6657181, trace=[], stack=[Error: EPERM: operation not permitted, symlink '..\mime\cli.js' -> 'myapp\amplify.temp#current-cloud-backend\function\pgaapicourses\src\node_modules.bin\mime']

Dependencies in my package.json

"dependencies": {
    "@material-ui/core": "3.9.2",
    "@material-ui/icons": "3.0.2",
    "classnames": "2.2.6",
    "cross-env": "5.2.0",
    "downshift": "3.2.4",
    "localforage": "1.7.3",
    "lodash": "4.17.11",
    "react": "16.8.1",
    "react-dom": "16.8.1",
    "react-router-dom": "4.3.1",
    "react-scripts-ts": "3.1.0"
  },
  "devDependencies": {
    "@types/classnames": "2.2.7",
    "@types/graphql": "14.0.7",
    "@types/history": "4.7.2",
    "@types/jest": "24.0.0",
    "@types/lodash": "4.14.121",
    "@types/node": "10.12.23",
    "@types/react": "16.8.2",
    "@types/react-dom": "16.8.0",
    "@types/react-router": "4.4.3",
    "@types/webpack-env": "1.13.7",
    "aws-amplify": "1.1.19",
    "aws-amplify-react": "2.3.0",
    "csstype": "2.6.2",
    "typescript": "3.3.3333"
  },

My Lambdas dependencies

  "dependencies": {
    "aws-sdk": "^2.49.0",
    "aws-serverless-express": "^3.3.5",
    "body-parser": "^1.17.1",
    "express": "^4.15.2"
  },

Hope it helps

kstro21 avatar Mar 11 '19 18:03 kstro21

The problem is due to Windows permissions to create symlinks, we need to run the cmd as administrator, then it works. Closing

Thanks, @yuth, for the time.

kstro21 avatar Mar 13 '19 14:03 kstro21

I am getting this error while running as administrator-

c:\Users\nitin\aws\aws3>amplify pull --appId dnq6aww8tlwm5 EPERM: operation not permitted, rename 'c:\Users\nitin\aws\aws3\amplify' -> 'c:\Users\nitin\aws\aws3\amplify-backup' Error: EPERM: operation not permitted, rename 'c:\Users\nitin\aws\aws3\amplify' -> 'c:\Users\nitin\aws\aws3\amplify-backup' at Object.renameSync (fs.js:772:3) at rename (C:\Users\nitin\AppData\Roaming\npm\node_modules@aws-amplify\cli\node_modules\fs-extra\lib\move-sync\move-sync.js:31:8) at doRename (C:\Users\nitin\AppData\Roaming\npm\node_modules@aws-amplify\cli\node_modules\fs-extra\lib\move-sync\move-sync.js:26:10) at Object.moveSync (C:\Users\nitin\AppData\Roaming\npm\node_modules@aws-amplify\cli\node_modules\fs-extra\lib\move-sync\move-sync.js:17:10) at backupAmplifyFolder (C:\Users\nitin\AppData\Roaming\npm\node_modules@aws-amplify\cli\lib\attach-backend.js:107:12) at Object.attachBackend (C:\Users\nitin\AppData\Roaming\npm\node_modules@aws-amplify\cli\lib\attach-backend.js:35:5) at Object.exports.run (C:\Users\nitin\AppData\Roaming\npm\node_modules@aws-amplify\cli\lib\commands\pull.js:62:32) at Object.executeAmplifyCommand (C:\Users\nitin\AppData\Roaming\npm\node_modules@aws-amplify\cli\lib\index.js:182:29) at processTicksAndRejections (internal/process/task_queues.js:93:5) at async executePluginModuleCommand (C:\Users\nitin\AppData\Roaming\npm\node_modules@aws-amplify\cli\lib\execution-manager.js:153:5)

nitin3000 avatar Dec 09 '20 14:12 nitin3000

@nitin3000

Try downgrading to 4.37.2

I just wasted 2 days on this.

kfernandes29 avatar Dec 09 '20 20:12 kfernandes29

@kfernandes29 Your 2 days of work just helped me out, thanks! This happened to me when trying to move my repo to another amplify project. It's still not working for me, but I think it's because of some config that the new admin ui threw in.

lebull avatar Dec 10 '20 15:12 lebull

@lebull Glad it helped! That new admin UI + the new CLI has been nothing but headaches this week. It set me back quite a bit. I’m not sure how I got it all back to normal, but after 48 hours of frustration...it’s good again.

kfernandes29 avatar Dec 10 '20 15:12 kfernandes29

@kfernandes29

https://github.com/aws-amplify/amplify-cli/issues/6138#issuecomment-742730830

lebull avatar Dec 10 '20 19:12 lebull

This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs.

Looking for a help forum? We recommend joining the Amplify Community Discord server *-help channels for those types of questions.

github-actions[bot] avatar May 25 '21 12:05 github-actions[bot]