Open njh opened 6 years ago
The way we get around this is to provide an environment variable to mock which node-gyp receives to do effectively the same thing as your shell script.
We run this as a shell script in our CI server to setup the environment config:
echo "config_opts['environment']['npm_config_nodedir'] = '/usr'" >> /etc/mock/site-defaults.cfg
Ahh! Thanks Chris!
npm-gyp is so cryptic. How is anyone supposed to know, based on the above error messages, that it is solved by setting npm_config_nodedir
to /usr/
. I wonder why it doesn't try looking in /usr anyway.
I think a note in the README would be really helpful, as it's environment specific. It wouldn't necessarily effect everyone trying to build an RPM and you may have headers in different places so I don't want to setup speculate in a way which would break other people.
This can be closed when #58 is merged
Hi,
I have been trying to build a small application that generates images using node-canvas.
canvas
uses the Cairo C library to do all the hard work and fortunately it exists as an RPM in CentOS 7.However when building using mock, I was getting errors that I didn't see when building using outside of a chroot. Annoyingly the error messages weren't very helpful and say things like "This is most likely not a problem with node-gyp" but concealed the actual problem.
This is the command I was running:
mock -r epel-7-x86_64 --rebuild --no-clean SRPMS/foo.src.rpm
And this part of the output:
Within the mock environment, it is not possible to access the internet. This is a good thing because it ensures that you should get the identical output, given the same inputs and not be dependant on the outside world changing. But that didn't explain what was actually failing.
By running
mock -r epel-7-x86_64 --shell
, I was able to inspect the mock build environment and see what is going on. I ran node-gyp manually within thenode_modules/canvas
directory:So node-gyp is failing because it is trying to download the C headers for the current version of node-js. These same headers are provided by the
nodejs-devel
RPM and they are installed into/usr/include/node
. I guess node-gyp doesn't know that they are there. Or doesn't know that they are the right headers for the current version of node.I managed to work round the problem by writing a shell script to copy the headers from
/usr/include/node
to~/.node-gyp/6.14.3/include/node/
There is a shell script to do this here: https://gist.github.com/njh/189eccddaa5c05dda4608edc5301481f
%build
section of the speculate template?