This is a production server. I have Passenger installed and it works properly for the most part. However, I always have to pack the gems with the projects. If I don't, I get this error message:
Missing the Rails 2.3.8 gem. Please `gem install -v=2.3.8 rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.
gem list --local returns rails 2.3.8 as well as 2.3.5 so the gem is actually not missing. Since I could not resolve this issue, I keep including the rails gem in every project (which results is a properly working application).
Any ideas?
P.S I did try the suggestions of the error message, my config is asking for 2.3.8 which I have installed
Make sure you are installing/running the gem command with the same user permission as Passenger.
By default, Passenger runs inside Apache which has superuser privileges.
If you type gem install, the Gems will be saved in your user folder unless you are root.
If you're installing gems logged in as a normal user (non-root) or without using sudo, your gems go into .gems folder in your home directory (eg. /home/matt/.gems) and Passenger cannot find them.
You can either install them as root/sudo or add your local directory to your GEM_HOME/GEM_PATH. Not sure if this is the best solution, but I put this at the top of config/environment.rb in my application:
if ENV['RAILS_ENV'] == 'production'
ENV['HOME'] = "/home/matt"
ENV['GEM_HOME'] = "/home/matt/.gems"
ENV['GEM_PATH'] = "/home/matt/.gems"
end
Related
I am new to ruby. I am trying to use AuthLogic gem in my rails application. I had installed it and added
config.gem"authlogic"
in my environment.rb file and executed the command
rails generate nifty_scaffold user username:string email:stringpassword:string new
It thrown me a error "git://github.com/odorcicd/authlogic.git (at rails3) is not yet checked out. Run bundle install first." Oftenly even though i run bundle install. Why? Please any one help me.
If you are using Rails 4+ versions, you need not to include gems in environment.rb file. You should add the gems in Gemfile as follows,
gem 'authlogic'
Once you have added new gems in Gemfile in addition to the existing gems, you must run
bundle install
so that, your rails application can consider including the recently added gems (here, authlogic gem in our example) in your application. That is what the reason why you need to run bundle install more often (only when you add new gems in Gemfile)
And, please do not add gems in config/environment.rb file. That is Rails 2 way.
I have an app running on my localhost which I want to install on my hosting account. The host is Bluehost and they appear to support RoR, as evidenced by this tutorial which I am trying to follow precisely.
The thing I'm stuck on is where my ruby gems should be? I'm currently unable to bundle install even immediately after gem install bundler so I'm pretty sure my app is looking in the wrong place. But before I can correct that, I think I need to know what is the right place.
Currently it appears there are gems here:
~/ruby/gems/gems
This is my app's /config/environment.rb file:
# Load the rails application
require File.expand_path('../application', __FILE__)
# Initialize the rails application
Goodwatching::Application.initialize!
ENV['GEM_PATH'] = '/home5/secretde/ruby/gems/gems:/usr/lib/ruby/gems/1.8'
Currently I can install a gem like this gem install bundler and it succeeds. But then afterwards I try bundle install and it says to intall bundler first.
The bundle installfail means that you are unable to find the path to bundle executable.
Your PATH must to include the path to bundle executable.
You could tray something like ~/ruby/gems/gems/bundler/bin/bundle install to workaround the path problem.
I was working on a project just fine, logged off for the night and the next morning when I tried to start again I was getting this error:
Missing the Rails 2.3.12 gem. Please `gem install -v=2.3.12 rails`,
update your RAILS_GEM_VERSION setting in config/environment.rb
for the Rails version you do have installed, or comment out RAILS_GEM_VERSION
to use the latest version installed.
I did a gem list and it's definitely installed:
rails (3.1.0, 2.3.14, 2.3.12, 2.3.8)
I also made sure that 2.3.12 was the required Gem in the environment.rb:
RAILS_GEM_VERSION = '2.3.12' unless defined? RAILS_GEM_VERSION
Before I logged off I deployed my changes to demo, which was working fine, and when I checked it the next morning I was getting the same error message.
I'm still pretty new to RoR so I am not sure how to trouble shoot this.
I had this problem before and it was because I was defaulting to the system version of ruby. Run "ruby -v" in console and make sure you are using the version you want to. If you are not run this in the console:
$ rvm use "x"
Where "x" is the version of ruby you want to use.
Also, make sure your gemsets are in order. You can create and start using a new gemset by running this in the console ("xxx" = what you want to call your gemset):
$ rvm gemset create xxx
$ rvm gemset use xxx
After creating (and switching to) the gemset you can try reinstalling rails. Creating a new gemset means that there are no gems associated with whatever project you are working on anymore. So you will need to reinstall all your other gems too. Should be easy with a "bundle install"
Hope this helps.
After finally managing to get my Rails app working, I've got stuck with a slightly perplexing problem. I've deployed my Rails 3.0.5 app to a Ubuntu 10.10 server with Capistrano, RVM and Nginx. All is working nicely and I can confirm Rails is working as I'm getting data from the database and meaningful log messages.
The problem is that on the server, I can't access the console. When I try
rails c
It says "The program 'rails' is currently not installed. To run 'rails' please ask your administrator to install the package 'rails'"
However it is installed otherwise my application wouldn't work! I've only got two RVM gemsets installed, the global one and one called "rails305". Trying
rvm gemset use rails305
then
gem list
doesn't show any of the gems that my app needs, however they must be installed because 1) the app wouldn't work without them and 2) in my Capistrano deploy script, bundler installs them (to that gemset). So the problem is obviously something to do with RVM but I can't work out what it is... anyone any ideas?
It looks like Capistrano uses bundler so you might want to try
bundle exec rails c
from the deployment directory.
See the Bundler deployment page for more information.
Bundler by default doesn't install gems into the default rvm environment when deployed via capistrano, it installs to the "shared/bundle" directory instead, to try and accommodate production installation environments that aren't using RVM. If you are using RVM in production, and want to just have bundler install to your default ruby/gemset (which is terribly useful if you are going to be logging into the production, running rake scripts, console, etc), add the following options to your config/deploy.rb:
set :bundle_dir, ""
set :bundle_flags, ""
This will remove the "--deployment" (and "--quiet", which you may or may not want to keep) and --path flags which cause bundler to try and package everything up nicely, so bundler will now install to the user's RVM environment; making your server environment work a lot more like your dev environment (which can be good or bad depending on what your needs are).
Rails 3.0.0, Passenger 2.2.15:
Create a new Rails project
Add gem 'paperclip', :git => 'git://github.com/lmumar/paperclip.git', :branch => 'rails3'
to your Gemfile
Do bundle install
Everything OK, starting with rails/script server & accessing also works
However, when accessing with Passenger, it says:
git://github.com/lmumar/paperclip.git (at rails3) is not checked out. Please run bundle install (Bundler::GitError)
I have tried bundler pack (doesn't help) and setting BUNDER_HOME to ~/.bundler (the Paperclip git gets installed there by bundler install) in the .htaccess and various places in config/*.rb, but this wasn't successful, too.
~/.bundler is owned by the same user as the Rails project (Passenger runs under this user), so it can't be a permission problem. sudo is installed and called by bundle install.
Any hints?
Im used to have this problem, resolve using
bundle --deployment
Which will install the gems in vendor/bundle
Solution (took me a few hours):
Mare sure that RAILS_ROOT/.bundle/config (SetEnv etc. didn't work for me) contains:
---
BUNDLE_PATH: /home/xxxxx/.bundler
Note BUNDLE_PATH, not BUNDLER_PATH! There was also an DISABLED_SHARED_GEMS=1 entry, I removed it.
Then bundler recognises the correct path even when loaded from Passenger. Without Passenger, it always worked (and used /home/xxxxx/.bundler, as said in the question)
You can use bundle install --path vendor/bundle to install the gems locally, instead of into system gems.
If you want to keep using system gems, though, it's just one line in your Apache configuration to tell Passenger where to find your system gems:
SetEnv GEM_HOME /Users/bob/.bundle
There's a slightly more elaborate writeup on my blog at Using Passenger with GEM_HOME set
I ran into this problem while writing a Sinatra app. To solve it I added this line to config.ru.
require 'bundler/setup'
I had the same problem and it was due to a rights issue with RVM.
The user that run the web server can not check if GIT gem is available.
As "Passenger" using the web user to run, it can not do this check.
The solution I found was to add web user to rvm group:
usermod -a -G rvm apache
I hope this will help some other people that don't want to have GEM deployed into "vendor/bundle".
I installed the passenger gem and its apache module as a sudo user and that was the problem in my case.
The reason why I used sudo initially was that I copied the code from railscasts' episode 122. Installing it without sodu access resolved this issue. Since Ruby was installed using rvm without the sudo access on my system.