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

Fail to build nsfw with node-gyp on Ubuntu #109

Closed
drochgenius opened this issue Apr 8, 2020 · 5 comments
Closed

Fail to build nsfw with node-gyp on Ubuntu #109

drochgenius opened this issue Apr 8, 2020 · 5 comments

Comments

@drochgenius
Copy link

drochgenius commented Apr 8, 2020

Problem description

In my CI build, yarn install was working properly until yesterday where is started to throw an error while building nsfw with node-gyp at step 4 of the yarn install.

Based on the traceback, it seems there are errors in the NSFW C++ code.

Take note that install works fine in MacOS, the issue is only reproducible on Linux Ubuntu.

I have also opened a similar issue on the Yarn Github repo: yarnpkg/yarn#8046

Can you please advise?

Traceback

error /node_modules/nsfw: Command failed.
Exit code: 1
Command: node-gyp rebuild
Arguments:
Directory: /node_modules/nsfw
Output:
gyp info it worked if it ends with ok
gyp info using node-gyp@5.1.0
gyp info using node@10.14.0 | linux | x64
gyp info find Python using Python version 2.7.6 found at "/usr/bin/python"
gyp http GET https://nodejs.org/download/release/v10.14.0/node-v10.14.0-headers.tar.gz
gyp http 200 https://nodejs.org/download/release/v10.14.0/node-v10.14.0-headers.tar.gz
gyp http GET https://nodejs.org/download/release/v10.14.0/SHASUMS256.txt
gyp http 200 https://nodejs.org/download/release/v10.14.0/SHASUMS256.txt
gyp info spawn /usr/bin/python
gyp info spawn args [ '/usr/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args   'binding.gyp',
gyp info spawn args   '-f',
gyp info spawn args   'make',
gyp info spawn args   '-I',
gyp info spawn args   '/node_modules/nsfw/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/usr/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/root/.cache/node-gyp/10.14.0/include/node/common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=/root/.cache/node-gyp/10.14.0',
gyp info spawn args   '-Dnode_gyp_dir=/usr/lib/node_modules/npm/node_modules/node-gyp',
gyp info spawn args   '-Dnode_lib_file=/root/.cache/node-gyp/10.14.0/<(target_arch)/node.lib',
gyp info spawn args   '-Dmodule_root_dir=/node_modules/nsfw',
gyp info spawn args   '-Dnode_engine=v8',
gyp info spawn args   '--depth=.',
gyp info spawn args   '--no-parallel',
gyp info spawn args   '--generator-output',
gyp info spawn args   'build',
gyp info spawn args   '-Goutput_dir=.' ]
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
make: Entering directory `/node_modules/nsfw/build'
  CXX(target) Release/obj.target/nsfw/src/NSFW.o
In file included from ../src/NSFW.cpp:1:0:
../src/../includes/NSFW.h:21:5: error: 'ThreadSafeFunction' in namespace 'Napi' does not name a type
     Napi::ThreadSafeFunction mErrorCallback;
     ^
../src/../includes/NSFW.h:22:5: error: 'ThreadSafeFunction' in namespace 'Napi' does not name a type
     Napi::ThreadSafeFunction mEventCallback;
     ^
../src/NSFW.cpp: In constructor 'NSFW::NSFW(const Napi::CallbackInfo&)':
../src/NSFW.cpp:30:3: error: 'mEventCallback' was not declared in this scope
   mEventCallback = Napi::ThreadSafeFunction::New(
   ^
../src/NSFW.cpp:30:26: error: 'Napi::ThreadSafeFunction' has not been declared
   mEventCallback = Napi::ThreadSafeFunction::New(
                          ^
../src/NSFW.cpp:64:5: error: 'mErrorCallback' was not declared in this scope
     mErrorCallback = Napi::ThreadSafeFunction::New(
     ^
../src/NSFW.cpp:64:28: error: 'Napi::ThreadSafeFunction' has not been declared
     mErrorCallback = Napi::ThreadSafeFunction::New(
                            ^
../src/NSFW.cpp: In destructor 'virtual NSFW::~NSFW()':
../src/NSFW.cpp:77:3: error: 'mErrorCallback' was not declared in this scope
   mErrorCallback.Release();
   ^
../src/NSFW.cpp:78:3: error: 'mEventCallback' was not declared in this scope
   mEventCallback.Release();
   ^
../src/NSFW.cpp: In member function 'virtual void NSFW::StartWorker::Execute()':
../src/NSFW.cpp:113:12: error: 'class NSFW' has no member named 'mErrorCallback'
     mNSFW->mErrorCallback.Acquire();
            ^
../src/NSFW.cpp:114:12: error: 'class NSFW' has no member named 'mEventCallback'
     mNSFW->mEventCallback.Acquire();
            ^
../src/NSFW.cpp: In member function 'void NSFW::pollForEvents()':
../src/NSFW.cpp:204:9: error: 'mErrorCallback' was not declared in this scope
         mErrorCallback.NonBlockingCall([error](Napi::Env env, Napi::Function jsCallback) {
         ^
../src/NSFW.cpp:242:11: error: 'mEventCallback' was not declared in this scope
           mEventCallback.NonBlockingCall(events.release(), callback);
           ^
../src/NSFW.cpp:250:3: error: 'mErrorCallback' was not declared in this scope
   mErrorCallback.Release();
   ^
../src/NSFW.cpp:251:3: error: 'mEventCallback' was not declared in this scope
   mEventCallback.Release();
   ^
make: *** [Release/obj.target/nsfw/src/NSFW.o] Error 1
make: Leaving directory `/node_modules/nsfw/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:194:23)
gyp ERR! stack     at ChildProcess.emit (events.js:182:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:240:12)
gyp ERR! System Linux 4.19.76-linuxkit
gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /node_modules/nsfw
gyp ERR! node -v v10.14.0
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.
@drochgenius
Copy link
Author

drochgenius commented Apr 8, 2020

The issue happens when trying to install Theia IDE dependencies. A workaround is proposed here: eclipse-theia/theia#7510

@implausible
Copy link
Contributor

Aha, looks like ThreadSafeFunction is only available in >=10.16.0. I can do a rerelease with 1.2.9 being only patches (no n-api changes). I will also do a 2.0.0 release that limits the engines to >10.16.0 w/ the napi changes.

@drochgenius
Copy link
Author

Thanks, your explanation makes sense.

I don't think it's worth doing a special release for this because:

  • I have a workaround on Node 10.14.
  • Node 10 Debian package should be updated at some point soon.

Therefore I think it's just a transcient issue.

For the records, the workaround is to add the following to the package.json file to lock nsfw on version 1.2.7:

    "resolutions": {
        "**/**/nsfw": "1.2.7"
    }

@implausible
Copy link
Contributor

Solution: Use 1.2.9 pre 10.16.0. Leverage 2.0.0 when your dependency chain has updated. Also, I highly recommend leveraging nvm instead of leveraging the debian install base for downloading node. It's a lot more flexible and doesn't lock your systems into any particular version of Node.

@drochgenius
Copy link
Author

Thanks @implausible

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

2 participants