Reputation: 9
I am trying to setup a rails project and I have to use the rake db:create
command to create a database. However using this command causes a Segmentation Fault bug with this error:
/home/steven/.rvm/gems/ruby-2.2.1/gems/json-1.8.3/lib/json/ext/parser.so: [BUG] Segmentation fault
ruby 1.9.3p484 (2013-11-22 revision 43786) [x86_64-linux]
However when I run the command bin/rake db:create
I do not get a segmentation fault. I have googled and could not find the reason for this, does anyone know what the cause of this problem is? Is this a serious problem?
After further testing, this seems to be a problem with the rake
command. Still not sure what is causing this.
EDIT
Running the which -a rake
command gives
/home/steven/.rvm/gems/ruby-2.2.1/bin/rake
/home/steven/.rvm/rubies/ruby-2.2.1/bin/rake
/usr/local/bin/rake
Running the which ruby
gives
/home/steven/.rvm/rubies/ruby-2.2.1/bin/ruby
Upvotes: 0
Views: 464
Reputation: 705
EDIT: This page looks like it has the answer: you need to reload/reinstall ruby.
Issue with json 1.8.1 gem in rails app on production
From what you've said above, I can see that you're using rvm. It looks like the gemset for the default rake is ruby-2.2.1, but there's an error involving ruby 1.9.3p484. That's a problem
Let's assume you want to use ruby 1.9.3p484 for your project. From the project directory, run rvm use 1.9.3p484
and it should switch the PATH variable to set things right.
To see more details about which rake executable you're using, and what's available, and the order of directories Ubuntu searches for a rake executable, you can use
which -a rake
-> list all possible rake executables on your PATHecho $PATH
-> show the PATH variable, which has all the directories Ubuntu searcheswhich rake
-> show the rake used by defaultNow, the reason bin/rake db:create
works is because it's the right version of ruby. To set things right, you need to do the rvm use command.
For me, the correct rvm gemset is automatically switched to when I cd to the rails directory. I forget exactly how this works on Ubuntu, but I do know one clue: you need to be in a login shell. You can type su - steven
to switch to a login shell, but in the Gnome Terminal preferences there's probably something about making sure you're in a login shell.
If you're already in a login shell but it's not working, you could also add
export PATH=/home/steven/.rvm/rubies/ruby-1.9.3p484/bin:$PATH
to the /home/steven/.bashrc
and/or the /home/steven/.bash_profile
file (I can never remember which).
There are a lot of reasons why this wouldn't work though, so feel free to comment with more details or update your question and I'll see if I can offer more ideas. - List item
Upvotes: 1