Skip to content
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

Postinstall script installation of tabtab fails #3760

Closed
ryanmurakami opened this issue Jun 8, 2017 · 10 comments
Closed

Postinstall script installation of tabtab fails #3760

ryanmurakami opened this issue Jun 8, 2017 · 10 comments

Comments

@ryanmurakami
Copy link
Member

This is a Bug Report

Description

When installing serverless the postinstall script throws when attempting to run tabtab install because tabtab does not exist. If I run the tamtam install command separately after installation, it succeeds. There seems to be a type of race condition with the creation of that binary and the execution of the postinstall script.

Repro steps:

  1. Run npm install serverless
  2. Observer error message on completion

Node.js version: 6.10.3 (also tried with 8.0.0)
npm version: 5.0.3

Additional Data

  • Serverless Framework Version you're using: 1.15.1
  • Operating System: MacOS 10.12.4
  • Stack Trace:
> serverless@1.15.1 postinstall /Users/rylewis/Documents/Dev/Repo/deploy/node_modules/serverless
> node ./scripts/postinstall.js

/bin/sh: ./node_modules/tabtab/bin/tabtab: No such file or directory
/bin/sh: ./node_modules/tabtab/bin/tabtab: No such file or directory
Unhandled rejection Error: Command failed: ./node_modules/tabtab/bin/tabtab install --name serverless --stdout
/bin/sh: ./node_modules/tabtab/bin/tabtab: No such file or directory

    at checkExecSyncError (child_process.js:481:13)
    at execSync (child_process.js:521:13)
    at serverless.init.then.e (/Users/rylewis/Documents/Dev/Repo/deploy/node_modules/serverless/scripts/postinstall.js:15:7)
    at tryCatcher (/Users/rylewis/Documents/Dev/Repo/deploy/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/Users/rylewis/Documents/Dev/Repo/deploy/node_modules/bluebird/js/release/promise.js:512:31)
    at Promise._settlePromise (/Users/rylewis/Documents/Dev/Repo/deploy/node_modules/bluebird/js/release/promise.js:569:18)
    at Promise._settlePromise0 (/Users/rylewis/Documents/Dev/Repo/deploy/node_modules/bluebird/js/release/promise.js:614:10)
    at Promise._settlePromises (/Users/rylewis/Documents/Dev/Repo/deploy/node_modules/bluebird/js/release/promise.js:693:18)
    at Promise._fulfill (/Users/rylewis/Documents/Dev/Repo/deploy/node_modules/bluebird/js/release/promise.js:638:18)
    at Promise._settlePromise (/Users/rylewis/Documents/Dev/Repo/deploy/node_modules/bluebird/js/release/promise.js:582:21)
    at Promise._settlePromise0 (/Users/rylewis/Documents/Dev/Repo/deploy/node_modules/bluebird/js/release/promise.js:614:10)
    at Promise._settlePromises (/Users/rylewis/Documents/Dev/Repo/deploy/node_modules/bluebird/js/release/promise.js:693:18)
    at Promise._fulfill (/Users/rylewis/Documents/Dev/Repo/deploy/node_modules/bluebird/js/release/promise.js:638:18)
    at /Users/rylewis/Documents/Dev/Repo/deploy/node_modules/bluebird/js/release/nodeback.js:42:21
    at /Users/rylewis/Documents/Dev/Repo/deploy/node_modules/graceful-fs/graceful-fs.js:99:16
    at /Users/rylewis/Documents/Dev/Repo/deploy/node_modules/graceful-fs/graceful-fs.js:43:10
    at FSReqWrap.oncomplete (fs.js:123:15)
@pmuens
Copy link
Contributor

pmuens commented Jun 9, 2017

Thanks for reporting @ryanmurakami 👍

Investigating...

@pmuens pmuens added this to the 1.16 milestone Jun 9, 2017
@HyperBrain
Copy link
Member

The same happens on Windows for me. I investigated the issue -> the problem for me is, that the interpreter (in this case node and env) is specified by a she-bang in the tabtab script file and the script is invoked by just specifying the tabtab install command line. This will only succeed, if the executables in the she-bang are found at exactly the specified location (here: /usr/bin/env).

This is the tabtab file:

#!/usr/bin/env node

process.env.DEBUG = process.env.DEBUG || 'tabtab*';
require('../src/cli');

A solution that will work on all systems is, to invoke the bin/tabtab script explicitly with the node executable as interpreter -> node ./node_modules/tabtab/bin/tabtab install ... instead of just calling the script (and let the shell determine what to do), or even running node ./node_modules/tabtab/src/cli instead of the script in postinstall.js. The cli would be even better as it is pure node and not a she-banged shell script.

@pmuens
Copy link
Contributor

pmuens commented Jun 9, 2017

Thanks for the update @HyperBrain 👍

That sounds reasonable. Looking into it now...

@HyperBrain
Copy link
Member

For completeness: here the exact output of my npm install error:

> serverless@1.15.0 postinstall C:\Projects\serverless\serverless
> node ./scripts/postinstall.js

'.' is not recognized as an internal or external command,
operable program or batch file.
'.' is not recognized as an internal or external command,
operable program or batch file.
Unhandled rejection Error: Command failed: ./node_modules/tabtab/bin/tabtab install --name serverless --stdout
'.' is not recognized as an internal or external command,
operable program or batch file.

@pmuens
Copy link
Contributor

pmuens commented Jun 9, 2017

I just PRed a fix for that in #3763

Can anyone confirm that this works? /cc @HyperBrain @ryanmurakami ? Thanks!

@efenderbosch
Copy link

We are also getting an error when installing 1.15.1, but the error looks different.

/usr/lib/node_modules/serverless/node_modules/write-file-atomic/index.js:132
    throw err
    ^

Error: EACCES: permission denied, open '/root/.serverlessrc.1718049435'
    at Error (native)
    at Object.fs.openSync (fs.js:641:18)
    at Function.writeFileSync [as sync] (/usr/lib/node_modules/serverless/node_modules/write-file-atomic/index.js:117:17)
    at createConfig (/usr/lib/node_modules/serverless/lib/utils/config/index.js:30:19)
    at getConfig (/usr/lib/node_modules/serverless/lib/utils/config/index.js:44:5)
    at Object.get (/usr/lib/node_modules/serverless/lib/utils/config/index.js:90:18)
    at isTrackingDisabled (/usr/lib/node_modules/serverless/lib/utils/isTrackingDisabled.js:6:22)
    at Object.<anonymous> (/usr/lib/node_modules/serverless/lib/utils/segment.js:9:30)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/usr/lib/node_modules/serverless/lib/classes/Utils.js:14:17)
npm ERR! Linux 4.9.27-moby
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "install" "-g" "serverless"
npm ERR! node v6.10.3
npm ERR! npm  v3.10.10
npm ERR! code ELIFECYCLE

npm ERR! serverless@1.15.1 postinstall: `node ./scripts/postinstall.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the serverless@1.15.1 postinstall script 'node ./scripts/postinstall.js'.

Environment:
Centos 7
node 6.10.2
npm 3.10.10

Is this the same problem, or something different?

@ryanmurakami
Copy link
Member Author

@efenderbosch I think that's related to #3757, not this one.

@pmuens
Copy link
Contributor

pmuens commented Jun 9, 2017

@efenderbosch yes, @ryanmurakami is right 👍

We'll do a patch release the upcoming hours. This should be fixed with #3763

@ryanmurakami
Copy link
Member Author

@pmuens Thanks for the quick fix!

@pmuens
Copy link
Contributor

pmuens commented Jun 9, 2017

@pmuens Thanks for the quick fix!

Thanks for reporting @ryanmurakami 👍 !

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

No branches or pull requests

4 participants