我在我的开发机器上有一个基本的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
...the 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
发布于 2011-08-12 19:20:10
找不到捆绑包,因为没有加载.bash_profile,因此您的路径是错误的。这可能是因为您在.bash_profile中有RVM脚本。
简单的答案是将RVM脚本从.bash_profile移动到.bashrc,Capistrano应该能够找到它(还要验证.bash_profile源.bashrc)。
Capistrano使用SSH通过non-interactive shell在服务器上执行命令。此shell会话将执行source .bashrc but not .bash_profile。我向两者添加了一个ECHO语句,并通过SSH运行LS。您可以在下面的结果中看到,只有.bashrc是源的:
$ ssh user@123.amazonaws.com ls
.bashrc loaded
git
file1
file2
发布于 2012-02-16 07:31:33
我在使用rbenv时也遇到了同样的问题。解决方案是从我的.bashrc文件底部提取特定于rbenv的行,并将它们放在顶部。如果shell没有在交互模式下运行,那么我的.bashrc文件的第一行将返回aborting。
发布于 2010-11-24 23:46:27
最后一行实际上应该是
set :rvm_type, :user
也就是说,user必须是一个符号,而不是一个变量,否则将得到
undefined local variable or method `user'
https://stackoverflow.com/questions/3737678
复制相似问题