Postgres segmentation fault ruby gem - ruby

I am trying to run this project https://github.com/eLobato/cartodb-rb-client but apparently either my rvm is messed up or pg has a terrible bug.
This is the error trace
/usr/bin/ruby1.8 -S bundle exec rspec "./spec/model/data_spec.rb" "./spec/model/metadata_spec.rb" "./spec/model/scopes_spec.rb" "./spec/client_spec.rb"
/home/daniel/.rvm/gems/ruby-1.9.2-p290#cartodb-rb-client/gems/pg-0.11.0/lib/pg_ext.so: [BUG] Segmentation fault
ruby 1.8.7 (2011-06-30 patchlevel 352) [x86_64-linux]
Aborted
rake aborted!
ruby -S bundle exec rspec "./spec/model/data_spec.rb" "./spec/model/metadata_spec.rb" "./spec/model/scopes_spec.rb" "./spec/client_spec.rb" failed
Tasks: TOP => spec
(See full trace by running task with --trace)
The Segmentation fault line really bugs me a lot because I tried to reinstall pg with no avail. I am running Ubuntu 11.10 and I have installed both ruby 1.9.2 and 1.8.7
Any clue?

I had this error too. Fixed it by removing all versions of Ruby installed on my system, then re-installing 1.9.3
Like so:
$ rvm remove all
$ rvm install ruby-1.9.3-p392

You're running a system Ruby 1.8.7 interpreter, but somehow loading a pg gem installed under Ruby 1.9.2 installed via rvm.
Ruby 1.8.7 and 1.9.2 have substantially different ABIs, so their extensions are not interchangeable.

For me it seemed to be the version of the pg gem that was in my Gemfile.lock. I had 0.13.2 in there, and it just didn't seem to work on Ruby 1.9.3. I ran bundle update pg and got 0.14.0, and then things started working.

Segmentation fault is, when program is accessing memory, which kernel don't expect (out of index, out of memory allocated block etc.).
What do you see, when you try:
ruby -S bundle --trace exec rspec "./spec/model/data_spec.rb" "./spec/model/metadata_spec.rb" "./spec/model/scopes_spec.rb" "./spec/client_spec.rb"
as backtrace advice to you?

Related

puppet --version fails with ruby issue

I have CentOS6 on which I have configured puppet server. but Whenever I try to execute ant puppet command it fails with ruby issue. see the output for puppet --version
-bash-4.1# puppet --version
/usr/local/rvm/gems/ruby-1.9.3-p551/gems/json-1.8.3/lib/json/ext/parser.so: [BUG] Segmentation fault
ruby 1.8.7 (2013-06-27 patchlevel 374) [x86_64-linux]
Aborted (core dumped)
Tried re-installing puppet and ruby but no luck.
Try I had a similar issue, and did a few things and it was fixed before I knew which one fixed it, but try this:
gem update --system
yum install ruby-json
Good luck!
Your Ruby 1.8.7 is trying to use a 1.9.3 gem for some reason.
This can be tricky to get right. In your shoes, I would check if I can
get rid of ruby1.8 altogether
make ruby1.9 the default Ruby on the system
make sure that Puppet always uses ruby1.9
Specifics depend heavily on the way Ruby and Puppet were actually installed.

"bundle install" for Ruby 1.8.7 on Ubuntu Raring Ringtail 13.04

I'm not a rubyist and there might be something obvious I'm missing.
I've wrote an application in Ruby 1.8.7, I'm trying to package it in Vagrant (running Raring 13.04), but I've to run "bundle install" to install the requirements and even though gem1.8 does exist, running bundle install still install the gems for Ruby 1.9.3. And then my program fails at runtime...
Any idea about how to solve this?
UPDATE 1
The related Gemfile (thanks to the first answerers):
ruby '1.8.7'
# ...
gem 'trollop'
but for ruby1.8 myfile.rb an error is raised
no such file to load -- trollop (LoadError)
After investigation, the problem looks in bundle install:
Your Ruby version is 1.9.3, but your Gemfile specified 1.8.7
I don't get how to solve the problem.
UPDATE 2
After following the advices from #klaffenboeck things have changed. I'm using RVM and have Ruby 1.8.7 when entering in the project folder. Bundler seems to install things correctly, however the require seems to fail... Path problem?
See here for detail about Vagrant / RVM setup: https://rvm.io/integration/vagrant
UPDATE 3
Problem solved, I was missing a:
require 'rubygems'
before all gems (it worked locally but not in Vagrant).
Bundler will install gems (by default) for whichever Ruby is in your PATH.
Try /usr/bin/env ruby -v or which ruby to figure out which one that is; my guess is you're running bundler with Ruby 1.8.
Adding
ruby '1.8.7'
on top of your Gemfile will help diagnose.
Not aware of this problem in general, but try to put the ruby-version at the top of your gemfile:
#Gemfile
ruby '1.8.7'
# followed by your gems
Edit:
this is most likely because your Gemfile.lock states ruby 1.9.3 - run bundle update
Try running gem uninstall bundler, then gem1.8 install bundler.
Your bundle command seems to be running under Ruby 1.9.3. You can verify which ruby executable bundler is using with head -n 1 $(which bundle). You want it to be ruby1.8.

installing compass on mac issue

I am installing compass on mac. when I run gem install compass command on terminal I got following output
I already have ruby ruby 1.8.7 (2012-02-08 patchlevel 358) [universal-darwin11.0] installed. I got this output after issuing ruby -v command on terminal.
How can fix above problems or how can I install compass successfully?
As far as I know you should be a root to install gems when using ruby from system.
It is a very good idea to run ruby with rvm or similar tools instead of running
system.

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 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.

Bus Error - What causes this in Ruby?

I have run into this error 5 or 10 times over the past few years and have never found a clear answer to this problem. Here is the error:
$ rake db:migrate
/usr/lib/ruby/gems/1.8/gems/libxml-ruby-0.9.5/lib/libxml_ruby.bundle: [BUG] Bus Error
ruby 1.8.7 (2009-06-12 patchlevel 174) [i686-darwin9.7.0]
Abort trap
The app I am running this in is using RMagick.
I have run into this problem when installing ImageMagick a while ago, and when installing Nokogiri, and when installing MySQL. For Nokogiri it was because I needed a more recent version of libxml. What are your thoughts on this? Any fixes? How can I check the version of RMagick the project is loading?
I am on a Mac, 10.5.8.
Thanks for the help,
Lance
I hit this issue running a worker in resque after upgrading Ruby from 1.8.6 to 1.8.7:
$ QUEUE=* rake resque:work
(in /Users/kimball/pulse)
/usr/local/lib/ruby/1.8/openssl/ssl-internal.rb:30: [BUG] Bus Error
ruby 1.8.7 (2010-08-16 patchlevel 302) [i686-darwin9.8.0]
Abort trap
Found this, but pretty much just says upgrade to 1.9.1:
http://redmine.ruby-lang.org/issues/show/405
If anyone knows how to fix it in 1.8.7, I'd be grateful.
Kimball

Resources