开发者

Upgraded to ruby 1.9.2 and getting Segmentation Fault errors in nokogiri

I decided to upgrade to 1.9.2 ruby yesterday and also installed rvm to do it. I ran a few recent files I had working previously on 1.8.7 but anything requiring nokogiri fails with the following errors.

/Users/myusername/.rvm/gems/ruby-1.9.2-p0/gems/nokogiri-1.4.3.1/lib/nokogiri/nokogiri.bundle: [BUG] Segmentation fault
ruby 1.8.7 (2009-06-12 patchlevel 174) [universal-darwin10.0]

I am running nokogiri开发者_StackOverflow 1.4.3.1, ruby 1.9.2 on OSX Snow Leopard 10.6.4


If you get a Segmentation fault error from nokogiri, e.g., when you open your rails console, and you are using RVM and your ruby version is 1.9.2 something (mine currently is 1.9.2p136) and you notice a reference to ruby 1.8.7 just after the nokogiri segmentation fault message, then perhaps the following may be of assistance...

ERROR

$ rails c
/Users/lex/.rvm/gems/ruby-1.9.2-p136@lmi/gems/nokogiri-1.4.4/lib/nokogiri/nokogiri.bundle: [BUG] Segmentation fault
ruby 1.8.7 (2009-06-12 patchlevel 174) [universal-darwin10.0]

Abort trap

SOLUTION

(1) make sure that ruby 1.8.7 is not a rvm ruby version: - run rvm list

if it is, then remove it: ex: rvm uninstall ree-1.8.7-2010.02

(2) uninstall nokogiri and libxml2 related dependencies:

$ gem uninstall nokogiri
$ brew uninstall libxml2

(3) install libxml2 using homebrew

$ brew install libxml2
$ brew link libxml2

(4) install libxslt from source

$ wget ftp://xmlsoft.org/libxml2/libxslt-1.1.26.tar.gz
$ tar -zxvf libxslt-1.1.26.tar.gz
$ cd libxslt-1.1.26
$ ./configure --prefix=/usr/local/Cellar/libxslt/1.1.26    --with-libxml-prefix=/usr/local/Cellar/libxml2/2.7.7
$ make
$ sudo make install

(5) install nokogiri

gem install nokogiri

Alternative (ensure your paths are correct): gem install nokogiri -- --with-xml2-include=/usr/local/Cellar/libxml2/2.7.7/include --with-xml2-lib=/usr/local/Cellar/libxml2/2.7.7/lib --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.26

(6) test

$ rails c
Loading development environment (Rails 3.0.3)
>>

Getting and keeping your Ruby XML parsing libraries running properly can be an issue. Here are some alternatives: LibXML, Hpricot, REXML


I'm guessing you just need to tell rvm to use the correct ruby.

rvm 1.9.2

Otherwise why would your second line indicate 1.8.7?

You shouldn't expect native code compiled against one major version of ruby to link cleanly to another. There's no ABI contract, afaik.

  • https://rvm.io/rvm/basics/
  • https://rvm.io/rvm/cli/


Is it possible you originally built Nokogiri on Leopard then upgraded to Snow Leopard?

If so, do a gem uninstall nokogiri followed by gem install nokogiri. That will force it to recompile for your currently selected Ruby and OS.

I saw the similar problems when I upgraded from Leopard to Snow Leopard, and reinstalled my Ruby. The gems didn't get recompiled, so I had to force several of them to do so.


Try running rvm requirements in Terminal and see if there are any missing dependencies. (It shows in red in my OS X)

The returned notes helped me install missing dependencies with brew, with clearly stated steps.


all the suggestions here didn't work for me, but the abridged answer to this issue by mmrobins below:

rvm gemset empty

followed by a standard bundle install got everything working for me.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜