/dev/null

(◞‸◟)

npmでのiconvインストールがコケた話

社内用に立ててるhubotのインストールの簡略化の為にpackage.jsonに色々書いてnpm installすれば終わるので楽をしているのですが、あるときインストールが失敗するようになってしまいました。

エラーログはこんな感じ。

npm http GET https://registry.npmjs.org/nan/-/nan-1.1.2.tgz
npm http 200 https://registry.npmjs.org/nan/-/nan-1.1.2.tgz

> iconv@2.1.3 install /home/user/hubot/node_modules/iconv
> node-gyp rebuild

make: ディレクトリ `/home/user/hubot/node_modules/iconv/build' に入ります
  CC(target) Release/obj.target/libiconv/deps/libiconv/lib/iconv.o
  AR(target) Release/obj.target/iconv.a
  COPY Release/iconv.a
  CXX(target) Release/obj.target/iconv/src/binding.o
../src/binding.cc:120: error: ‘template<class T, class P> static void<unnamed>::Iconv::_Nan_Weak_Callback_WeakCallback(const _NanWeakCallbackData<T, P>&)’ cannot be overloaded
../src/binding.cc:120: error: with ‘template<class T, class P> static void<unnamed>::Iconv::_Nan_Weak_Callback_WeakCallback(const _NanWeakCallbackData<T, P>&)’
../src/binding.cc:120: 警告: inline function ‘static void<unnamed>::Iconv::_Nan_Weak_Callback_WeakCallback(const _NanWeakCallbackData<T, P>&) [with T = v8::Object, P = <unnamed>::Iconv]’ used but never defined
make: *** [Release/obj.target/iconv/src/binding.o] エラー 1
make: ディレクトリ `/home/user/hubot/node_modules/iconv/build' から出ます
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:267:23)
gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:98:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:789:12)
gyp ERR! System Linux 2.6.32-358.18.1.el6.x86_64
gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/user/hubot/node_modules/iconv
gyp ERR! node -v v0.10.22
gyp ERR! node-gyp -v v0.11.0
gyp ERR! not ok
npm ERR! iconv@2.1.3 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the iconv@2.1.3 install script.
npm ERR! This is most likely a problem with the iconv package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get their info via:
npm ERR!     npm owner ls iconv
npm ERR! There is likely additional logging output above.

npm ERR! System Linux 2.6.32-358.18.1.el6.x86_64
npm ERR! command "/usr/local/bin/node" "/usr/local/bin/npm" "install"
npm ERR! cwd /home/jenkins/nabbit/hubot
npm ERR! node -v v0.10.22
npm ERR! npm -v 1.3.14
npm ERR! code ELIFECYCLE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     /home/user/hubot/npm-debug.log
npm ERR! not ok code 0

どうやらiconvが悪そう。

package.jsonには

 "dependencies" : {
        "iconv": "2.1.3"
  }

みたいに書いてました。

npmを見ると最新Versionは2.1.4

iconv - npm

これをpackage.jsonに書けばインストールが成功するようになりました。

いままで2.1.3指定で上手くインストールできてたのに不思議ですがとりあえず良しとします。

が、不安なのはiconvのバージョンが上がる度に前のバージョンだとコケるなんていう事態。

どうせ最低限の機能しか使っていないのでいつでも最新バージョンを追従してほしい。

その場合の書き方は

 "dependencies" : {
        "iconv": "*"
  }

となる。

身も蓋もない書き方ですが、こうすることで現在npmの最新を持ってきてくれるようです。

まぁ破壊的変更加えられたらこれもこれでscript側が死にそうですがそれはそれということで。