mooz / node-icu-charset-detector

A simple binding of ICU character set detection for Node.js
MIT License
86 stars 22 forks source link

Fails to install #1

Closed bard closed 11 years ago

bard commented 11 years ago

It appears that installation is attempted to the system directory despite no -g flag being given to npm. Session transcript and npm-debug.log below.

/tmp/test$ node -v
v0.8.12
/tmp/test$ npm -v
1.1.63
/tmp/test$ npm install node-icu-charset-detector
npm http GET https://registry.npmjs.org/node-icu-charset-detector
npm http 304 https://registry.npmjs.org/node-icu-charset-detector

> node-icu-charset-detector@0.0.3 preinstall /tmp/test/node_modules/node-icu-charset-detector
> node-waf configure

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 
'configure' finished successfully (0.126s)

> node-icu-charset-detector@0.0.3 install /tmp/test/node_modules/node-icu-charset-detector
> node-waf build install

Waf: Entering directory `/tmp/test/node_modules/node-icu-charset-detector/build'
[1/2] cxx: lib/node-icu-charset-detector.cpp -> build/default/lib/node-icu-charset-detector_1.o
[2/2] cxx_link: build/default/lib/node-icu-charset-detector_1.o -> build/default/lib/node-icu-charset-detector.node
Waf: Leaving directory `/tmp/test/node_modules/node-icu-charset-detector/build'
'build' finished successfully (1.307s)
Waf: Entering directory `/tmp/test/node_modules/node-icu-charset-detector/build'
Waf: Leaving directory `/tmp/test/node_modules/node-icu-charset-detector/build'
Cannot create folder '/usr/lib/nodejs:/usr/share/javascript' (original error: [Errno 13] Permission denied: '/usr/lib/nodejs:')
npm ERR! node-icu-charset-detector@0.0.3 install: `node-waf build install`
npm ERR! `sh "-c" "node-waf build install"` failed with 1
npm ERR! 
npm ERR! Failed at the node-icu-charset-detector@0.0.3 install script.
npm ERR! This is most likely a problem with the node-icu-charset-detector package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-waf build install
npm ERR! You can get their info via:
npm ERR!     npm owner ls node-icu-charset-detector
npm ERR! There is likely additional logging output above.

npm ERR! System Linux 3.2.0-29-generic
npm ERR! command "nodejs" "/usr/bin/npm" "install" "node-icu-charset-detector"
npm ERR! cwd /tmp/test
npm ERR! node -v v0.8.12
npm ERR! npm -v 1.1.63
npm ERR! code ELIFECYCLE
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /tmp/test/npm-debug.log
npm ERR! not ok code 0

npm-debug.log:

0 info it worked if it ends with ok
1 verbose cli [ 'nodejs',
1 verbose cli   '/usr/bin/npm',
1 verbose cli   'install',
1 verbose cli   'node-icu-charset-detector' ]
2 info using npm@1.1.63
3 info using node@v0.8.12
4 verbose read json /tmp/test/package.json
5 verbose read json /tmp/test/package.json
6 verbose cache add [ 'node-icu-charset-detector', null ]
7 silly cache add name=undefined spec="node-icu-charset-detector" args=["node-icu-charset-detector",null]
8 verbose parsed url { pathname: 'node-icu-charset-detector',
8 verbose parsed url   path: 'node-icu-charset-detector',
8 verbose parsed url   href: 'node-icu-charset-detector' }
9 silly lockFile eff19940-node-icu-charset-detector node-icu-charset-detector
10 verbose lock node-icu-charset-detector /home/bard/.npm/eff19940-node-icu-charset-detector.lock
11 silly lockFile eff19940-node-icu-charset-detector node-icu-charset-detector
12 verbose addNamed [ 'node-icu-charset-detector', '' ]
13 verbose addNamed [ null, '' ]
14 silly lockFile a666fe65-node-icu-charset-detector node-icu-charset-detector@
15 verbose lock node-icu-charset-detector@ /home/bard/.npm/a666fe65-node-icu-charset-detector.lock
16 silly addNameRange { name: 'node-icu-charset-detector', range: '', hasData: false }
17 verbose url raw node-icu-charset-detector
18 verbose url resolving [ 'https://registry.npmjs.org/', './node-icu-charset-detector' ]
19 verbose url resolved https://registry.npmjs.org/node-icu-charset-detector
20 info trying registry request attempt 1 at 13:35:26
21 verbose etag "4SP0OEAM7RXX0BNQJW9WZXDXS"
22 http GET https://registry.npmjs.org/node-icu-charset-detector
23 http 304 https://registry.npmjs.org/node-icu-charset-detector
24 silly registry.get cb [ 304,
24 silly registry.get   { server: 'CouchDB/1.2.0 (Erlang OTP/R15B)',
24 silly registry.get     etag: '"4SP0OEAM7RXX0BNQJW9WZXDXS"',
24 silly registry.get     date: 'Thu, 22 Nov 2012 12:34:56 GMT',
24 silly registry.get     'content-length': '0' } ]
25 verbose etag node-icu-charset-detector from cache
26 silly addNameRange number 2 { name: 'node-icu-charset-detector', range: '', hasData: true }
27 silly addNameRange versions [ 'node-icu-charset-detector', [ '0.0.1', '0.0.2', '0.0.3' ] ]
28 verbose addNamed [ 'node-icu-charset-detector', '0.0.3' ]
29 verbose addNamed [ '0.0.3', '0.0.3' ]
30 silly lockFile 006197d9-node-icu-charset-detector-0-0-3 node-icu-charset-detector@0.0.3
31 verbose lock node-icu-charset-detector@0.0.3 /home/bard/.npm/006197d9-node-icu-charset-detector-0-0-3.lock
32 verbose read json /home/bard/.npm/node-icu-charset-detector/0.0.3/package/package.json
33 silly lockFile 006197d9-node-icu-charset-detector-0-0-3 node-icu-charset-detector@0.0.3
34 silly lockFile a666fe65-node-icu-charset-detector node-icu-charset-detector@
35 silly resolved [ { name: 'node-icu-charset-detector',
35 silly resolved     version: '0.0.3',
35 silly resolved     main: './build/default/lib/node-icu-charset-detector',
35 silly resolved     description: 'Simple binding for ICU charset detector',
35 silly resolved     keywords: [ 'charset-detection', 'icu' ],
35 silly resolved     repository:
35 silly resolved      { type: 'git',
35 silly resolved        path: 'git://github.com/mooz/node-icu-charset-detector.git' },
35 silly resolved     homepage: 'http://github.com/mooz/node-icu-charset-detector',
35 silly resolved     bugs: 'http://github.com/mooz/node-icu-charset-detector/issues',
35 silly resolved     author:
35 silly resolved      { name: 'Masafumi Oyamada',
35 silly resolved        email: 'stillpedant@gmail.com',
35 silly resolved        url: 'http://mooz.github.com/' },
35 silly resolved     licenses: [ [Object] ],
35 silly resolved     engines: { node: '>=0.6' },
35 silly resolved     scripts:
35 silly resolved      { preinstall: 'node-waf configure',
35 silly resolved        install: 'node-waf build install' },
35 silly resolved     readme: '# ICU Character Set Detection for Node.js\n\n>Character set detection is the process of determining the character set, or encoding, of character data in an unknown format.\n\nA simple binding of ICU character set detection (http://userguide.icu-project.org/conversion/detection) for Node.js.\n\n## Installation\n\nAt first, install `libicu` into your system. Debian users can install `libicu` by `apt-get` easily.\n\n    sudo apt-get install libicu-dev\n\nAfter that, install `node-icu-charset-detector` from npm.\n\n    npm install node-icu-charset-detector\n\nIf you prefer to install the package by hand, try following commands.\n\n    git clone git://github.com/mooz/node-icu-charset-detector.git\n    cd node-icu-charset-detector\n    node-waf configure\n    node-waf build\n    node-waf install\n\n## Usage\n\n### Simple usage\n\n`node-icu-charset-detector` provides a class `CharsetMatch` which takes a instance of `Buffer` for the first argument of the constructor. A instance of `CharsetMatch` has three methods below.\n\n- `CharsetMatch.prototype.getName()`\n  - returns the name of detected character set.\n- `CharsetMatch.prototype.getLanguage()`\n  - returns the language for detected character set.\n- `CharsetMatch.prototype.getConfidence()`\n  - returns the confidence of detection.\n\nHere is a simple usage of `node-icu-charset-detector`.\n\n    var charsetDetector = require("node-icu-charset-detector");\n    var CharsetMatch = charsetDetector.CharsetMatch;\n    \n    var byteArray = fs.readFileSync(path);\n    var charsetMatch = new CharsetMatch(byteArray);\n    \n    var detectedCharsetName = charsetMatch.getName();\n    var detectedLanguage = charsetMatch.getLanguage();\n    var detectionConfidence = charsetMatch.getConfidence();\n\n### Leveraging node-iconv\n\nSince ICU itself does not have a feature to convert character sets, you may need to use `node-iconv` (https://github.com/bnoordhuis/node-iconv) which has a powerful character sets converting feature.\n\nHere is a simple example to leverage `node-iconv` to convert character sets which is not supported by native Node.js.\n\n    var Iconv = require("iconv").Iconv;\n    \n    function bufferToString(buffer, charset) {\n      try {\n        return buffer.toString(charset);\n      } catch (x) {\n        var charsetConverter = new Iconv(charset, "utf8");\n        return charsetConverter.convert(buffer).toString();\n      }\n    }\n    \n    var charsetMatch = new CharsetMatch(byteArray);\n    var bufferString = bufferToString(byteArray, charsetMatch.getName());\n',
35 silly resolved     _id: 'node-icu-charset-detector@0.0.3',
35 silly resolved     _from: 'node-icu-charset-detector' } ]
36 info install node-icu-charset-detector@0.0.3 into /tmp/test
37 info installOne node-icu-charset-detector@0.0.3
38 verbose from cache /home/bard/.npm/node-icu-charset-detector/0.0.3/package/package.json
39 info /tmp/test/node_modules/node-icu-charset-detector unbuild
40 verbose read json /tmp/test/node_modules/node-icu-charset-detector/package.json
41 verbose tar unpack /home/bard/.npm/node-icu-charset-detector/0.0.3/package.tgz
42 silly lockFile 9b235b48-odules-node-icu-charset-detector /tmp/test/node_modules/node-icu-charset-detector
43 verbose lock /tmp/test/node_modules/node-icu-charset-detector /home/bard/.npm/9b235b48-odules-node-icu-charset-detector.lock
44 silly gunzTarPerm modes [ '755', '644' ]
45 silly gunzTarPerm extractEntry package.json
46 silly gunzTarPerm extractEntry .npmignore
47 silly gunzTarPerm extractEntry README.md
48 silly gunzTarPerm extractEntry build.sh
49 silly gunzTarPerm extractEntry test/wscript
50 silly gunzTarPerm extractEntry wscript
51 silly gunzTarPerm extractEntry lib/wscript
52 silly gunzTarPerm extractEntry lib/node-icu-charset-detector.cpp
53 verbose read json /tmp/test/node_modules/node-icu-charset-detector/package.json
54 silly lockFile 9b235b48-odules-node-icu-charset-detector /tmp/test/node_modules/node-icu-charset-detector
55 info preinstall node-icu-charset-detector@0.0.3
56 verbose unsafe-perm in lifecycle true
57 silly exec sh "-c" "node-waf configure"
58 silly sh,-c,node-waf configure,/tmp/test/node_modules/node-icu-charset-detector spawning
59 verbose from cache /tmp/test/node_modules/node-icu-charset-detector/package.json
60 verbose readDependencies using package.json deps
61 verbose from cache /tmp/test/node_modules/node-icu-charset-detector/package.json
62 verbose readDependencies using package.json deps
63 silly resolved []
64 verbose about to build /tmp/test/node_modules/node-icu-charset-detector
65 info build /tmp/test/node_modules/node-icu-charset-detector
66 verbose from cache /tmp/test/node_modules/node-icu-charset-detector/package.json
67 verbose linkStuff [ false, false, false, '/tmp/test/node_modules' ]
68 info linkStuff node-icu-charset-detector@0.0.3
69 verbose linkBins node-icu-charset-detector@0.0.3
70 verbose linkMans node-icu-charset-detector@0.0.3
71 verbose rebuildBundles node-icu-charset-detector@0.0.3
72 info install node-icu-charset-detector@0.0.3
73 verbose unsafe-perm in lifecycle true
74 silly exec sh "-c" "node-waf build install"
75 silly sh,-c,node-waf build install,/tmp/test/node_modules/node-icu-charset-detector spawning
76 info node-icu-charset-detector@0.0.3 Failed to exec install script
77 info /tmp/test/node_modules/node-icu-charset-detector unbuild
78 verbose from cache /tmp/test/node_modules/node-icu-charset-detector/package.json
79 info preuninstall node-icu-charset-detector@0.0.3
80 info uninstall node-icu-charset-detector@0.0.3
81 verbose true,/tmp/test/node_modules,/tmp/test/node_modules unbuild node-icu-charset-detector@0.0.3
82 info postuninstall node-icu-charset-detector@0.0.3
83 error node-icu-charset-detector@0.0.3 install: `node-waf build install`
83 error `sh "-c" "node-waf build install"` failed with 1
84 error Failed at the node-icu-charset-detector@0.0.3 install script.
84 error This is most likely a problem with the node-icu-charset-detector package,
84 error not with npm itself.
84 error Tell the author that this fails on your system:
84 error     node-waf build install
84 error You can get their info via:
84 error     npm owner ls node-icu-charset-detector
84 error There is likely additional logging output above.
85 error System Linux 3.2.0-29-generic
86 error command "nodejs" "/usr/bin/npm" "install" "node-icu-charset-detector"
87 error cwd /tmp/test
88 error node -v v0.8.12
89 error npm -v 1.1.63
90 error code ELIFECYCLE
91 verbose exit [ 1, true ]
mooz commented 11 years ago

It seems that the cause of problem is $NODE_PATH, but I don't know how to reconcile the problem in the build script.

Here is a workaround for local installation.

NODE_PATH=../node_modules npm install node-icu-charset-detector

OK, I'll investigate a more smarter way.

mooz commented 11 years ago

I've fixed the problem in 8e60df9a039adc6c215437307ba8d03552aa6cca

bard commented 11 years ago

Works perfect, thank you!

bard commented 11 years ago

I spoke too soon. It installs, but in package.json I had to change:

  "main": "./build/default/lib/node-icu-charset-detector",

Into:

  "main": "./build/Release/obj.target/node-icu-charset-detector",

Or I would get an error when require()ing the module (no ./build/default/lib gets created on my system).

When actually using the module, I now get:

node: symbol lookup error: /tmp/test/node-icu-charset-detector/build/Release/obj.target/node-icu-charset-detector.node: undefined symbol: ucsdet_open_48
bard commented 11 years ago

Update: adding the following to binding.gyp fixes it for me:

'link_settings': {
  'libraries': [
    '-licui18n'
  ]
}
mooz commented 11 years ago

Oops. I didn't have enough tests. Thank you very much for the suggestions.

I've fixed installation scripts, both node-waf and node-gyp, and checked that this change suppresses installation failures in several environments.

bard commented 11 years ago

Confirmed as now working out of the box for me. Thanks!