Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Capistrano: Bundler doesn't use rvm gemset

I have a Ruby on Rails 3.2 app using bundler and capistrano for deployment. My server is a Debian Squeeze with rvm and ruby 1.9.2. I read the rvm stuff for capistrano (http://beginrescueend.com/integration/capistrano/) where you can set the gemset by set :rvm_ruby_string, '1.9.2@my_gemset'.

But during the deployment, bundler writes every gem to /var/www/my_app/shared/bundle. I thought if i define the rvm_ruby_string with the @ sign, bundler would use the gemset.

The output from the deployment says

  * executing "cd /var/www/my_app/releases/20120216145728 && bundle install --gemfile /var/www/my_app/releases/20120216145728/Gemfile --path /var/www/my_app/shared/bundle --deployment --quiet --without development test"

Where I can change the --path /var/www/... to use the 1.9.2@my_gemset gemset from rvm?

Maybe its, because I'm using several environments for deployment (staging, production...). So here is my deploy.rb

# RVM bootstrap
$:.unshift(File.expand_path('./lib', ENV['rvm_path']))
require 'capistrano/ext/multistage'
require 'bundler/capistrano'
require 'rvm/capistrano'

set :rvm_bin_path, "/usr/local/rvm/bin"
set :rvm_type, :system

set :stages, %w(production staging)
set :default_stage, "staging"

set :application, "my_app"
set :repository,  "[email protected]:my_app.git"

set :scm, :git

set :user, "my_deploy_user"

set :use_sudo, false

set :ssh_options, { :forward_agent => true }

default_run_options[:pty] = true

namespace :deploy do
  task :start do
  end
  task :stop do
  end
  task :restart, :roles => :app, :except => { :no_release => true } do
    run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"
  end
end

And in config/deploy/staging.rb

set :rails_env, "staging"
set :rvm_ruby_string, '1.9.2@my_gemset'
set :deploy_to, "/var/www/my_app"

role :web, "stage.mydomain.de"                          # Your HTTP server, Apache/etc
role :app, "stage.mydomain.de"                          # This may be the same as your `Web` server
role :db,  "stage.mydomain.de", :primary => true # This is where Rails migrations will run

Maybe someone can help me.

like image 515
23tux Avatar asked Dec 17 '22 03:12

23tux


1 Answers

capistrano-bundler 1.1.2 allows you to remove the --path flag from the bundler arguments and install gems to a specified gemset.

There is what my config looks like in the end:

set :rvm_type, :system
set :rvm_ruby_version, "2.0.0-p353@#{fetch(:application)}"

set :bundle_path, nil
set :bundle_binstubs, nil
set :bundle_flags, '--system'
like image 63
Dwayne Forde Avatar answered Dec 30 '22 02:12

Dwayne Forde