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

Install /build failure in docker image #466

Closed
ashander opened this issue Mar 17, 2016 · 5 comments
Closed

Install /build failure in docker image #466

ashander opened this issue Mar 17, 2016 · 5 comments

Comments

@ashander
Copy link

Using docker pull node:5.8.0 from the dockerfile here the build failed on rabin@1.4.0. (Relevant part of the log is below)

I will try to look into this more at some point, but at least it should be reproducible ;)

Tail of the log

> rabin@1.4.0 install /usr/local/lib/node_modules/dat/node_modules/rabin
> prebuild --download && echo "Installed prebuilt binary successfully.
"

prebuild info begin Prebuild version 2.9.2
prebuild info looking for local prebuild @ prebuilds/rabin-v1.4.0-node-v47-linux-x64.tar.gz
prebuild WARN install EACCES: permission denied, access '/root/.npm'
prebuild info install We will now try to compile from source.
prebuild ERR! configure error
prebuild ERR! stack Error: Invalid version number: 0.10.40,0.12.7,1.0.4,1.8.4,2.4.0,3.0.0,4.0.0,5.0.0
prebuild ERR! stack     at getNodeDir (/usr/local/lib/node_modules/dat/node_modules/node-gyp/lib/configure.js:69:25)
prebuild ERR! stack     at /usr/local/lib/node_modules/dat/node_modules/node-gyp/lib/configure.js:41:7
prebuild ERR! stack     at /usr/local/lib/node_modules/dat/node_modules/node-gyp/lib/configure.js:393:9
prebuild ERR! stack     at ChildProcess.exithandler (child_process.js:193:7)
prebuild ERR! stack     at emitTwo (events.js:100:13)
prebuild ERR! stack     at ChildProcess.emit (events.js:185:7)
prebuild ERR! stack     at maybeClose (internal/child_process.js:850:16)
prebuild ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:215:5)
prebuild ERR! not ok
prebuild ERR! build Error: Invalid version number: 0.10.40,0.12.7,1.0.4,1.8.4,2.4.0,3.0.0,4.0.0,5.0.0
prebuild ERR! build     at getNodeDir (/usr/local/lib/node_modules/dat/node_modules/node-gyp/lib/configure.js:69:25)
prebuild ERR! build     at /usr/local/lib/node_modules/dat/node_modules/node-gyp/lib/configure.js:41:7
prebuild ERR! build     at /usr/local/lib/node_modules/dat/node_modules/node-gyp/lib/configure.js:393:9
prebuild ERR! build     at ChildProcess.exithandler (child_process.js:193:7)
prebuild ERR! build     at emitTwo (events.js:100:13)
prebuild ERR! build     at ChildProcess.emit (events.js:185:7)
prebuild ERR! build     at maybeClose (internal/child_process.js:850:16)
prebuild ERR! build     at Process.ChildProcess._handle.onexit (internal/child_process.js:215:5)
npm info lifecycle rabin@1.4.0~install: Failed to exec install script
/usr/local/lib
`-- (empty)

npm ERR! Linux 4.2.0-30-generic
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g" "dat"
npm ERR! node v5.8.0
npm ERR! npm  v3.7.3
npm ERR! code ELIFECYCLE

npm ERR! rabin@1.4.0 install: `prebuild --download && echo "Installed prebuilt binary successfully.
npm ERR! "`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the rabin@1.4.0 install script 'prebuild --download && echo "Installed prebuilt binary successfully.
npm ERR! "'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the rabin package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     prebuild --download && echo "Installed prebuilt binary successfully.
npm ERR! "
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs rabin
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls rabin
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /npm-debug.log
npm ERR! code 1
@joehand
Copy link
Collaborator

joehand commented Mar 17, 2016

Hi, @ashander this looks like a npm permissions issue. The issue is with installing node-gyp and mismatched permissions (root vs docker user).

Either you'll need to make sure your user owns the .npm directory or change how you are installing dat. Here is a similar issue in the npm docker repo. There are a few potential solutions there (and then linked also to the node-gyp issues) depending on how you'd like to use your docker container.

Hopefully that helps the debugging!

@ashander
Copy link
Author

Thanks Joe! I noticed the README mentions this too: https://docs.npmjs.com/getting-started/fixing-npm-permissions

Unfortunately I didn't notice before filing the issue that EACCES shows up in my log. Otherwise, I would have gone down the permissions rabbit hole first. - Jaime

@mafintosh
Copy link
Contributor

npm install dat --unsafe should fix it as well.

mafintosh added a commit to dat-ecosystem-archive/rabin that referenced this issue Mar 17, 2016
@ashander
Copy link
Author

@mafintosh thanks! This worked on the node 5.8 image without any other permission fix. The issue, as I understand it, was this:

  • on a docker container, npm will be run as root unless some other user is set
  • as detailed in the USER section of npm-scripts docs, unless --unsafe-perm flag is set, scripts aren't run as root

Thanks again.

For completeness, this is what worked:

docker pull node:5.8
docker run node:5.8 npm install -g --unsafe dat
#...
#npm info it worked if it ends with ok
#npm info using npm@3.7.3
#npm info using node@v5.8.0
#+-- dat@9.8.2
# ...
#npm info ok

@ashander
Copy link
Author

For others who run into this, I'll also note that the steps suggested under option 1 to change permissions (namely chown -R $(whoami) $(npm config get prefix)/{lib/node_modules,bin,share}) do NOT work alone. Changing this does remove the EACCES error, but an ELIFECYCLE error remains

$ grep EACCES npm-debug.log
$ grep -C 10 ELIFECYCLE npm-debug.log
#32944 verbose stack     at emitTwo (events.js:100:13)
#32944 verbose stack     at ChildProcess.emit (events.js:185:7)
#32944 verbose stack     at maybeClose (internal/child_process.js:850:16)
#32944 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:215:5)
#32945 verbose pkgid rabin@1.4.0
#32946 verbose cwd /
#32947 error Linux 4.1.18-boot2docker
#32948 error argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g" "dat"
#32949 error node v5.9.0
#32950 error npm  v3.7.3
#32951 error code ELIFECYCLE
#32952 error rabin@1.4.0 install: `prebuild --download && echo "Installed prebuilt binary successfully.
#32952 error "`
#32952 error Exit status 2
#32953 error Failed at the rabin@1.4.0 install script 'prebuild --download && echo "Installed prebuilt #binary successfully.
#32953 error "'.
#32953 error Make sure you have the latest version of node.js and npm installed.
#32953 error If you do, this is most likely a problem with the rabin package,
#32953 error not with npm itself.
#32953 error Tell the author that this fails on your system:
#32953 error     prebuild --download && echo "Installed prebuilt binary successfully.
$

I think this is because of what I wrote above: the scripts command is still run as non-root.

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

3 participants