No rule to make target '../.node-gyp/0.10.36/common.gypi', needed by 'Makefile #165

Open
jywarren opened this Issue Jun 5, 2015 · 9 comments

Comments

Projects
None yet
3 participants

jywarren commented Jun 5, 2015

In voodootikigod/node-serialport#535 (comment) I've been documenting a difficulty with installing serialport which depends on node-pre-gyp, and have seen the following error (or possibly two):

gyp WARN EACCES user "root" does not have permission to access the dev dir "/root/.node-gyp/0.10.36"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/local/lib/node_modules/serialport/.node-gyp"
make: Entering directory '/usr/local/lib/node_modules/serialport/build'
make: *** No rule to make target '../.node-gyp/0.10.36/common.gypi', needed by 'Makefile'.  Stop.
make: Leaving directory '/usr/local/lib/node_modules/serialport/build'

Is this a node-pre-gyp issue or a node-serialport issue? If the latter, please feel free to close, but is there perhaps a patch I could submit to node-serialport to resolve it? Thanks in advance for any help.

Member

springmeyer commented Jun 23, 2015

hi @jywarren! Nice to see ya, but sorry about the trouble. Those errors look related to permissions only. Are you perhaps running as root? If so can you run as a normal user? I'm aware that npm does not work correctly when run as root unless you also pass --unsafe-perm npm/npm#3497.

That said if this is not the issue happy to try to help more. Basically node-pre-gyp and node-gyp both need to be callable as command line tools. So if permissions are off they often break, but the underlying problem can only be fixed by fixing permissions.

Hi Dane and Jeff! Funny finding you on this corner of the Internet today :)

I got the same error when running this dockerfile today, it blows up when running the npm install dat as dat uses leveldown which uses node-pre-gyp.

I tried adding RUN npm install node-gyp-install -g and RUN node-gyp-install to the above Dockerfile but that didn't help. I'll post back if I figure out if it's a permissions thing I can fix or not...

Member

springmeyer commented Jun 24, 2015

@maxogden hi! thanks for helping out. Okay, so sounds like there must be some bad interaction of node-pre-gyp somehow. Are you able to replicate outside of docker? Let me know what you find.

here's what fixed it for us mafintosh/try-dat@88c7527. not sure what the underlying cause is though

Member

springmeyer commented Jun 24, 2015

If that fixed it then the cause is likely:

  • you are running as root
  • therefore npm blocks usage of command line tools
  • therefore somewhere in the logs there is likely a cannot run in wd message which indicates that npm blocked the call to node-pre-gyp

It's not clear to me there is any other workaround other than --unsafe-perm as per npm/npm#3497.

Over at #162 we are revisiting the idea of whether some other way of calling node-pre-gyp might solve other edge cases. Like "install": "node -e \"require('node-pre-gyp').install()\"". But I fear that shelling out to node might still incur this problem and npm would block it when root?

Thanks, we'll try that! Great to see you both here :-)

Member

springmeyer commented Jun 26, 2015

noticed that when npm denies being able to run node-pre-gyp when running as root the problem is not an error but an early return: https://github.com/npm/npm/blob/4e7db7dab54bf30615caa2e8f3c6b2db6b59c258/lib/utils/lifecycle.js#L54-L57

So that explains why this results in such confusing later errors because the install state is undefined.

Member

springmeyer commented Jun 26, 2015

I wonder if there is some way to catch when root is being used with npm and stop the process with a clearer message. /cc @othiym23 for ideas.

@springmeyer springmeyer referenced this issue in mapbox/node-sqlite3 Jul 9, 2015

Closed

sqlite3 install error - node-pre-gyp: not found #474

Member

springmeyer commented Jul 9, 2015

@othiym23 - can you help advise on this problem? Should I recommend people not run as root? Should I recommend always passing --unsafe-perm when using docker + node installs? Is there something I can change about node-pre-gyp that would avoid this pitfall completely? As docker grows in popularity this is starting to happen frequently: mapbox/node-sqlite3#474

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