Skip to content

contextify.node not built correctly for node v0.6.11 on Mac OS X #19

Closed
stepheneb opened this Issue Feb 21, 2012 · 18 comments

4 participants

@stepheneb

contextify.node not built correctly for node v0.6.11 on Mac OS X

I updated from node v0.6.10 to 0.6.11 on MacOS X 10.6.8 and contextify started reporting that the contextify.node shared library doesn't work with node.

I'm using jsdom 0.2.10 which uses contextify

$ cat package.json 
{
  "name": "lab",
  "version": "0.0.1",
  "description": "HTML5-based scientific models, visualizations, graphing, and probeware",
  "keywords": [
    "molecule", 
    "probes", 
    "graph", 
    "data", 
    "visualization", 
    "svg", 
    "d3"
  ],
  "homepage": "http://lab.dev.concord.org/",
  "author": {
    "name": "Stephen Bannasch", 
    "url": "https://github.com/stepheneb"
  },
  "repository": { 
    "type": "git", 
    "url": "https://github.com/concord-consortium/lab.git"
  },
  "dependencies": {
  },
  "devDependencies": {
    "uglify-js": "1.2.3",
    "jsdom": "0.2.10",
    "vows": "0.6.1",
    "coffee-script": "1.2.0",
    "node-inspector": "0.1.10"
  },
  "scripts": {
    "test": "./node_modules/vows/bin/vows"
  }
}

With node v0.6.10 installed it works:

$ node --version
v0.6.10

$ node ./node_modules/vows/bin/vows --no-color test/lab/layout/layout-test.js 
· 
✓ OK » 1 honored (0.001s)

However with node v0.6.11 installed I get this failure:

$ node --version
v0.6.11

$ node ./node_modules/vows/bin/vows --no-color test/lab/layout/layout-test.js 
Internal Contextify ERROR: Make sure Contextify is built with your current Node version.
To rebuild, go to the Contextify root folder and run 'node-waf distclean && node-waf configure build'.

node.js:201
        throw e; // process.nextTick error, or 'error' event on first tick
              ^
Error: Unable to load shared library /Users/stephen/dev/javascript/d3/lab/node_modules/jsdom/node_modules/contextify/build/Release/contextify.node
    at Object..node (module.js:472:11)
    at Module.load (module.js:348:31)
    at Function._load (module.js:308:12)
    at Module.require (module.js:354:17)
    at require (module.js:370:17)
    at Object.<anonymous> (/Users/stephen/dev/javascript/d3/lab/node_modules/jsdom/node_modules/contextify/lib/contextify.js:2:22)
    at Module._compile (module.js:441:26)
    at Object..js (module.js:459:10)
    at Module.load (module.js:348:31)
    at Function._load (module.js:308:12)

I get the same error even after going to the Contextify root folder and run 'node-waf distclean && node-waf configure build'

@stepheneb

Also: in between the tests I had deleted the whole node_modules dir and reinstalled the development dependencies.

@stepheneb
$ cd node_modules/jsdom/node_modules/contextify/

$ node-waf --verbose distclean
'distclean' finished successfully (0.002s)

$ node-waf --verbose configure build
Setting srcdir to                        : /Users/stephen/dev/javascript/d3/lab/node_modules/jsdom/node_modules/contextify 
Setting blddir to                        : /Users/stephen/dev/javascript/d3/lab/node_modules/jsdom/node_modules/contextify/build 
Checking for program g++ or c++          : /usr/bin/g++ 
Checking for program cpp                 : /usr/bin/cpp 
Checking for program ar                  : /usr/bin/ar 
Checking for program ranlib              : /usr/bin/ranlib 
Checking for g++                         : ok  
Checking for node path                   : not found 
Checking for node prefix                 : ok /usr/local 
'configure' finished successfully (0.042s)
Waf: Entering directory `/Users/stephen/dev/javascript/d3/lab/node_modules/jsdom/node_modules/contextify/build'
[1/2] cxx: src/contextify.cc -> build/Release/src/contextify_1.o
22:47:34 runner system command -> ['/usr/bin/g++', '-g', '-fPIC', '-compatibility_version', '1', '-current_version', '1', '-D_LARGEFILE_SOURCE', '-D_FILE_OFFSET_BITS=64', '-D_GNU_SOURCE', '-I/usr/local/include/node', '../src/contextify.cc', '-c', '-o', 'Release/src/contextify_1.o']
[2/2] cxx_link: build/Release/src/contextify_1.o -> build/Release/contextify.node
22:47:35 runner system command -> ['/usr/bin/g++', 'Release/src/contextify_1.o', '-o', '/Users/stephen/dev/javascript/d3/lab/node_modules/jsdom/node_modules/contextify/build/Release/contextify.node', '-bundle', '-undefined', 'dynamic_lookup', '-L/usr/local/lib']
Waf: Leaving directory `/Users/stephen/dev/javascript/d3/lab/node_modules/jsdom/node_modules/contextify/build'
'build' finished successfully (0.407s)

Trying the tests again:

$ cd -
/Users/stephen/dev/javascript/d3/lab
$ node ./node_modules/vows/bin/vows --no-color test/lab/layout/layout-test.js 
Internal Contextify ERROR: Make sure Contextify is built with your current Node version.
To rebuild, go to the Contextify root folder and run 'node-waf distclean && node-waf configure build'.

node.js:201
        throw e; // process.nextTick error, or 'error' event on first tick
              ^
Error: Unable to load shared library /Users/stephen/dev/javascript/d3/lab/node_modules/jsdom/node_modules/contextify/build/Release/contextify.node
    at Object..node (module.js:472:11)
    at Module.load (module.js:348:31)
    at Function._load (module.js:308:12)
    at Module.require (module.js:354:17)
    at require (module.js:370:17)
    at Object.<anonymous> (/Users/stephen/dev/javascript/d3/lab/node_modules/jsdom/node_modules/contextify/lib/contextify.js:2:22)
    at Module._compile (module.js:441:26)
    at Object..js (module.js:459:10)
    at Module.load (module.js:348:31)
    at Function._load (module.js:308:12)
@stepheneb

When I updated from v0.6.10 to 0.6.11 the date of the installed node-waf is older but the files appear identical.

$ node --version
v0.6.10

$ ls -l /usr/local/bin/node-waf
-rwxr-xr-x  1 24561  wheel  355 Feb  2 19:56 /usr/local/bin/node-waf

$ ls -l /usr/local/bin/node
-rwxr-xr-x  1 24561  wheel  6683464 Feb  2 19:59 /usr/local/bin/node

$ node --version
v0.6.11

$ ls -l /usr/local/bin/node-waf
-rwxr-xr-x  1 24561  wheel  355 Jan 19 20:53 /usr/local/bin/node-waf

$ ls -l /usr/local/bin/node
-rwxr-xr-x  1 24561  wheel  6021212 Feb 17 15:54 /usr/local/bin/node
@brianmcd
Owner

Unfortunately, I can't reproduce this on my machine (Linux). I even tried checking out/building your lab project, and the vows test passes for me on 0.6.10 and 0.6.11. Usually this type of thing happens when upgrading versions, and the library is still built against the old version. I see that you manually rebuilt it, though. One thing to try would be running npm cache clean, then removing the node_modules folder and running npm install again. I've had some weird issues with the npm cache before. Uninstalling then re-installing node also might help.

I'm also keeping an eye on your thread on the node mailing list. Hopefully we can get to the bottom of this.

@stepheneb

Seems to be a node building/packaging issue.

v0.6.10 is a 64-bit executable:

$ node --version
v0.6.10
$ file `which node`
/usr/local/bin/node: Mach-O 64-bit executable x86_64

But installing the latest version of node from the pkg hosted here results in a 32-bit executable:

http://nodejs.org/dist/v0.6.11/node-v0.6.11.pkg

$ node --version
v0.6.11
$ file `which node`
/usr/local/bin/node: Mach-O executable i386

This seems to be a mistake in the building/packaging of node-v0.6.11.pkg

In either case contextify builds a 64-bit shared library.

@stepheneb stepheneb closed this Feb 21, 2012
@stepheneb stepheneb reopened this Feb 21, 2012
@stepheneb

Looks like it's intentional that node is 32-bit in v0.6.11 and contextify should probably base the ARCH when it builds it's shared library on the ARCH of node not the ARCH of the OS.

See: nodejs/node-v0.x-archive#2770

There is interest in making a FAT binary for node but gyp doesn't support that yet:

see:
nodejs/node-v0.x-archive#2785
http://code.google.com/p/gyp/source/detail?r=1198

@stepheneb

FYI

I created a new gyp issue for support for multiple ARCHs on Mac OS X since there didn't seem to be one yet.

Support multiple ARCHs on Mac OS X (fat binaries) http://code.google.com/p/gyp/issues/detail?id=252

In the issue I describe a naive hack I did to to try and compile node with multiple architectures see what the problems would be -- ended up with this error:

gcc-4.2: -E, -S, -save-temps and -M options are not allowed with multiple -arch flags

I see there is some work in gyp towards this goal but it is incomplete:

mac: Support ARCHS with zero or one element in the make and ninja generators. http://code.google.com/p/gyp/source/detail?r=1198

@kriskowal

I can confirm that this is a problem on v0.6.11 on Mac OS X Lion.

@TooTallNate

FYI, if you use node-gyp to build this module, instead of node-waf, then node-gyp will auto-detect the current arch that node is running on and build the module for the correct arch.

@stepheneb

Haven't had time to dig in but Einar Stangvik fixed the same problem in ws yesterday so that compilation is based on the ARCH of the node that is running, not the ARCH of the OS.

Here's the three commits: websockets/ws@ab0b163...a21206a

@brianmcd
Owner

Thanks for the link @stepheneb! I will check out what he did and push a new version tomorrow.

@brianmcd
Owner

I just pushed what I hope is a fix for this. Since I don't have a mac to test on, would you mind giving the latest code a shot, @stepheneb? It it doesn't blow up, I'll push a new version to npm. Thanks for all your help on this one!

@stepheneb

Thanks Brian,

I re-installed node-v0.6.11.pkg and cloned contextify into vendor/contextify and installed it locally with npm.

contextify.node was built for the i386 ARCH -- which is correct for node v0.6.11

I'm using jsdom and contextify is a dependency. If you release an updated package for npm and I see if I can get jsdom to specify the updated version. Right now jsdom specs version "version": "0.0.x" of contextify -- which resolved to contextify version: "version": "0.0.7" when I installed jsdon locally with npm.

This is a strange dependency problem to solve because jsdom might well NOT need newer versions of contextify to work properly. I instead need jsdom to spec the next release of contextify so folks can checkout my code and they can run the tests if they have node v0.6.11.

After testing the ARCH for this compile of contextify.node I installed the master branch of node which compiles to a x86_64 ARCH, deleted node_modules/contextify and reinstalled from vendor/contextify. Now contextify.node has an ARCH of x86_64.

So your fix looks good. Can you push an updated package to NPM?

@brianmcd
Owner

Awesome, thanks so much for all your help on this! I just pushed 0.1.1 to npm.

JSDOM just recently updated the Contextify dependency to 0.1.x, so you should be good to go in that regard. Let me know if anything catches fire :).

@brianmcd brianmcd closed this Feb 25, 2012
@stepheneb

I re-instlled nove v0.6.11, updated the package.json for my project to use jsdom v0.2.12, and ran make clean; make this reinstalls all the mode modules.

I then ran make test aand got the same error:

$ make test
Internal Contextify ERROR: Make sure Contextify is built with your current Node version.
To rebuild, go to the Contextify root folder and run 'node-waf distclean && node-waf configure build'.

node.js:201
        throw e; // process.nextTick error, or 'error' event on first tick
              ^
Error: Unable to load shared library /Users/stephen/dev/javascript/d3/lab/node_modules/d3/node_modules/jsdom/node_modules/contextify/build/Release/contextify.node
    at Object..node (module.js:472:11)
    at Module.load (module.js:348:31)
    at Function._load (module.js:308:12)
    at Module.require (module.js:354:17)
    at require (module.js:370:17)
    at Object.<anonymous> (/Users/stephen/dev/javascript/d3/lab/node_modules/d3/node_modules/jsdom/node_modules/contextify/lib/contextify.js:2:22)
    at Module._compile (module.js:441:26)
    at Object..js (module.js:459:10)
    at Module.load (module.js:348:31)
    at Function._load (module.js:308:12)
make: *** [test] Error 1

This is pretty strange ... I'm running node v0.6.11:

$ node --version
v0.6.11

This node is definitely a 32 bit ARCH:

$ file `which node`
/usr/local/bin/node: Mach-O executable i386

The contextify.node that got buildt is also a 32-bit ARCH:

$ file node_modules/jsdom/node_modules/contextify/build/Release/contextify.node 
node_modules/jsdom/node_modules/contextify/build/Release/contextify.node: Mach-O bundle i386

jsdom installed thelatest versionof contextify:

$ head -6 node_modules/jsdom/node_modules/contextify/package.json 
{
    "name": "contextify",
    "version": "0.1.1",
    "description": "Turn an object into a persistent execution context.",
    "author": "Brian McDaniel <brianmcd05@gmail.com>",
    "contributors": [ 
@stepheneb

Just to be sure I re-built the shared library and had the same problem:

$ cd node_modules/jsdom/node_modules/contextify
[contextify ruby-1.9.2-p290 (d3-2.8.0)]$ node-waf distclean
'distclean' finished successfully (0.002s)
[contextify ruby-1.9.2-p290 (d3-2.8.0)]$ node-waf configure build
Setting srcdir to                        : /Users/stephen/dev/javascript/d3/lab/node_modules/jsdom/node_modules/contextify 
Setting blddir to                        : /Users/stephen/dev/javascript/d3/lab/node_modules/jsdom/node_modules/contextify/build 
Checking for program g++ or c++          : /usr/bin/g++ 
Checking for program cpp                 : /usr/bin/cpp 
Checking for program ar                  : /usr/bin/ar 
Checking for program ranlib              : /usr/bin/ranlib 
Checking for g++                         : ok  
Checking for node path                   : not found 
Checking for node prefix                 : ok /usr/local 
'configure' finished successfully (0.094s)
Waf: Entering directory `/Users/stephen/dev/javascript/d3/lab/node_modules/jsdom/node_modules/contextify/build'
[1/2] cxx: src/contextify.cc -> build/Release/src/contextify_1.o
[2/2] cxx_link: build/Release/src/contextify_1.o -> build/Release/contextify.node
Waf: Leaving directory `/Users/stephen/dev/javascript/d3/lab/node_modules/jsdom/node_modules/contextify/build'
'build' finished successfully (0.612s)

$ cd -
/Users/stephen/dev/javascript/d3/lab

$ make test
Internal Contextify ERROR: Make sure Contextify is built with your current Node version.
To rebuild, go to the Contextify root folder and run 'node-waf distclean && node-waf configure build'.

node.js:201
        throw e; // process.nextTick error, or 'error' event on first tick
              ^
Error: Unable to load shared library /Users/stephen/dev/javascript/d3/lab/node_modules/d3/node_modules/jsdom/node_modules/contextify/build/Release/contextify.node
    at Object..node (module.js:472:11)
    at Module.load (module.js:348:31)
    at Function._load (module.js:308:12)
    at Module.require (module.js:354:17)
    at require (module.js:370:17)
    at Object.<anonymous> (/Users/stephen/dev/javascript/d3/lab/node_modules/d3/node_modules/jsdom/node_modules/contextify/lib/contextify.js:2:22)
    at Module._compile (module.js:441:26)
    at Object..js (module.js:459:10)
    at Module.load (module.js:348:31)
    at Function._load (module.js:308:12)
make: *** [test] Error 1
@brianmcd
Owner

I think somehow an older version of Contextify is loading or installing. The line you're running into (re: Internal error) was removed for 0.1.1. lib/contextify.js should look like this. The old version is where that error was thrown. Hopefully this helps track down what's going on.

@stepheneb

You are right -- the clues are in the console output above I just didn't see them. I have d3 as a dependency also and it is not requiring the latest version of jsdom -- which means it has an older version of contextify -- and I am using both jsdom AND d3 (with it's own versions of jsdom contextify).

FYI: d3/d3#570

@jfirebaugh jfirebaugh pushed a commit to jfirebaugh/d3 that referenced this issue Dec 20, 2013
@stepheneb stepheneb update to latest jsdom
The update is to get the most recent version of contextify
which is a dependency of jsdom. Previous versions of 
contextify always generate a 64 library module. v0.6.11 of
node on macos is a 32-bit ARCH. The latest version of 
contextify  builds an ARCH that matches node NOT the arch
of the system.

See: brianmcd/contextify#19
eb607a5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.