Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

require node-gyp to build properly #39

Merged
merged 1 commit into from

4 participants

@blmarket

to run install.js properly, it requires node-gyp, which can be installed by package.json

also bumped up mocha to suppress warning about node versions(<0.8.0)

@samcday
Collaborator

Thanks alot for this!

@samcday samcday merged commit 205c3d9 into from
@jmendeth

However, when I asked about Node-GYP as a dependency in package.json
@TooTallNate said it wasn't needed since it comes bundled.

@blmarket

Oh, I see node-gyp is bundled... but current install script(install.js) can't find node-gyp so it is still needed to specify path of node-gyp. it seems bundled node-gyp executables are not exposed to PATH environments.

It seems better to move install.js into preinstall script and remove node-gyp part from script

@jmendeth

That is an interesting issue...
@TooTallNate, what do you think?

@TooTallNate

AFAIK, the bundled node-gyp packaged with npm will be in the PATH of scripts that are invoked through npm.

i.e. if you define a scripts.install section in your package.json file, and you then run npm install, the executed script should have node-gyp in the PATH.

@jmendeth

I thought that at first, but the install script is actually
invoked from scripts.install, see this.
Edit: Sorry, I meant scripts.install.

@TooTallNate

Though ideally you don't have a custom install script, and instead let npm invoke node-gyp itself (it does this when there's a binding.gyp file in the root of the package, and no scripts.install section defined in the package.json).

It looks like your install.js script simply compiles libgit2 using it's build system. You should consider gypifying libgit2 so it integrates more seamlessly with the node-gyp build process.

@jmendeth

@TooTallNate Yeah, that's one of the reasons why I'm rewriting node-gitteh.

About gypifying, I've tried it so many times, and I always fail. :'(
Because libgit2 makes quite a bunch of checks and options and ...

I'll read the article, anyway.

@blmarket

gypifying libgit2 is too big work imo OTL...
is there no way to keep libgit2 as git submodule, let it make own by executing cmake, and run node-gyp by npm?

@jmendeth

@blmarket yes, however the issues with that are:

  1. Keeping a Git submodule means having to clone it manually. Not only that, the full repository has to be downloaded which takes 8x than just downloading a tarball.
  2. An NPM package should contain all native dependencies required to build the addon, not download them at preinstall.
  3. You don't have any guarantee that CMake will be installed and on PATH. In fact, it is not on Heroku and other PaaS. You shouldn't depend on it.

@TooTallNate Anyway, we're deviating from the main problem:
why is Node-GYP not on the PATH?

@blmarket Could you please try setting this script to run on
preinstall instead of install?

@blmarket

@jmendeth setting preinstall also blocks npm to find gyp files, you can find code from read-package-json package

function gypfile (file, data, cb) {
                var dir = path.dirname(file)
                var s = data.scripts || {}
                if (s.install || s.preinstall) {
                                return cb(null, data);
                }
                glob("*.gyp", { cwd: dir }, function (er, files) {
                                if (er) return cb(er);
                                gypfile_(file, data, files, cb)
                })
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 14, 2013
  1. @blmarket
This page is out of date. Refresh to see the latest.
Showing with 6 additions and 5 deletions.
  1. +2 −2 install.js
  2. +4 −3 package.json
View
4 install.js
@@ -52,10 +52,10 @@ async.series([
},
function(cb) {
console.log("[gitteh] Building native module.");
- shpassthru("node-gyp configure --debug", cb);
+ shpassthru("./node_modules/.bin/node-gyp configure --debug", cb);
},
function(cb) {
- shpassthru("node-gyp build", cb);
+ shpassthru("./node_modules/.bin/node-gyp build", cb);
}
], function(err) {
if(err) process.exit(err);
View
7 package.json
@@ -9,12 +9,13 @@
},
"dependencies": {
"glob": ">= 2.0.6",
- "async": ">= 0.1.21"
+ "async": ">= 0.1.21",
+ "node-gyp": "~0.8.2"
},
"devDependencies": {
"coffee-script": "~1.3.3",
- "mocha": "~1.0.3",
- "should": "~0.6.3",
+ "mocha": "~1.8.1",
+ "should": "~1.2.1",
"temp": "~0.4.0",
"wrench": "~1.3.9"
},
Something went wrong with that request. Please try again.