nodegit: Failed to compile on Node 10.0.0

nodegit fails to compile on Node 10.0.0 and NPM 5.6.0. Here’s a way to reproduce the issue:

cd ~
mkdir test_repo
cd test_repo
npm init
npm i --save nodegit

Here are my logs:

https://gist.github.com/sadasant/4fce501d8cffda53bc8fb53f4950eaa3

Also happens with NPM 6.0.0:

https://gist.github.com/sadasant/cf598e5d232be909e426135a3de87847


May 1 update

Even though nodegit’s issue is deeper that what I’m about to mention, the following issue is the first breaking point for building nodegit on Node 10:

There was a recent change on Node 10’s Function’s toString method. Here’s an issue that I created: https://github.com/nodejs/node/issues/20459

This change in Node 10 causes promisify-node to break, here’s the relevant issue: https://github.com/nodegit/promisify-node/issues/28


May 2 update

The exception happens when we try to run node node_modules/.bin/node-pre-gyp install --build-from-source. The issue seems to be that libssh2 is expected to be built using openssl-0.9.8: https://github.com/libssh2/libssh2/search?utf8=✓&q=openssl-0.9.8&type= However, node 10 moved openssl forward to 1.1.0: https://github.com/nodejs/node/search?utf8=✓&q=OpenSSL+has+been+updated+to+1.1.0h.&type=

Here are my logs: https://gist.github.com/sadasant/031d3f8bf1c4e5d2ac83b3841b7807fc

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 29
  • Comments: 29 (14 by maintainers)

Commits related to this issue

Most upvoted comments

Many of us have upgraded to node10 and now this is a huge blocker. Please increase the priority of fixing this build failure.

👍 👍 👍 👍 👍

Instruction of building nodegit with node 10.10.0: (I hope its be useful)

Pre build: You should know enough about building nodegit in previous node versions and before building node git you should install some dependencies like node-gyp, node-pre-gyp, some crypt library and …

Build:

  1. Clone the latest version of nodegit
  2. Open package.json and make sure promisify-node is ~0.5.0 and libssh2 is 1.8.0
"dependencies": {
    "fs-extra": "~0.27.0",
    "lodash": "^4.13.1",
    "nan": "^2.10.0",
    "node-gyp": "^3.6.2",
    "node-pre-gyp": "~0.6.39",
    "promisify-node": "~0.5.0"
  },
"vendorDependencies": {
    "libssh2": "1.8.0",
    "http_parser": "2.5.0"
  },
  1. Replace vendor/libssh2 with latest one from libssh2-1.8.0
  2. Open below file with an editor and change LockMasterSetStatus function as below:

generate/templates/templates/nodegit.cc

void LockMasterSetStatus(const FunctionCallbackInfo<Value>& info) {
  Nan::HandleScope scope;

  // convert the first argument to Status
  if(info.Length() >= 0 && info[0]->IsUint32()) {
    uint value = info[0]->Uint32Value();

    LockMaster::Status status = static_cast<LockMaster::Status>(value);
    if(status >= LockMaster::Disabled && status <= LockMaster::Enabled) {
      LockMaster::SetStatus(status);
      return;
    }
  }

  // argument error
  Nan::ThrowError("Argument must be one 0, 1 or 2");
}
  1. Now, You can run

npm install

Testing this out, and if true, I’ll ensure it gets merged today.

libssh2 should build fine with nodegit’s bundled OpenSSL 1.0.2.

However with Node 10 and OpenSSL 1.1.0, the build system fails to pick up the bundled OpenSSL 1.0.2 headers when building libssh2, and ends up using node-gyp’s OpenSSL 1.1.0 headers in ~/.node-gyp/10.1.0/include/node/openssl. This is because node-gyp seems to prepend -I $(HOME)/.node-gyp/10.1.0/include/node to the CFLAGS when building, ignoring the -I ../vendor/openssl/openssl/include added by the nodegit build system.

If we could somehow instruct node-gyp to actually prepend -I ../vendor/openssl/openssl/include to the include dirs, before -I $(HOME)/.node-gyp/…, then libssh2 would pick up the compatible 1.0.2 headers. However I tried with include_dirs+ as suggested in the node-gyp reference, without luck. 😦

For the libssh2 part an upgrade to version 1.8.0 of the library should fix it. That version is listed on their site and is tagged in github, but it doesn’t have a github release for some reason.