Amplify-cli: amplify env pull fails in Windows after adding a function

Created on 7 Mar 2019  路  10Comments  路  Source: aws-amplify/amplify-cli

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-backendfunction\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.

bug functions windows

Most helpful comment

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.

All 10 comments

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

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

@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 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-backendfunction\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-backendfunction\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

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.

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_modulesfs-extra\lib\move-sync\move-sync.js:31:8)
at doRename (C:\Users\nitin\AppData\Roaming\npm\node_modules\@aws-amplify\cli\node_modulesfs-extra\lib\move-sync\move-sync.js:26:10)
at Object.moveSync (C:\Users\nitin\AppData\Roaming\npm\node_modules\@aws-amplify\cli\node_modulesfs-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

Try downgrading to 4.37.2

I just wasted 2 days on this.

@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 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鈥檓 not sure how I got it all back to normal, but after 48 hours of frustration...it鈥檚 good again.

Was this page helpful?
0 / 5 - 0 ratings