嗨,我想我遗漏了一些基本的东西。
我使用Capistrano部署到"集成",然后部署到"测试"。
我似乎无法添加一个gem,然后用Capistrano成功部署到其中一个网站("测试")。然而,我可以成功地将其部署到另一个("集成")。
我正在尝试添加bootstrap sass'~>3.0.2',但当我尝试添加它们时,其他gem也会出现同样的错误。
当我试图用"cap-testing-deploy"部署到"testing"时,我得到一个错误,读取
whenever --update-crontab registration --set environment=testing --roles db"
servers: ["test.calm.dhamma.org"]
[test.calm.dhamma.org] executing command
*** [err :: test.calm.dhamma.org] /home/calm/.rvm/gems/ruby-1.9.3-p448/gems/bundler-1.3.5/lib/bundler/spec_set.rb:92:in `block in materialize'
*** [err :: test.calm.dhamma.org] :
*** [err :: test.calm.dhamma.org] Could not find bootstrap-sass-3.0.3.0 in any of the sources
*** [err :: test.calm.dhamma.org] (
*** [err :: test.calm.dhamma.org] Bundler::GemNotFound
*** [err :: test.calm.dhamma.org] )
*** [err :: test.calm.dhamma.org] from /home/calm/.rvm/gems/ruby-1.9.3-p448/gems/bundler-1.3.5/lib/bundler/spec_set.rb:85:in `map!'
*** [err :: test.calm.dhamma.org] from /home/calm/.rvm/gems/ruby-1.9.3-p448/gems/bundler-1.3.5/lib/bundler/spec_set.rb:85:in `materialize'
*** [err :: test.calm.dhamma.org] from /home/calm/.rvm/gems/ruby-1.9.3-p448/gems/bundler-1.3.5/lib/bundler/definition.rb:114:in `specs'
*** [err :: test.calm.dhamma.org] from /home/calm/.rvm/gems/ruby-1.9.3-p448/gems/bundler-1.3.5/lib/bundler/definition.rb:159:in `specs_for'
*** [err :: test.calm.dhamma.org] from /home/calm/.rvm/gems/ruby-1.9.3-p448/gems/bundler-1.3.5/lib/bundler/definition.rb:148:in `requested_specs'
etc..
我花了很长时间寻找答案,但没有成功。我确实有
require 'bundler/capistrano'
在我的Capfile.rb中,如下所示。
require "rvm/capistrano"
#set :rvm_type, :system # :user is the default
set :rvm_ruby_string, ENV['GEM_HOME'].gsub(/.*//,"") # Read from local system
puts "RVM ruby string = "
puts rvm_ruby_string
#set :rvm_ruby_string, :local
#
set :rvm_autolibs_flag, "read-only"
before 'deploy:setup', 'rvm:install_rvm'
before 'deploy:setup', 'rvm:install_ruby'
require 'bundler/capistrano'
require 'capistrano/ext/multistage'
set :stages, ["integration","testing", "production"]
set :default_stage, "integration"
# use whenever gem. Only if you have chron jobs
require "whenever/capistrano"
set :whenever_command, "bundle exec whenever"
set :application, "registration"
set :repository, "ssh://gitrepo@tools.calm.dhamma-eu.org/home/gitrepo/repositories/registration"
#set :repository, "ssh://gitrepo@94.23.144.59/home/gitrepo/repositories/registration"
set :scm, :git
# Or: `accurev`, `bzr`, `cvs`, `darcs`, `git`, `mercurial`, `perforce`, `subversion` or `none`
set :deploy_to, "/home/calm/wwwshare/registration"
set :user, "calm"
set :use_sudo, false
set :ssh_options, { :forward_agent => true }
#set :deploy_to, "/home/calm/wwwshare/#{application}"
set :deploy_via, :remote_cache
#before "deploy:bundle_gems","deploy:symlink_vendor"
#after "deploy", "deploy:bundle_gems"
#after "deploy:bundle_gems", "assets:symlink"
#after "assets:symlink", "deploy:copy_database_configuration"
#after "deploy:copy_database_configuration", "deploy:restart"
# http://beginrescueend.com/integration/capistrano/
#set :default_environment, {
# 'PATH' => "/home/calm/.rvm/gems/ruby-1.9.3-p448/bin:/home/calm/.rvm/gems/ruby-1.9.3-p448@global/bin:/home/calm/.rvm/bin:/home/calm/.rvm/rubies/ruby-1.9.3-p448/bin:$PATH",
# 'RUBY_VERSION' => 'ruby-1.9.3-p448',
# 'GEM_HOME' => '/home/calm/.rvm/gems/ruby-1.9.3-p448',
# 'GEM_PATH' => '/home/calm/.rvm/gems/ruby-1.9.3-p448:/home/calm/.rvm/gems/ruby-1.9.3-p448@global',
# 'BUNDLE_PATH' => '/home/calm/.rvm/gems/ruby-1.9.3-p448' # If you are using bundler.
#}
#task :testing do
# server 'THE-SERVER.mudbugmedia.com', :web, :app, :db, :primary => true
# set :deploy_to, '/home/calm/wwwshare/#{application}'
# set :rails_env, 'testing'
# set :branch, 'master'
#end
after 'deploy:setup', :create_configs
desc 'Create the shared/config dir for various config files'
task :create_configs do
run "mkdir -p #{shared_path}/config"
run "touch #{shared_path}/config/database.yml"
end
after 'deploy:finalize_update', :update_configs
desc 'Copy the shared config files to the release config dir'
task :update_configs do
run "cp -Rf #{shared_path}/config/* #{release_path}/config"
end
#after 'deploy:finalize_update', :bundle_gems
#desc "Install gems ??? or require 'bundler/capistrano'"
#task :bundle_gems do
# run "cd #{release_path} && bundle install --path vendor/gems"
#end
# If you are using Passenger
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
我尝试过直接在"测试"网站中安装gem,方法是编辑那里的Gemfile和Gemfile.lock,使其与我的开发和"集成"网站上的一致,并运行捆绑包安装。
然后当我"捆绑显示"时,我得到
bundle show bootstrap-sass
....../.rvm/gems/ruby-1.9.3-p448/gems/bootstrap-sass-3.0.2.1
然后:
bundle exec gem list
Could not find bootstrap-sass-3.0.2.1 in any of the sources
Run `bundle install` to install missing gems.
帽子测试部署仍然失败
在工作的网站上,gem安装如下:
bundle show bootstrap-sass
...../registration/shared/bundle/ruby/1.9.1/gems/bootstrap-sass-3.0.2.1
这与我在不工作的网站上手动安装它的地方不同。
所以,我的问题是:
为什么Capistrano没有在一个网站上添加新的宝石,但在另一个网站却成功了?
我应该直接在我尝试过的不起作用的网站上安装gem吗?如果这是个好主意,我该如何将其安装在正确的位置?
Ryan
现在让我的评论成为一个答案:
它现在正在工作——不同的ruby版本似乎存在问题。我在本地的测试中有1.9.7 p448,测试中有1.9.7 p484。我们只是将每台机器上的所有版本都设置为相同的版本,现在我可以使用Capistrano根据Gemfile的更改来更新gem。