nodegit: Can't be installed for Node v16

It seems like nodegit can’t be installed for Node v16? Can anyone confirm if they can?

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Reactions: 27
  • Comments: 44 (5 by maintainers)

Commits related to this issue

Most upvoted comments

I too am having an issue installing nodegit on Node v16.3.0 on Mac OS Big Sur. It seems to install fine on Windows 10 though.

We’re working on resolving some lingering context awareness issues. Once those are addressed, we’ll cut another alpha release. Once that’s been out without issue for a while, we’d like to cut a non-alpha release including these changes.

Could we have prebuilds for node 18? It is now LTS. Node 16 will be EOL in less than a year, whereas node 18 will be supported through 2025, so I would really like to use node 18, but installing from source can be a pain (and slow).

@ianhattendorf any updates on if the current alpha release has met expectations? Conservative ETA for a 0.28.0 drop?

I have since upgraded to Node v18 and installed nodegit v0.28.0-alpha.18, and it installed and runs fine. I know that’s not a solution for everyone, but it might help someone.

I wish nodegit wouldn’t need native builds. Or at least not built with node-gyp. node-gyp has been a pain in the – you know, the place, where the sun doesn’t shine. It’s been problematic ever since its beginnings. It’s complicated and the error messages and traces have never been any good. When using NPM, it’s a nightmare and with yarn it’s even worse.

Alternatively, you might want to think about an option to allow simple spawned calls to the git-cli.

I don’t mind a few split seconds or maybe even seconds more, it would take nodegit to execute when running synchronously.

That’s still more efficient than spending half a day chasing these pesky node-gyp compile errors.

I can install in a node 16 docker container, I can not on my Mac Mojave 10.14.6

info
npm ERR! spawn
npm ERR! make
npm ERR! gyp
npm ERR! info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
npm ERR! In file included from ../src/async_baton.cc:1:
npm ERR! In file included from ../src/../include/async_baton.h:5:
npm ERR! In file included from ../../nan/nan.h:58
npm ERR! :
npm ERR! In file included from /Users/<user>/Library/Caches/node-gyp/16.6.1/include/node/node.h:63:
npm ERR! In file included from /Users/<user>/Library/Caches/node-gyp/16.6.1/include/node/v8.h:30:
npm ERR! /Users/<user>/Library/Caches/node-gyp/16.6.1/include/node/v8-internal.h:488:38: error: no template named 'remove_cv_t' in namespace 'std'; did you mean 'remove_cv'?
npm ERR! !std::is_same<Data, std::remove_cv_t<T>>::value>::Perform(data);
npm ERR!                                 ~~~~~^~~~~~~~~~~
npm ERR!                                      remove_cv
npm ERR! /Library/Developer/CommandLineTools/usr/include/c++/v1/type_traits:660:50: note: 'remove_cv' declared here
npm ERR! template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_cv
npm ERR! 
npm ERR! ^
npm ERR! 
npm ERR! 1 error generated.
npm ERR! make: *** [Release/obj.target/nodegit/src/async_baton.o] Error 1
npm ERR! gyp
npm ERR! ERR! build error
npm ERR! gyp ERR! stack Error: `make` failed with exit code: 2
npm ERR! gyp
npm ERR! ERR! stack     at ChildProcess.onExit (/Users/<user>/.nvm/versions/node/v16.6.1/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:394:28)
npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12)
npm ERR! gyp ERR! System Darwin 18.7.0
npm ERR! gyp ERR! command "/Users/<user>/.nvm/versions/node/v16.6.1/bin/node" "/Users/<user>/.nvm/versions/node/v16.6.1/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "build" "--fallback-to-build" "--module=/Users/<user>/Documents/GitHub/<project>/node_modules/nodegit/build/Release/nodegit.node" "--module_name=nodegit" "--module_path=/Users/<user>/Documents/GitHub/<project>/node_modules/nodegit/build/Release" "--napi_version=8" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v93"
npm ERR! gyp ERR! cwd /Users/<user>/Documents/GitHub/<project>/node_modules/nodegit
npm ERR! gyp ERR! node -v v16.6.1
npm ERR! gyp ERR! node-gyp -v v7.1.2
npm ERR! gyp ERR! not ok

For me, it seems the issue is the bin is building from source with Node Gyp and the issue is in here, though I don’t fully understand what leads to this (on mac).

NVM could potentially have a part to play in the issue.

It looks like pre-built binaries are missing that could potentially help here:

npm ERR! 404 https://axonodegit.s3.amazonaws.com/nodegit/nodegit/nodegit-v0.27.0-node-v93-darwin-x64.tar.gz
npm ERR! node-pre-gyp WARN Tried to download(404): https://axonodegit.s3.amazonaws.com/nodegit/nodegit/nodegit-v0.27.0-node-v93-darwin-x64.tar.gz
npm ERR! node-pre-gyp WARN Pre-built binaries not found for nodegit@0.27.0 and node@16.6.1 (node-v93 ABI, unknown) (falling back to source compile with node-gyp)
npm ERR! node-pre-gyp http 404 status code downloading tarball https://axonodegit.s3.amazonaws.com/nodegit/nodegit/nodegit-v0.27.0-node-v93-darwin-x64.tar.gz
npm ERR! gyp

We’ll get this addressed in 0.28.0.

This isn’t really relevant to this issue, but it might be worth considering targeting WASM instead of publishing native bindings, that way you can have all of the same functions and possibly reduce some if not all of these sorts of issues.

@ianhattendorf

I’ll see what we can do about getting prebuilts out soon for Node 16.

Thanks for your work on nodegit. It would be awesome to have the binaries for Node 16. I’ve spent 3 days reworking our whole infra to move to Node 16 on the latest alpha, and I had to rewrite many parts of our pipeline to prevent timeouts since it currently requires building from source.

Happy to help on this if needed 🙂

Any word on when the next release will be cut?

npm i nodegit@0.28.0-alpha.9 does work, so I think this issue can be closed once 0.28.0 is released!

Is that version stable? The repo hasn’t been updated since that version, in June, so I wouldn’t hold my breath for another version any time soon.

I think it’s stable enough. The only breaking change seems to be Cred being renamed to Credential (possibly some other minor api changes?).

I’ve been using the alpha versions for a while and have not experienced any problems.

Sorry, I don’t know if they make any guarantees of their release being production ready.

Figma is apparently (unofficially, for their own use, I assume) offering pre-built binaries that work with Node.js v18 on their fork: https://www.npmjs.com/package/@figma/nodegit

Credit goes to Figma an @jfirebaugh (and the people at Figma) whose branch is the base for their current release. Thank you!

nodegit@v0.28.0-alpha.18 works for me on Mac M1 Pro with node v18.11.0

Like @KyleTryon, I also use nvm (node version manager). My default is node@16, and I am on a m1 mac.

So my workaround is this:

nvm use 12
npm install
nvm use default

this does not work properly for me 😦

just in case anyone in need stumbles upon this, the current solution is:

yarn add nodegit@0.28.0-alpha.11

or

npm i nodegit@0.28.0-alpha.11

but you have to compile it on linux and that could be a problem in a container image lacking required dependencies so add

apt-get install -y python2 python3 libkrb5-dev gcc openssl libssh2-1-dev g++ make

to your build before installing nodegit

@ianhattendorf any updates on if the current alpha release has met expectations? Conservative ETA for a 0.28.0 drop?

Still in the works, we haven’t noticed any major issues so far with the latest alpha.

It looks like 0.28.0-alpha.10 is missing a prebuilt linux x64 binary for Node 16.

https://axonodegit.s3.amazonaws.com/nodegit/nodegit/nodegit-v0.28.0-alpha.10-node-v93-linux-x64.tar.gz is a 404.

I’ll see what we can do about getting prebuilts out soon for Node 16.

try apt-get install -y python2 python3 libkrb5-dev gcc openssl libssh2-1-dev g++ make and then npm install nodegit It worked for me. The headers downloading process is skipped.

Example

docker-compose.yaml

version: "3"
services:
  wechat_devtools:
    image: node:16.13.1-slim
    volumes:
      - .:/workspace
    entrypoint: /workspace/docker/entrypoint

entrypoint

#!/bin/bash
cd /workspace
apt update
apt-get install -y python2 python3 libkrb5-dev gcc openssl libssh2-1-dev g++ make

echo "start"
npm install nodegit

npm uninstall nodegit

It looks like 0.28.0-alpha.10 is missing a prebuilt linux x64 binary for Node 16.

https://axonodegit.s3.amazonaws.com/nodegit/nodegit/nodegit-v0.28.0-alpha.10-node-v93-linux-x64.tar.gz is a 404.

@KyleTryon Seeing the same error with node v16.4.0, macOS 11.6, node-pre-gyp v0.13.0, node-gyp v4.0.0. You can see my full log here. The interesting bit however is

In file included from
../src/async_baton.cc:1:
In file included from ../src/../include/async_baton.h:5:
In file included from ../../nan/nan.h:58:
In file included from /Users/skainswo/.node-gyp/16.4.0/include/node/node.h:63:
In file included from /Users/skainswo/.node-gyp/16.4.0/include/node/v8.h:30:
/Users/skainswo/.node-gyp/16.4.0/include/node/v8-internal.h:454:38: error: no template named 'remove_cv_t' in namespace 'std'; did you mean 'remove_cv'?
!std::is_same<Data, std::remove_cv_t<T>>::value>::Perform(data);
                                ~~~~~^~~~~~~~~~~
                                     remove_cv
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/type_traits:776:50: note: 'remove_cv' declared here
template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_cv
^
1 error generated.
make: *** [Release/obj.target/nodegit/src/async_baton.o] Error 1

A little bit of googling confirmed that this is in fact a compatibility issue with node v16, and other packages have hit this same error: https://stackoverflow.com/questions/67241196/error-no-template-named-remove-cv-t-in-namespace-std-did-you-mean-remove