无法通过上限找到RubyGem捆绑包

时间:2012-04-11 12:14:02

标签: ruby-on-rails capistrano

这是我对rails的最新部署试用版。

我设法在服务器端设置所有依赖项

当我输入

bundle exec rails console
一切正常。当我运行cap deploy时,我遇到了这个奇怪的问题:本地迁移

[.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

更新

当我从上限启动捆绑-v时,我得到了正确的位置!

$ cap invoke COMMAND="which bundle"

输出

 /home//.gems/bin/bundle

1 个答案:

答案 0 :(得分:0)

将这些行添加到config.ru文件解决了问题

ENV['GEM_HOME'] = '/home/aaalsubaie/.gems/'
ENV['GEM_PATH'] = '/usr/lib/ruby/gems/1.8'

require 'rubygems'
Gem.clear_paths