rorofromfrance
rorofromfrance

Reputation: 1904

Deploying to RVM-enviroment with Capistrano (RoR App)

I've been looking around a lot for answers to my problem but I can't find a solution that works...so here is my first post ever on stackoverflow!

A while ago I setup an apache server with RVM in order to host one of my client's website. By then, my development environment also had ruby installed through rvm. In the meanwhile, I changed my development environment and now started using VM VirtualBox with Ubuntu, and installed ruby directly from source using apt-get install ruby. I've used Capistrano to deploy all my projects.

Now I've done some work back on that project, but when I tried to deploy it to the production server, I get this error:

2013-07-08 08:12:50 executing `bundle:install'
* executing "cd /var/www/project/releases/20130708061242 && bundle install --gemfile /var/www/project/releases/20130708061242/Gemfile --path /var/www/project/shared/bundle --deployment --quiet --without development test"
    servers: ["xxx.xx.xxx.xxx"]
    [xxx.xx.xxx.xxx] executing command
*** [err :: xxx.xx.xxx.xxx] tput:
*** [err :: xxx.xx.xxx.xxx] No value for $TERM and no -T specified
*** [err :: xxx.xx.xxx.xxx] 
*** [err :: xxx.xx.xxx.xxx] tput:
*** [err :: xxx.xx.xxx.xxx] No value for $TERM and no -T specified
*** [err :: xxx.xx.xxx.xxx] 
 ** [out :: xxx.xx.xxx.xxx] ERROR: Gem bundler is not installed, run `gem install bundler` first.
    command finished in 818ms
*** [deploy:update_code] rolling back
  * executing "rm -rf /var/www/project/releases/20130708061242; true"
    servers: ["xxx.xx.xxx.xxx"]
    [xxx.xx.xxx.xxx] executing command
    command finished in 693ms
failed: "rvm_path=$HOME/.rvm/ $HOME/.rvm/bin/rvm-shell 'default' -c 'cd /var/www/project/releases/20130708061242 && bundle install --gemfile /var/www/project/releases/20130708061242/Gemfile --path /var/www/project/shared/bundle --deployment --quiet --without development test'" on xxx.xx.xxx.xxx

I also have my own testing server and I have no problem when deploying on this one (which has rbenv instead).

Server end stuff is my least knowledgeable area :) Let me know if I can give any additional information that you might need.

Thanks!

EDIT

Here is my deploy.rb

require "bundler/capistrano"
require "rvm/capistrano"

server "xxx.xx.xxx.xxx", :app, :web, :db, :primary => true

set :rvm_ruby_string, ENV['GEM_HOME'].gsub(/.*\//,"")
set :rvm_install_ruby_params, '--1.9'      # for jruby/rbx default to 1.9 mode
set :rvm_install_pkgs, %w[libyaml openssl] # package list from https://rvm.io/packages
set :rvm_install_ruby_params, '--with-opt-dir=/usr/local/rvm/usr' # package support

before 'deploy:setup', 'rvm:install_rvm'   # install RVM
before 'deploy:setup', 'rvm:install_pkgs'  # install RVM packages before Ruby
before 'deploy:setup', 'rvm:install_ruby'  # install Ruby and create gemset, or:
before 'deploy:setup', 'rvm:create_gemset' # only create gemset
before 'deploy:setup', 'rvm:import_gemset' # import gemset from file

#General settings
set :ssh_options, { :forward_agent => true }
set :application, "project"
set :repository,  "[email protected]:project.git"
set :deploy_to, "/var/www/#{application}"
set :deploy_via, :remote_cache

set :scm, :git
set :scm_user, "deploy"
set :user, :deploy
set :use_sudo, false
set :keep_releases, 5

after "deploy:update_code", "deploy:migrate"
load "deploy/assets"

Upvotes: 0

Views: 1179

Answers (1)

mpapis
mpapis

Reputation: 53188

change top part of your deploy.rb to:

require "bundler/capistrano"
require "rvm/capistrano"

server "xxx.xx.xxx.xxx", :app, :web, :db, :primary => true

set :rvm_ruby_string, :local

before 'deploy:setup', 'rvm:install_rvm'   # install RVM
before 'deploy:setup', 'rvm:install_ruby'  # install Ruby and create gemset

#General settings

Upvotes: 2

Related Questions