我在开发箱上本地有一个基本的Rails 3应用程序,但是想要尽早测试部署以确保一切正常。我正在使用Capistrano进行部署。

当我运行cap deploy(在所有其他必要的设置之后)时,它在此命令上中断,并显示以下错误:

[...]
* executing 'bundle:install'
* executing "bundle install --gemfile /var/www/trex/releases/20100917172521/Gemfile --path /var/www/trex/shared/bundle --deployment --quiet --without development test"

servers: ["www.[my domain].com"]
[www.[my domain].com] executing command
** [out :: www.[my domain].com] sh: bundle: command not found
command finished
[...]

因此,看起来在服务器上找不到bundle命令。

但是,当我登录到服务器时...
$ ruby -v
ruby 1.9.2p0 (2010-08-18 revision 29036) [x86_64-linux]
$ rails -v
Rails 3.0.0
$ bundle -v
Bundler version 1.0.0

... bundle命令可以正常工作。

可能出什么问题了?

--

(此外,出于完整性考虑:)
$ which ruby
~/.rvm/rubies/ruby-1.9.2-p0/bin/ruby
$ which rails
~/.rvm/gems/ruby-1.9.2-p0/bin/rails
$ which bundle
~/.rvm/gems/ruby-1.9.2-p0/bin/bundle

最佳答案

更新:

对于RVM> = 1.11.3,您现在应该只使用rvm-capistrano gem。对于较旧的RVM> = 1.0.1,以下答案仍然适用。

原始答案:

好的,尽管我仍然没有完整的cap deploy可以工作,但是我确实解决了这个问题。问题是Capistrano尝试为Bundler(和其他gems)使用与RVM路径不同的路径。

依次执行cap shellecho $PATH,检查您的Capistrano路径。您可能会看到标准的/usr/local/bin/usr/bin,但这不是RVM存储Bundler等的地方。

编辑您的Capistrano config/deploy.rb文件,并为these instructions添加以下行:

# Add RVM's lib directory to the load path.
$:.unshift(File.expand_path('./lib', ENV['rvm_path']))

# Load RVM's capistrano plugin.
require "rvm/capistrano"

set :rvm_ruby_string, '1.9.2'
set :rvm_type, :user  # Don't use system-wide RVM

最终,Capistrano看到了Bundler并开始适当地装载 gem 。

08-26 08:39
查看更多