开发者

Can't access Rails console for app deployed on Passenger using Capistrano & RVM

开发者 https://www.devze.com 2023-02-17 12:06 出处:网络
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 i

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).

0

精彩评论

暂无评论...
验证码 换一张
取 消