这是我对 Rails 的 forst 部署试验。
我设法在服务器端设置了所有依赖项
当我输入
bundle exec rails console
一切正常。我在本地运行 cap deploy:migrations 时遇到了这个奇怪的问题
[.com] sh -c 'cd /home//.com/releases/20120411120423 && bundle install --gemfile /home//.com/releases/20120411120423/Gemfile --path /home//.com/shared/bundle --deployment --quiet --without development test'
** [out ::.com] /usr/lib/ruby/1.8/rubygems.rb:779:in `report_activate_error': Could not find RubyGem bundler (>= 0) (Gem::LoadError
** [out ::.com] )
** [out ::.com] from /usr/lib/ruby/1.8/rubygems.rb:214:in `activate'
** [out ::.com] from /usr/lib/ruby/1.8/rubygems.rb:1082:in `gem'
** [out ::.com] from /home//.gems/bin/bundle:18
command finished in 539ms
当我手动复制命令并在服务器中执行它时,它可以完美运行!
这是我的 deploy.rb 文件
require "bundler/capistrano"
default_run_options[:pty] = true
set :user, 'xyz'
set :domain, 'xyz.com'
set :application, 'xyz'
set :repository, "#{user}@#{domain}:git/#{application}.git"
set :deploy_to, "/home/#{user}/#{domain}"
set :deploy_via, :remote_cache
set :scm, 'git'
set :branch, 'master'
set :git_shallow_clone, 1
set :scm_verbose, true
set :use_sudo, false
set :rake, "/home//.gems/bin/rake"
server domain, :app, :web
role :db, domain, :primary => true
namespace :deploy do
task :restart do
run "touch #{current_path}/tmp/restart.txt"
end
end
更新:
当我从 cap 启动 bundle -v 时,我得到了正确的位置!
$ cap invoke COMMAND="which bundle"
输出
/home//.gems/bin/bundle