简体   繁体   English

Capistrano:Bundler不使用rvm gemset

[英]Capistrano: Bundler doesn't use rvm gemset

I have a Ruby on Rails 3.2 app using bundler and capistrano for deployment. 我有一个Ruby on Rails 3.2应用程序,使用bundler和capistrano进行部署。 My server is a Debian Squeeze with rvm and ruby 1.9.2. 我的服务器是带有rvm和ruby 1.9.2的Debian Squeeze。 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' . 我读了capistrano(http://beginrescueend.com/integration/capistrano/)的rvm东西,你可以在其中设置gemset set :rvm_ruby_string, '1.9.2@my_gemset'

But during the deployment, bundler writes every gem to /var/www/my_app/shared/bundle . 但在部署期间,bundler会将每个gem写入/var/www/my_app/shared/bundle I thought if i define the rvm_ruby_string with the @ sign, bundler would use the gemset. 我想如果我用@符号定义rvm_ruby_string,bundler会使用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? 我可以在哪里更改--path /var/www/...以使用1.9.2@my_gemset gemset?

Maybe its, because I'm using several environments for deployment (staging, production...). 也许吧,因为我正在使用几个环境进行部署(登台,制作......)。 So here is my deploy.rb 所以这是我的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,  "gitosis@mydomain.org: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 在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. 也许有人可以帮助我。

capistrano-bundler 1.1.2 allows you to remove the --path flag from the bundler arguments and install gems to a specified gemset. capistrano-bundler 1.1.2允许您从bundler参数中删除--path标志 ,并将gem安装到指定的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'

You're both using bundler and rvm integration. 你们都在使用bundler和rvm集成。 Rvm will make sure it is using the right ruby (convenient for managing rubies), bundler will separate all gems into the shared/bundle directory. Rvm将确保它使用正确的ruby(便于管理rubies),bundler会将所有gem分成shared / bundle目录。 This is bundlers default setting for production. 这是生产的捆绑包默认设置。 I believe that this is a good way to set this up, also because it works with passenger out of the box, separates gems from each app, and has rvm handling the rubies. 我相信这是一个很好的方式来设置它,也因为它适用于开箱即用的乘客,从每个应用程序中分离宝石,并有rvm处理红宝石。

If you really want to use RVM for gem separation, you can best start at this blogpost by Darcy (this applies for passenger). 如果您真的想使用RVM进行宝石分离,最好从达西开始这篇博文 (这适用于乘客)。 As you can see, there is some effort involved in making that work, but it is possible. 正如您所看到的,在完成这项工作时需要付出一些努力,但这是可能的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM