Capistrano自定义任务失败,因为“ Rails要求RubyGems> = 1.3.2” [英] Capistrano custom task fails because "Rails requires RubyGems >= 1.3.2"

查看:62
本文介绍了Capistrano自定义任务失败,因为“ Rails要求RubyGems> = 1.3.2”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的自定义capistrano任务 app:sample失败,并显示以下错误消息:

My custom capistrano task "app:sample" fails with the following error message:

mnylen ilmo-on-rails $ cap app:sample
* executing `app:sample'
* executing "export RAILS_ENV=production; cd /home/mnylen/ilmo-on-rails/current; ruby script/coursegen 10"
servers: ["rails.cs.helsinki.fi"]
* establishing connection to gateway `melkinpaasi.cs.helsinki.fi'
* Creating gateway using melkinpaasi.cs.helsinki.fi
* establishing connection to `rails.cs.helsinki.fi' via gateway
Password: 
[rails.cs.helsinki.fi] executing command
*** [err :: rails.cs.helsinki.fi] Rails requires RubyGems >= 1.3.2. Please install RubyGems and try again: http://rubygems.rubyforge.org
command finished
failed: "sh -c 'export RAILS_ENV=production; cd /home/mnylen/ilmo-on-rails/current; ruby script/coursegen 10'" on rails.cs.helsinki.fi

我错过了一些东西还是做错了什么?任务是:

Am I missing something or doing something wrong? The task is:

namespace :app do
  desc "Run sample data on production2
  task :sample do
    run "export RAILS_ENV=production; cd #{current_path}; ruby script/coursegen 10"
  end
end

如果我运行相同

推荐答案

好,解决了。

问题是生产服务器上安装了两个Ruby。

The problem was that there was two Ruby installations on the production server.

我的主目录下的 .profile 文件生产服务器将 PATH 环境变量设置为指向正确的Ruby版本。

The .profile file under my home directory on the production server set the PATH environment variable to point to the correct Ruby version.

run 命令,不会提供 .profile 文件,因此,在任务中运行 ruby​​脚本/ coursegen 10 使用了错误的Ruby版本,这是产生有关以下内容的奇怪错误消息的原因

run command, it seems, doesn't source the .profile file and thus, running ruby script/coursegen 10 in the task used the wrong Ruby version, which was the reason for the weird error message about RubyGems version. This also explains why it worked when manually running the command from production servers shell.

我的解决方案是在运行任务中使用Ruby可执行文件的完整路径,像这样:

My solution was to use full path to the Ruby executable in my run task, like this:

run "export RAILS_ENV=production; cd #{current_path}; /opt/ruby-enterprise-1.8.7-2009.10/bin/ruby script/coursegen 10"

当然,这不是很漂亮,但是可以用,如果有人有更漂亮的解决方案,我会很乐意使用这些解决方案。:)

Of course, this isn't pretty, but it works. If anyone has any prettier solutions, I'd be more than glad to use those instead. :)

这篇关于Capistrano自定义任务失败,因为“ Rails要求RubyGems> = 1.3.2”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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