unit icon indicating copy to clipboard operation
unit copied to clipboard

Cant install npm package `unit-http`, "libunit version mismatch"

Open mStirner opened this issue 10 months ago • 5 comments

I have freshly installed, unit & unit-dev via apt on my ubuntu 22.04.4. When i run npm install -g --unsafe-perm unit-http i get a "libunit version mismatch":

npm ERR! code 1
npm ERR! path /home/marc/.nvm/versions/node/v20.11.1/lib/node_modules/unit-http
npm ERR! command failed
npm ERR! command sh -c node-gyp configure build
npm ERR! make: Verzeichnis „/home/marc/.nvm/versions/node/v20.11.1/lib/node_modules/unit-http/build“ wird betreten
npm ERR!   CXX(target) Release/obj.target/unit-http/unit.o
npm ERR! make: Verzeichnis „/home/marc/.nvm/versions/node/v20.11.1/lib/node_modules/unit-http/build“ wird verlassen
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using [email protected]
npm ERR! gyp info using [email protected] | linux | x64
npm ERR! gyp info find Python using Python version 3.10.12 found at "/usr/bin/python3"
npm ERR! gyp info spawn /usr/bin/python3
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args '/home/marc/.nvm/versions/node/v20.11.1/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
npm ERR! gyp info spawn args 'binding.gyp',
npm ERR! gyp info spawn args '-f',
npm ERR! gyp info spawn args 'make',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/home/marc/.nvm/versions/node/v20.11.1/lib/node_modules/unit-http/build/config.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/home/marc/.nvm/versions/node/v20.11.1/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/home/marc/.cache/node-gyp/20.11.1/include/node/common.gypi',
npm ERR! gyp info spawn args '-Dlibrary=shared_library',
npm ERR! gyp info spawn args '-Dvisibility=default',
npm ERR! gyp info spawn args '-Dnode_root_dir=/home/marc/.cache/node-gyp/20.11.1',
npm ERR! gyp info spawn args '-Dnode_gyp_dir=/home/marc/.nvm/versions/node/v20.11.1/lib/node_modules/npm/node_modules/node-gyp',
npm ERR! gyp info spawn args '-Dnode_lib_file=/home/marc/.cache/node-gyp/20.11.1/<(target_arch)/node.lib',
npm ERR! gyp info spawn args '-Dmodule_root_dir=/home/marc/.nvm/versions/node/v20.11.1/lib/node_modules/unit-http',
npm ERR! gyp info spawn args '-Dnode_engine=v8',
npm ERR! gyp info spawn args '--depth=.',
npm ERR! gyp info spawn args '--no-parallel',
npm ERR! gyp info spawn args '--generator-output',
npm ERR! gyp info spawn args 'build',
npm ERR! gyp info spawn args '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! gyp info spawn make
npm ERR! gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
npm ERR! In file included from ../unit.h:9,
npm ERR!                  from ../unit.cpp:6:
npm ERR! ../nxt_napi.h:20:2: error: #error "libunit version mismatch."
npm ERR!    20 | #error "libunit version mismatch."
npm ERR!       |  ^~~~~
npm ERR! make: *** [unit-http.target.mk:105: Release/obj.target/unit-http/unit.o] Fehler 1
npm ERR! gyp ERR! build error 
npm ERR! gyp ERR! stack Error: `make` failed with exit code: 2
npm ERR! gyp ERR! stack at ChildProcess.<anonymous> (/home/marc/.nvm/versions/node/v20.11.1/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:209:23)
npm ERR! gyp ERR! System Linux 6.5.0-1019-oem
npm ERR! gyp ERR! command "/home/marc/.nvm/versions/node/v20.11.1/bin/node" "/home/marc/.nvm/versions/node/v20.11.1/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "build"
npm ERR! gyp ERR! cwd /home/marc/.nvm/versions/node/v20.11.1/lib/node_modules/unit-http
npm ERR! gyp ERR! node -v v20.11.1
npm ERR! gyp ERR! node-gyp -v v10.0.1
npm ERR! gyp ERR! not ok

Followed the install steps: https://unit.nginx.org/installation/#node-js

node.js version: v20.11.1 npm version: v10.2.4 os version: Ubuntu 22.04.4 LTS node-gyp version: v10.1.0

How can i fix this/install unit-http & why does it not download a pre-compiled version from npm?

Thanks in advance

mStirner avatar Apr 17 '24 12:04 mStirner

npm ERR! ../nxt_napi.h:20:2: error: #error "libunit version mismatch." npm ERR! 20 | #error "libunit version mismatch." npm ERR! | ^~~~~

In simple terms this means the version of unit-http you're trying to build/install is from a different version of unit to what you're trying to build/install against.

The check it's failing on is

#if NXT_VERNUM != NXT_NODE_VERNUM                                               
#error "libunit version mismatch."                                              
#endif 

from src/nodejs/unit-http/nxt_napi.h

These versions essentially come from the version file in the repository root.

However seeing as you installed unit via your package manager you'd either need to install the nodejs language module likewise, or build it from the Unit source having checked out the version that matches what you have installed.

Any reason not to just use the packaged module though?

ac000 avatar Apr 17 '24 14:04 ac000

Im not sure if i understand correctly.

I have unit installed via apt. Followed the install steps for the unit-http module.

Is there a version relationship between the unit-http npm module & unit/unit-dev from apt? What version do i need to change (to what) that i can build the unit-http module?

I have unit v1.32.1 installed. The latest release of unit-http is v1.32.0. Would it work if both versions match?

Any reason not to just use the packaged module though?

What module are you meaning?


To clarify things: I just copy & pasted all your installation guide's.

  • Install unit/unit-dev: https://unit.nginx.org/installation/#ubuntu-2204
  • Install unit-http via npm: https://unit.nginx.org/installation/#node-js

I do not want to use any specific version or any other kind of special case. Just wanted to start as easy as possible.

mStirner avatar Apr 17 '24 15:04 mStirner

I have unit v1.32.1 installed. The latest release of unit-http is v1.32.0.
Would it work if both versions match?

Yes, they both need to be the same version.

So it broke before because

NXT_VERNUM is 13201 and NXT_NODE_VERNUM is 13200

What module are you meaning?

Hmm, so there is no nodejs module package...

ac000 avatar Apr 17 '24 15:04 ac000

Yes, they both need to be the same version.

Ok, now i understand.

Any reason there is not a unit-http v1.32.1 module in the npm registry?

There should also be a note on the docs (https://unit.nginx.org/installation/#node-js) that the unit & unit-http module need matching version numbers.

mStirner avatar Apr 17 '24 15:04 mStirner

Any reason there is not a unit-http v1.32.1 module in the npm registry?

Not sure, probably an oversight, maybe @tippexs or @thresheek knows?

There should also be a note on the docs (https://unit.nginx.org/installation/#node-js) that the unit & unit-http module need matching version numbers.

Indeed, that vital bit of information does seem to be missing... (I'll open a unit-docs issue for it)

ac000 avatar Apr 17 '24 16:04 ac000