Rails 3 -- Bundler/Capistrano 错误 [英] Rails 3 -- Bundler/Capistrano Errors

查看:36
本文介绍了Rails 3 -- Bundler/Capistrano 错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have a basic Rails 3 app working locally on my development box, but want to test out deploying early on to make sure everything works. I'm using Capistrano to deploy.

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

When I run cap deploy (after all the other necessary setup), it breaks on this command with this error:

[...]
* 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命令.

So it looks like it can't find the bundle command on the server.

但是,当我登录服务器时...

However, when I log in to the server...

$ 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 命令工作正常.

...the bundle command works just fine.

可能出了什么问题?

-

(此外,为了完整性:)

(Furthermore, for completeness:)

$ 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,以下答案仍然适用.

For RVM >= 1.11.3, you should now just use the rvm-capistrano gem. For older RVM >= 1.0.1, the answer below still applies.

原始答案:

好吧,虽然我仍然还没有得到一个完整的cap deploy来工作,但我确实解决了这个问题.问题在于 Capistrano 试图为 Bundler(和其他 gem)使用与 RVM 路径不同的路径.

Okay, though I still haven't gotten a full cap deploy to work, I did fix this problem. The problem was Capistrano trying to use a different path for Bundler (and other gems) than the RVM paths.

通过执行 cap shell,然后 echo $PATH 检查您的 Capistrano 路径.您可能会看到标准的 /usr/local/bin/usr/bin,但这不是 RVM 存储 Bundler 等的地方.

Check your Capistrano path by doing cap shell, then echo $PATH. You'll probably see your standard /usr/local/bin and /usr/bin, but that's not where RVM has Bundler, et al., stored.

编辑您的 Capistrano config/deploy.rb 文件,并根据 添加以下行这些说明:

Edit your Capistrano config/deploy.rb file, and add the following lines, per 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.

That finally got Capistrano to see Bundler and start loading gems appropriately.

这篇关于Rails 3 -- Bundler/Capistrano 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆