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
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 PATH
echo $PATH -> show the PATH variable, which has all the directories Ubuntu searches
which rake -> show the rake used by default
Now, 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
Related
I have cloned a rails project from Ryan Bates (complex forms samples) and am having a problem with rake. I titled the question generally because I suspect it's an issue with my setup/usage rather than the project itself.
The project I am trying to use is:
I am using RVM on OSX and my default ruby is ruby-1.9.2-p290.
Here are the steps I am doing in a terminal (starting in a new empty directory):
git clone https://github.com/ryanb/complex-form-examples.git
--Created the project without error
The first time I did this, after I changed dir to the "complex-forms-examples", I got an RVM warning which I had not seen before. It was asking for some sort of permission which I granted. It does not do this anymore when I repeat the clone in a new empty directory.
The warning mentioned that there is an .rvmrc file in the directory. The contents are as follows (one line):
rvm 1.9.2#complex-form-examples --create
I then run 'bundle' and have no errors.
Then I try to run "rake db:migrate" and I get the following error:
-bash: /Users/ken/.rvm/gems/ruby-1.9.2-p290#global/bin/rake: /Users/ken/.rvm/rubies/ruby-1.9.2-p136/bin/ruby: bad interpreter: No
such file or directory
I get the same error when I run rake by itself or with any other parameter.
I have no ruby 1.9.2-p136 so I don't know why it is trying to use that ruby.
'rails s' is starting the server without error
I am only having problems with this project (i.e. rake is still working fine in my other rails projects).
Can anyone tell me what I'm missing?
Thanks
It could be broken migration/upgrade of ruby, try this:
rvm 1.9.2#global,1.9.2#complex-form-examples do gem pristine
rvm 1.9.2#global do gem pristine rake
make sure there is no error reported, in case of errors you need to pristine all gems manually (like in the second line)
it looks like you have issues with updating rvm, go this route:
rvm get head && rvm reload
rvm use 1.9.2#complex-form-examples --create --install
also make sure you trust .rvmrc properly (cd project dir first):
rvm rvmrc trust .
maybe not related but you might find this interesting: http://screencasts.org/episodes/how-to-use-rvm
Alright, well I'm trying to fix this problem again. I followed this fix to eliminate the error by reverting to version 0.8.7, which worked the first time. However, now I'm trying to use cucumber and I'm getting it all again.
I tried it again by running gem uninstall rake -v=0.9.2.2 which lists all the gem dependencies. Successfully uninstalled. Then I ran bundle update rake. Using rake (0.8.7). Cool. rake -V. rake, version 0.9.2.2. wat. Same problems return. What am I missing? I thought 9.2 was supposed to fix this bug anyway?
I think this fix is obsolete. Rake 0.9.0 got fixed, and 0.9.2.2 is certainly working. You want to uninstall and completely eradicate rake 0.8.x. Try something like:
gem list -d rake
The -d switch will show the installation directories. If you're using RVM, there may be multiple search paths that get hit, running rvm info will tell you the search path and preference ordering. Depending on the system you're on, your OS may also ship with an old rake version. Try uninstalling everything other than the local gemset (if using RVM) or the latest rake (if not using RVM).
The problem with the rake gem uninstall sounds like you have Rake in your default gemset, check ~/.rvm/gemsets/global.gems It will no doubt have rake in it
I'm deploying a rails application using Capistrano to a shared server (on WebFaction). This means there are several different Ruby version installed there.
Everything works fine until I want to run some rake tasks. These tasks fail by saying I don't have the right RubyGems version.
From this thread I understood that fixing it would be as easy as adding the full path to the correct rake folder to my rake commands. I tried that but failed again, now because the Ruby interpreter that is used is the wrong one.
I assumed that capistrano would use the username/password I gave it to run commands on the server but it seems not to be the case.
Am I missing something? How can I fix that?
Thanks!
This is indeed a path issue. I solved it by symlinking my ruby, rake, and rails executables to my path. For instance, if the executables that you want (but are failing to work) are located at /opt/ruby/bin/ruby, you'll symlink it to:
ln -s /opt/ruby/bin/ruby /usr/local/bin/ruby
I don't know why but when I run rake commands in my rails project, nothing happens. Also rails server does nothing. Any suggestions?
you can add an "ruby -rtracer" to the begining to see where it is hanging.
The solution for me entailed exiting rails console -sandbox.
I think sandboxing console puts a lock of some sort on the database.
You could try adding the --trace argument to your rake calls to see if that sheds any light on where it is getting stuck. Failing that there may be some information in the logs.
It does suggest that something that is getting stuck during setting up your environment which may be something you've added to environment.rb.
Are you using rvm?
A lot of advice these days is to install ruby within rvm and rails within an rvm gemset. If you've done this, then you need to remember to do commands such as these at the start of your terminal session:
rvm use 1.9.3
rvm gemset use ruby193rails3
I found if I forgot to do this, then the rake command, even just a simple rake --version , would hang and thrash the disk.
...which all seems a bit fragile. I guess it's latching onto part of rails but with some files missing due to rvm not having moved them into place or something.
Spring has a bug in Rails 4.1 which also causes this (not the OP's issue, based on date). For those googling, I solved this problem my typing "spring stop". Spring will be automatically restarted the next time you run "rails ". To give proper credit, I found this information from this blog:
http://www.dixis.com/?p=754
What fixed this for me was running
bin/spring stop
and then running my rake command after.
I'm running a crontab that executes a rake task. I'm getting the following error (with MAILTO from crontab):
rake aborted!
no such file to load -- bundler
/Users/Mendel/Sites/misnooit/Rakefile:4
(See full trace by running task with --trace)
I'm using rvm with:
ruby: ruby 1.9.1p378
rails: Rails 3.0.0.beta
$GEM_HOME: /Users/Mendel/.rvm/gems/ruby-1.9.1-p378
bundler: bundler (0.9.11)
The error is pretty self explanatory but I'm not able to fix it.. Is there someone with more knowledge about this matter? Thanks in advance.
I just experienced this. Problem for me was that the instances of rake and ruby I use were built locally, and installed to /usr/local/bin. There are other versions in /usr/bin (must check what I installed using apt-get in the past..).
So, in my crontab file I set the path using
PATH=/usr/local/bin:/usr/bin:/bin
(I was seeing it as PATH=/usr/bin:/bin in the failed crontab emails)
and it works.
Just guessing: is Ruby 1.9.1p378 your default Ruby?
I think it's not so you can just execute rvm --defaults "ruby-1.9.1-p378"
If this doesn't help, are you sure bundler has been installed when ruby 1.9 was used?
Also, in your test/production environment, you may want to run you cron with another user than yourself. So I suggest you install rvm as "root", and set up (still as root) a default RVM that will be the default for all the system users.
And of course, you can override this per user.
I've had good experience using http://github.com/javan/whenever
It uses a Ruby DSL to manage cron tasks and it handles setting all the environment magic.
every 3.hours do
runner "MyModel.some_process"
rake "my:rake:task"
end
have your run the command with --trace asserted to ensure there isn't something obvious in the rake command, but what you could do is chain the crontab commands
rvm 1.9.1;rake do_whatever_task
That way it will load the ruby environment every time prior to running rake.
I had a similar issue this weekend, I found that my Rake Gem was updated to 0.90 you need rake 0.8.7. This solved the issue on my end.