Skip to content

Error: EPERM: operation not permitted, unlink 'bin' #302

New issue

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

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

Already on GitHub? Sign in to your account

Closed
jorgenfroland opened this issue Jan 2, 2019 · 7 comments
Closed

Error: EPERM: operation not permitted, unlink 'bin' #302

jorgenfroland opened this issue Jan 2, 2019 · 7 comments

Comments

@jorgenfroland
Copy link

When running this command:

serverless deploy --stage staging

I get this error:

Serverless: Load command config
Serverless: Load command config:credentials
Serverless: Load command create
Serverless: Load command install
Serverless: Load command package
Serverless: Load command deploy
Serverless: Load command deploy:function
Serverless: Load command deploy:list
Serverless: Load command deploy:list:functions
Serverless: Load command invoke
Serverless: Load command invoke:local
Serverless: Load command info
Serverless: Load command logs
Serverless: Load command login
Serverless: Load command logout
Serverless: Load command metrics
Serverless: Load command print
Serverless: Load command remove
Serverless: Load command rollback
Serverless: Load command rollback:function
Serverless: Load command slstats
Serverless: Load command plugin
Serverless: Load command plugin
Serverless: Load command plugin:install
Serverless: Load command plugin
Serverless: Load command plugin:uninstall
Serverless: Load command plugin
Serverless: Load command plugin:list
Serverless: Load command plugin
Serverless: Load command plugin:search
Serverless: Load command config
Serverless: Load command config:credentials
Serverless: Load command rollback
Serverless: Load command rollback:function
Serverless: Load command requirements
Serverless: Load command requirements:clean
Serverless: Load command requirements:install
Serverless: Invoke deploy
Serverless: Invoke package
Serverless: Invoke aws:common:validate
Serverless: Invoke aws:common:cleanupTempDir
Serverless: Installing required Python packages with python3.6...
Serverless: Docker Image: lambci/lambda:build-python3.6
Serverless: Linking required Python packages...
Serverless: Packaging service...
Serverless: Excluding development dependencies...
Serverless: Unlinking required Python packages...

  Error --------------------------------------------------

  EPERM: operation not permitted, unlink 'bin'

     For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.

  Stack Trace --------------------------------------------

Error: EPERM: operation not permitted, unlink 'bin'
    at Object.unlinkSync (fs.js:952:3)
    at fse.readdirSync.map (C:\Users\jfroland\Documents\deployable-lambda-v2\node_modules\serverless-python-requirements\lib\link.js:76:11)
    at Array.map (<anonymous>)
    at ServerlessPythonRequirements.unlinkRequirements (C:\Users\jfroland\Documents\deployable-lambda-v2\node_modules\serverless-python-requirements\lib\link.js:72:38)
From previous event:
    at PluginManager.invoke (C:\Users\jfroland\AppData\Roaming\npm\node_modules\serverless\lib\classes\PluginManager.js:391:22)
    at PluginManager.spawn (C:\Users\jfroland\AppData\Roaming\npm\node_modules\serverless\lib\classes\PluginManager.js:409:17)
    at Deploy.BbPromise.bind.then (C:\Users\jfroland\AppData\Roaming\npm\node_modules\serverless\lib\plugins\deploy\deploy.js:117:50)
From previous event:
    at Object.before:deploy:deploy [as hook] (C:\Users\jfroland\AppData\Roaming\npm\node_modules\serverless\lib\plugins\deploy\deploy.js:107:10)
    at BbPromise.reduce (C:\Users\jfroland\AppData\Roaming\npm\node_modules\serverless\lib\classes\PluginManager.js:391:55)
From previous event:
    at PluginManager.invoke (C:\Users\jfroland\AppData\Roaming\npm\node_modules\serverless\lib\classes\PluginManager.js:391:22)
    at PluginManager.run (C:\Users\jfroland\AppData\Roaming\npm\node_modules\serverless\lib\classes\PluginManager.js:422:17)
    at variables.populateService.then.then (C:\Users\jfroland\AppData\Roaming\npm\node_modules\serverless\lib\Serverless.js:157:33)
    at runCallback (timers.js:705:18)
    at tryOnImmediate (timers.js:676:5)
    at processImmediate (timers.js:658:5)
    at process.topLevelDomainCallback (domain.js:120:23)
From previous event:
    at Serverless.run (C:\Users\jfroland\AppData\Roaming\npm\node_modules\serverless\lib\Serverless.js:144:8)
    at serverless.init.then (C:\Users\jfroland\AppData\Roaming\npm\node_modules\serverless\bin\serverless:44:28)

  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues
     Issues:        forum.serverless.com

  Your Environment Information -----------------------------
     OS:                     win32
     Node Version:           10.14.2
     Serverless Version:     1.35.1

I believe this has something to do with it trying to unlink a directory that is treated as a file, but Im not sure. See this post: https://stackoverflow.com/questions/50590798/nodejs-serverless-windows-10/50613829#50613829

@dschep
Copy link
Contributor

dschep commented Jan 2, 2019

Huh.. what version of the plugin are you using? It shouldn't be using symlinks anymore, thus shouldn't have to delete them 😕

@jorgenfroland
Copy link
Author

jorgenfroland commented Jan 2, 2019

Sorry, forgot to mention that.
`-- [email protected]

@jorgenfroland
Copy link
Author

I did a test with inserting an empty return statement in "link.js" in the plugin, just before the line that triggered the error (link.js:76:11). The deploy command completed without any errors:

function unlinkRequirements() {
  const requirementsDir = path.join(this.servicePath, '.serverless/requirements');
  if (!this.options.zip && fse.existsSync(requirementsDir)) {
    this.serverless.cli.log('Unlinking required Python packages...');
    const noDeploy = new Set(this.options.noDeploy || []);
    fse.readdirSync(requirementsDir).map((file) => {
      if (noDeploy.has(file.split(/\.(py|pyc|dist-info\/?)$/)[0])) {
        return;
      }
      return;  // My edit
      fse.unlinkSync(file);
    });
  }
}

module.exports = {linkRequirements, unlinkRequirements};

@dschep
Copy link
Contributor

dschep commented Jan 3, 2019

Is there a particular reason you're using that version and not the latest?

@jorgenfroland
Copy link
Author

jorgenfroland commented Jan 3, 2019

I followed this tutorial: http://joshuaballoch.github.io/custom-packages-lambda/ and set up a package.json like this:

{
  "name": "deployable-lambda",
  "description": "",
  "version": "0.1.0",
  "dependencies": {},
  "devDependencies": {
    "serverless-python-requirements": "^3.0.10"
  }
}

I thought that this would install the newest version not older than v3.0.10.

@dschep
Copy link
Contributor

dschep commented Jan 3, 2019

Right, that won't install anything < 3 actually, and the latest version is 4.2.5, so I recommend upgrading: npm i serverless-python-requirements@^4.2.5 then try again

@jorgenfroland
Copy link
Author

I installed the newest version. Now I encountered issue #274. I got it working by installing plugin with
npm i T-Tmnr/serverless-python-requirements#fix-issue-274

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants