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

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

@jywarren
Copy link

jywarren commented Jun 5, 2015

In serialport/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.

@springmeyer
Copy link
Contributor

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.

@max-mapper
Copy link

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

@springmeyer
Copy link
Contributor

@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.

@max-mapper
Copy link

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

@springmeyer
Copy link
Contributor

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?

@jywarren
Copy link
Author

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

@springmeyer
Copy link
Contributor

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.

@springmeyer
Copy link
Contributor

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
Copy link
Contributor

@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: TryGhost/node-sqlite3#474

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