Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails s return: [BUG] Segmentation fault

If I run rails s, I get:

/Users/adam/.rvm/gems/ruby-1.9.3-p327/gems/pg-0.13.2/lib/pg_ext.bundle: [BUG] Segmentation fault
ruby 1.8.7 (2012-02-08 patchlevel 358) [universal-darwin12.0]

Abort trap: 6

Versions:

rails -v
Rails 3.2.1
ruby -v
ruby 1.9.3p327 (2012-11-10 revision 37606) [x86_64-darwin12.2.0]

Why is in the error message mentioned the ruby version 1.8.7 if I use 1.9.3?

like image 675
user984621 Avatar asked Nov 26 '12 17:11

user984621


3 Answers

It looks like your pg gem compiled against Ruby 1.8.7 when you originally installed it. Simply running gem uninstall pg; gem install pg should recompile it against Ruby 1.9.3.

If you're not already, I would recommend using RVM to avoid this kind of problem.

like image 69
davogones Avatar answered Nov 08 '22 15:11

davogones


I had a similar problem, running anything with bundle exec gave a segmentation fault:

~/mayapp >bundle exec rake -T
/Users/rogermarlow/.rvm/gems/ruby-1.9.3-p327/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle: [BUG] Segmentation fault
ruby 1.8.7 (2012-02-08 patchlevel 358) [universal-darwin11.0]

Abort trap: 6

I had two problems (1) using 1.9.3p327 instead of 1.9.3p125 and (2) GEM_HOME environment variable pointing to a now non-existent directory. So the fix for me was:

~/myapp >rvm list

rvm rubies

=* ruby-1.9.3-p327 [ x86_64 ]

# => - current
# =* - current && default
#  * - default

~/myapp >rvm install 1.9.3-p125
**snip**
~/myapp >rvm use 1.9.3-p125
Using /Users/rogermarlow/.rvm/gems/ruby-1.9.3-p125
Running /Users/rogermarlow/.rvm/hooks/after_use_maglev
~/myapp >echo $GEM_HOME
/Users/rogermarlow/.rvm/gems/ruby-1.9.3-p125
~/myapp ># you should check that the directory in $GEM_HOME exists, I had ...-p125@global which had been removed at some point
~/myapp >bundle install
**snip**

Now try that bundle exec which was segmentation faulting...

~/myapp >bundle exec rake -T
rake about                  # List versions of all Rails frameworks and the environment
rake assets:clean           # Remove compiled assets
rake assets:precompile      # Compile all the assets named in config.assets.precompile
**snip**
like image 25
Roger Marlow Avatar answered Nov 08 '22 15:11

Roger Marlow


I don't know how about your situation, I was installing ruby 1.8.7 before to test an older project, then I switched to my current rails project folder, where I have a .rvmrc file setting my gemset to 1.9.3@blabla. My ruby and rails versions were correct (1.9.3, 3.2.12), but apparently Postgres was somehow still trying to use 1.8.7. and having the same error you mentioned.

My solution:

1/ cd out of the current folder project with the .rvmrc file
2/ rvm use 1.9.3 --default

Then I came back to my current rails project ran bundle update pg, just in case, I don't know if that really had any effect, and voila, everything works!

like image 24
Petr Smejkal Avatar answered Nov 08 '22 13:11

Petr Smejkal