环境: Rails 3.1.0 Ruby 1.9.3-p125 雪豹 10.6.8
在练习 Rails 项目:
$ bundle install
nokogiri 装不起来。
错误讯息(仅节录有错部分):
checking for iconv_open() in iconv.h... no
... 略 ...
in /opt/local/lib/libz.1.dylib, file was built for i386 which is not the architecture being linked (x86_64)
collect2: ld returned 1 exit status
make: *** [nokogiri.bundle] Error 1
我试了差不多 1 个多小时:
一开始想说是不是我的 iconv 坏了,试了 rvm 网站的 iconv quick fix
又在 stackover flow 找了,有一解答说是 Macport 闹的,
我是先装 Macport 的,再装 brew 的,
感觉问题非常严重。又有人说重装 zlib 64 位,试了不行。
还是不死心,github issue 四处找。有人说跟 rvm也有关系,
用 rvm 重装 Ruby,使用 rvm 重装了 ruby 1.9.3 。还是不行。
本来估计是当初 Macport 害的,都拿出雪豹光碟,要来个彻底重装了。
眼睛又喵到 stackover flow 一大哥说:
sudo rm /opt/local/lib/libz*
就可以了,我也不知道为什么。
恩...希望可以省下你的一小时。