badges / gh-badges

Go to badges/shields. Especially if you don't know why. (This repo is old.)
http://img.shields.io/
Creative Commons Zero v1.0 Universal
86 stars 29 forks source link

Installation in Node.js v5.8.0 - Compilation error #48

Closed dzielin closed 8 years ago

dzielin commented 8 years ago

I installed gh-badges a few days ago on a server running Node.js v0.10.25. For that installation, npm was able to complete the install after I did the following things in order:

apt-get update
apt-get install libcairo2-dev libturbojpeg libjpeg-dev libpango1.0-dev libgif-dev build-essential g++
npm install -g canvas
npm install -g gh-badges

Unfortunately, after upgrading Node, I'm getting some errors I wasn't getting before:

npm WARN deprecated graceful-fs@3.0.8: graceful-fs version 3 and before will fail on newer node releases. Please update to graceful-fs@^4.0.0 as soon as possible.
npm WARN deprecated graceful-fs@2.0.3: graceful-fs version 3 and before will fail on newer node releases. Please update to graceful-fs@^4.0.0 as soon as possible.
npm WARN deprecated npmconf@2.1.1: this package has been reintegrated into npm and is now out of date with respect to npm
/usr/bin/badge -> /usr/lib/node_modules/gh-badges/gh-badge.js

> canvas@1.1.6 install /usr/lib/node_modules/gh-badges/node_modules/canvas
> node-gyp rebuild

gyp WARN EACCES user "root" does not have permission to access the dev dir "/root/.node-gyp/5.8.0"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/lib/node_modules/gh-badges/node_modules/canvas/.node-gyp"
make: Entering directory '/usr/lib/node_modules/gh-badges/node_modules/canvas/build'
  SOLINK_MODULE(target) Release/obj.target/canvas-postbuild.node
  COPY Release/canvas-postbuild.node
  CXX(target) Release/obj.target/canvas/src/Canvas.o
In file included from ../src/Canvas.h:22:0,
                 from ../src/Canvas.cc:7:
../node_modules/nan/nan.h: In function 'v8::Local<v8::Signature> NanNew(v8::Handle<v8::FunctionTemplate>, int, v8::Handle<v8::FunctionTemplate>*)':
../node_modules/nan/nan.h:342:78: error: no matching function for call to 'v8::Signature::New(v8::Isolate*, v8::Handle<v8::FunctionTemplate>&, int&, v8::Handle<v8::FunctionTemplate>*&)'
     return v8::Signature::New(v8::Isolate::GetCurrent(), receiver, argc, argv);
                                                                              ^
../node_modules/nan/nan.h:342:78: note: candidate is:
In file included from ../src/Canvas.h:11:0,
                 from ../src/Canvas.cc:7:
/usr/lib/node_modules/gh-badges/node_modules/canvas/.node-gyp/5.8.0/include/node/v8.h:4674:27: note: static v8::Local<v8::Signature> v8::Signature::New(v8::Isolate*, v8::Local<v8::FunctionTemplate>)
   static Local<Signature> New(
                           ^
/usr/lib/node_modules/gh-badges/node_modules/canvas/.node-gyp/5.8.0/include/node/v8.h:4674:27: note:   candidate expects 2 arguments, 4 provided
In file included from ../src/Canvas.h:22:0,
                 from ../src/Canvas.cc:7:
../node_modules/nan/nan.h: At global scope:
../node_modules/nan/nan.h:424:3: error: redefinition of 'v8::Local<T> NanNew(P) [with T = v8::StringObject; P = v8::Local<v8::String>]'
   NanNew<v8::StringObject, v8::Handle<v8::String> >(
   ^
../node_modules/nan/nan.h:417:3: error: 'v8::Local<T> NanNew(P) [with T = v8::StringObject; P = v8::Local<v8::String>]' previously declared here
   NanNew<v8::StringObject, v8::Local<v8::String> >(
   ^
../node_modules/nan/nan.h:442:36: error: redefinition of 'template<class T> v8::Local<v8::RegExp> NanNew(v8::Local<v8::String>, v8::RegExp::Flags)'
   NAN_INLINE v8::Local<v8::RegExp> NanNew(
                                    ^
../node_modules/nan/nan.h:436:36: error: 'template<class T> v8::Local<v8::RegExp> NanNew(v8::Handle<v8::String>, v8::RegExp::Flags)' previously declared here
   NAN_INLINE v8::Local<v8::RegExp> NanNew(
                                    ^
../node_modules/nan/nan.h:454:36: error: redefinition of 'template<class T, class P> v8::Local<v8::RegExp> NanNew(v8::Local<v8::String>, v8::RegExp::Flags)'
   NAN_INLINE v8::Local<v8::RegExp> NanNew(
                                    ^
../node_modules/nan/nan.h:448:36: error: 'template<class T, class P> v8::Local<v8::RegExp> NanNew(v8::Handle<v8::String>, v8::RegExp::Flags)' previously declared here
   NAN_INLINE v8::Local<v8::RegExp> NanNew(
                                    ^
../node_modules/nan/nan.h:623:19: error: 'NanNew' declared as an 'inline' variable
       v8::String::ExternalAsciiStringResource *resource) {
                   ^
../node_modules/nan/nan.h:623:19: warning: 'always_inline' attribute ignored [-Wattributes]
../node_modules/nan/nan.h:623:19: error: 'v8::Local<v8::String> NanNew' redeclared as different kind of symbol
../node_modules/nan/nan.h:617:36: error: previous declaration of 'v8::Local<v8::String> NanNew(v8::String::ExternalStringResource*)'
   NAN_INLINE v8::Local<v8::String> NanNew(
                                    ^
../node_modules/nan/nan.h:623:7: error: 'ExternalAsciiStringResource' is not a member of 'v8::String'
       v8::String::ExternalAsciiStringResource *resource) {
       ^
../node_modules/nan/nan.h:623:48: error: 'resource' was not declared in this scope
       v8::String::ExternalAsciiStringResource *resource) {
                                                ^
../node_modules/nan/nan.h:637:27: error: redefinition of 'template<class T> v8::Local<T> _NanEscapeScopeHelper(v8::Local<T>)'
   NAN_INLINE v8::Local<T> _NanEscapeScopeHelper(v8::Local<T> val) {
                           ^
../node_modules/nan/nan.h:632:27: error: 'template<class T> v8::Local<T> _NanEscapeScopeHelper(v8::Handle<T>)' previously declared here
   NAN_INLINE v8::Local<T> _NanEscapeScopeHelper(v8::Handle<T> val) {
                           ^
../node_modules/nan/nan.h:889:13: error: 'node::smalloc' has not been declared
     , node::smalloc::FreeCallback callback
             ^
../node_modules/nan/nan.h:889:35: error: expected ',' or '...' before 'callback'
     , node::smalloc::FreeCallback callback
                                   ^
../node_modules/nan/nan.h: In function 'v8::Local<v8::Object> NanNewBufferHandle(char*, size_t, int)':
../node_modules/nan/nan.h:893:50: error: 'callback' was not declared in this scope
         v8::Isolate::GetCurrent(), data, length, callback, hint);
                                                  ^
../node_modules/nan/nan.h:893:60: error: 'hint' was not declared in this scope
         v8::Isolate::GetCurrent(), data, length, callback, hint);
                                                            ^
../node_modules/nan/nan.h: In function 'v8::Local<v8::Object> NanNewBufferHandle(const char*, uint32_t)':
../node_modules/nan/nan.h:900:67: error: call of overloaded 'New(v8::Isolate*, const char*&, uint32_t&)' is ambiguous
     return node::Buffer::New(v8::Isolate::GetCurrent(), data, size);
                                                                   ^
../node_modules/nan/nan.h:900:67: note: candidates are:
In file included from ../node_modules/nan/nan.h:179:0,
                 from ../src/Canvas.h:22,
                 from ../src/Canvas.cc:7:
/usr/lib/node_modules/gh-badges/node_modules/canvas/.node-gyp/5.8.0/include/node/node_buffer.h:31:40: note: v8::MaybeLocal<v8::Object> node::Buffer::New(v8::Isolate*, v8::Local<v8::String>, node::encoding) <near match>
 NODE_EXTERN v8::MaybeLocal<v8::Object> New(v8::Isolate* isolate,
                                        ^
/usr/lib/node_modules/gh-badges/node_modules/canvas/.node-gyp/5.8.0/include/node/node_buffer.h:31:40: note:   no known conversion for argument 3 from 'uint32_t {aka unsigned int}' to 'node::encoding'
/usr/lib/node_modules/gh-badges/node_modules/canvas/.node-gyp/5.8.0/include/node/node_buffer.h:43:40: note: v8::MaybeLocal<v8::Object> node::Buffer::New(v8::Isolate*, char*, size_t) <near match>
 NODE_EXTERN v8::MaybeLocal<v8::Object> New(v8::Isolate* isolate,
                                        ^
/usr/lib/node_modules/gh-badges/node_modules/canvas/.node-gyp/5.8.0/include/node/node_buffer.h:43:40: note:   no known conversion for argument 2 from 'const char*' to 'char*'
In file included from ../src/Canvas.h:22:0,
                 from ../src/Canvas.cc:7:
../node_modules/nan/nan.h: In function 'v8::Local<v8::Object> NanNewBufferHandle(uint32_t)':
../node_modules/nan/nan.h:904:61: error: could not convert 'node::Buffer::New(v8::Isolate::GetCurrent(), ((size_t)size))' from 'v8::MaybeLocal<v8::Object>' to 'v8::Local<v8::Object>'
     return node::Buffer::New(v8::Isolate::GetCurrent(), size);
                                                             ^
../node_modules/nan/nan.h: In function 'v8::Local<v8::Object> NanBufferUse(char*, uint32_t)':
../node_modules/nan/nan.h:911:12: error: 'Use' is not a member of 'node::Buffer'
     return node::Buffer::Use(v8::Isolate::GetCurrent(), data, size);
            ^
../node_modules/nan/nan.h: In function 'bool _NanGetExternalParts(v8::Handle<v8::Value>, const char**, size_t*)':
../node_modules/nan/nan.h:1993:12: error: 'class v8::String' has no member named 'IsExternalAscii'
   if (str->IsExternalAscii()) {
            ^
../node_modules/nan/nan.h:1994:11: error: 'ExternalAsciiStringResource' in 'class v8::String' does not name a type
     const v8::String::ExternalAsciiStringResource* ext;
           ^
../node_modules/nan/nan.h:1995:5: error: 'ext' was not declared in this scope
     ext = str->GetExternalAsciiStringResource();
     ^
../node_modules/nan/nan.h:1995:16: error: 'class v8::String' has no member named 'GetExternalAsciiStringResource'
     ext = str->GetExternalAsciiStringResource();
                ^
../node_modules/nan/nan.h: In function 'v8::Local<v8::Object> NanNewBufferHandle(const char*, uint32_t)':
../node_modules/nan/nan.h:901:3: warning: control reaches end of non-void function [-Wreturn-type]
   }
   ^
make: *** [Release/obj.target/canvas/src/Canvas.o] Error 1
make: Leaving directory '/usr/lib/node_modules/gh-badges/node_modules/canvas/build'
gyp ERR! build error 
gyp ERR! stack Error: 'make' failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:276:23)
gyp ERR! stack     at emitTwo (events.js:100:13)
gyp ERR! stack     at ChildProcess.emit (events.js:185:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:204:12)
gyp ERR! System Linux 3.19.0-25-generic
gyp ERR! command "/usr/bin/nodejs" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /usr/lib/node_modules/gh-badges/node_modules/canvas
gyp ERR! node -v v5.8.0
gyp ERR! node-gyp -v v3.2.1
gyp ERR! not ok 
/usr/lib
└── (empty)

npm ERR! Linux 3.19.0-25-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install" "-g" "gh-badges"
npm ERR! node v5.8.0
npm ERR! npm  v3.7.3
npm ERR! code ELIFECYCLE

npm ERR! canvas@1.1.6 install: 'node-gyp rebuild'
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the canvas@1.1.6 install script 'node-gyp rebuild'.
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 canvas package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs canvas
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls canvas
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /root/npm-debug.log
npm ERR! code 1

Since upgrading node, I have removed all existing node_modules and have been reinstalling them manually using npm to ensure they're installed properly with the new version of Node.

dzielin commented 8 years ago

Not sure what the policy is on double-posts... but this update warrants a separate comment.

I was able to get the basic svg functionality working like before. I created a temp directory. I installed the latest version of using 'npm install -g canvas.' From there, I cloned the repo into the temp directory. I updated the package.json to use the latest version for all dependencies.

Once that was done, I ran npm install to install the dependencies. This got stuck on an infinite loop with a message like:

gyp WARN EACCES user "root" does not have permission to access the dev dir "/root/temp/gh-badges/node_modules/gh-badges/node_modules/canvas/.node-gyp/5.8.0"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/root/temp/gh-badges/node_modules/gh-badges/node_modules/canvas/.node-gyp"

So, I recursively set the permissions of the node_modules directory to 777. I re-ran npm install and the dependencies were able to finish installing without error. From there, I ran 'npm install -g .' to install gh-badges globally, then removed the temp directory. Worked like a charm!

I haven't done any thorough testing. The mocha tests fail miserably, but I'm able to create my svg badges again, so I'm not too worried about it. Still, this compatibility issue seems like something important to look into.

espadrine commented 8 years ago

Thanks for describing your issues. I am glad you found a solution. I am definitely interested in improving the ease of installation by avoiding the use of node-canvas, which causes both your NAN issue and your circular dependency issue.

As a side-note, the gh-badges project has switched location to https://github.com/badges/shields/.