I have been working with rails and have been trying to setup passenger with rake 10.1.0 and it sends back me this errors.
Here is the link to the error.Website LInk
The problem is that when you run the ruby command from the web server, it does not add /home/rails/.rvm/gems/ruby-2.0.0-p353@global/gems
to your GEM_PATH
, only /usr/local/rvm/.../gems
. Your rake gem is installed in /home/rails/.rvm/gems
. You need to add /home/rails/.rvm/gems/ruby-2.0.0-p353@global/gems
to GEM_PATH
.
So after hours of working on this problem I found what it was created by. So here is how I solved it.
First problem was with the fact that I installed rvm incorrectly. I installed it under the rails user which resulted in some access problems. However this does not resolve the problem with the can't find the rake file. In order to fix this I had to start over. Because it was a cloud server starting over was easy. Just did a full rest and followed there few steps.
\curl -sSL https://get.rvm.io | bash
apt-get update
apt-get upgrade
apt-get install build-essential
rvm install ruby-2.0.0-p353
rvm ruby-2.0.0-p353@global --default --create
gem install passenger
passenger-install-apache2-module
Not all these steps are needed on some server depending on what is installed but in my case I wanted to make sure everything worked.
As you run the last command passenger-install-apache2-module
you will see something like this. Just follow the instructions in my case I got this result.
Installation instructions for required software
* To install Curl development headers with SSL support:
Please run apt-get install libcurl4-openssl-dev or libcurl4-gnutls-dev, whichever you prefer.
* To install Apache 2:
Please install it with apt-get install apache2-mpm-worker
* To install Apache 2 development headers:
Please install it with apt-get install apache2-threaded-dev
* To install Apache Portable Runtime (APR) development headers:
Please install it with apt-get install libapr1-dev
* To install Apache Portable Runtime Utility (APU) development headers:
Please install it with apt-get install libaprutil1-dev
This was simple just followed the install steps and now I have apache running. After that you just run passenger-install-apache2-module
again.
Everything should pass this time and we are on to the next step.
In my case the next step was to add this code to the /etc/apache2/apache2.conf
.
LoadModule passenger_module /usr/local/rvm/gems/ruby-2.0.0-p353@global/gems/passenger-4.0.29/buildout/apache2/mod_passenger.so
PassengerRoot /usr/local/rvm/gems/ruby-2.0.0-p353@global/gems/passenger-4.0.29
PassengerDefaultRuby /usr/local/rvm/wrappers/ruby-2.0.0-p353@global/ruby
I just added it to the top really does not matter where you add it everything works.
after you have done that make a new ruby on rails application with these steps
rvm use rvm ruby-2.0.0-p353@test --create
gem install rails
gem install bundler
rails new tester
cd tester
After which you need to create a new sites-avaliable.Mine looks like this.
root@rails-app:/etc/apache2/sites-enabled# cat /etc/apache2/sites-available/test.conf
<VirtualHost *:80>
ServerName www.something.com
# !!! Be sure to point DocumentRoot to 'public'!
DocumentRoot /home/rails/apps/tester/public
<Directory "/home/rails/apps/tester/public">
# This relaxes Apache security settings.
AllowOverride all
# MultiViews must be turned off.
Options -MultiViews
Require all granted
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Run this to restart and add test
sudo a2ensite test && sudo service apache2 restart
Found out that if you don't have the Require all granted
it will send you a error message that looks something like this in the error log. Not total sure if you need any of the others like Allow from all
but I added them anyway. Here is some extra documentation on this error if you want some more reading Wiki Apache Org
[client 75.1.169.97:51729] AH01797: client denied by server configuration: /home/rails/apps/tester/public/
oh if you were wondering the error log is located in /var/log/apache2/
After which it got me back to the error I noted above
So here is how I fixed can't find the Could not find rake-10.1.0 in any of the sources (Bundler::GemNotFound)
.
first thing you need to do is simple just created .ruby-version
and .ruby-gemset
here is what mine look like.
rails@rails-app:~/apps/tester$ cat .ruby-version
ruby-2.0.0-p353
rails@rails-app:~/apps/tester$ cat .ruby-gemset
test
after that you need to add this file into your config folder
# config/setup_load_paths.rb
if ENV['MY_RUBY_HOME'] && ENV['MY_RUBY_HOME'].include?('rvm')
begin
rvm_path = File.dirname(File.dirname(ENV['MY_RUBY_HOME']))
rvm_lib_path = File.join(rvm_path, 'lib')
# $LOAD_PATH.unshift rvm_lib_path
require 'rvm'
RVM.use_from_path! File.dirname(File.dirname(__FILE__))
rescue LoadError
# RVM is unavailable at this point.
raise "RVM ruby lib is currently unavailable."
end
end
ENV['BUNDLE_GEMFILE'] = File.expand_path('../Gemfile', File.dirname(__FILE__))
require 'bundler/setup'
This is a bit of magic here but was it is doing is changing the default rvm gemset for passenger. However if your using capistrano you can use rvm-capistrano. However you have to use older version of capistrano. Capistrano 3 does not work with rvm-capistrano.
If this does not work for you might be how you have it set up. Anyway hope that helps.
I had this exact Passenger message and resolved it with this solution from Brian Armstrong: Bundler installing gems in wrong location (run bundle install --system).
Your problem is that you added an additional gem that has unresolved dependencies. Run bundle update
to update your dependencies and you should be good to go.
That's a lot more hassle than needbe. All you really had to do was reset your gemsets: https://github.com/phusion/passenger/wiki/Resetting-RVM-gemsets
rvm gemset empty
or before rvm use whateveryourgemset
Basically you can list all active gemsets, empty them all, then install passenger into the correct one by installing your bundle again from the application folder. Problem solved.