安装 gems 会在安装之前尝试在我的自定义 rake 任务中加载 gem

发布于 2024-09-06 04:52:09 字数 1178 浏览 2 评论 0原文

我正在使用 Rails 2.3.5 开发一个应用程序,gitorious 并使用 vlad 进行部署,操作系统是 Linux Mint 9 Isadora。
vlad:setup 和 vlad:update 都可以。 但是当我 vlad:migrate 并遇到与在服务器上 ssh 并尝试 rake gems:install 相同的错误时

耙子中止!
没有要加载的文件 -- ya2yaml
/var/www/path/to/releases/20100622030150/Rakefile:10 (通过使用 --trace 运行任务查看完整跟踪)

我的 config/environment.rb 很好:

RAILS_GEM_VERSION = '2.3.5' unless defined? RAILS_GEM_VERSION  
# Bootstrap the Rails environment, frameworks, and default configuration  
require File.join(File.dirname(__FILE__), 'boot')  
Rails::Initializer.run do |config|  
  config.gem "haml"

我在 lib/tasks/db_fixtures.rake 中有一个自定义任务,需要ya2yaml

namespace :export do
desc 'Create YAML test fixtures from data in an existing database.
Defaults to development database.  Set RAILS_ENV to override.'
require 'rubygems'
require 'ya2yaml'
task :fixtures => [:environment] do

当我重命名此文件时,rake 不会加载它,并且当我 rake gems:install 时不再出现错误,

所以我的猜测是它看起来像rake gems:install 出于某种原因尝试在安装 gems 之前在我的自定义任务中加载库,并抛出错误。

解决方案是什么?
谢谢,

I'm developing an application using rails 2.3.5, gitorious and deploy with vlad, the OS is Linux Mint 9 Isadora.
vlad:setup and vlad:update are ok.
But when I vlad:migrate and have the same error than if I ssh on the server and try a rake gems:install

rake aborted!
no such file to load -- ya2yaml
/var/www/path/to/releases/20100622030150/Rakefile:10
(See full trace by running task with --trace)

My config/environment.rb is good:

RAILS_GEM_VERSION = '2.3.5' unless defined? RAILS_GEM_VERSION  
# Bootstrap the Rails environment, frameworks, and default configuration  
require File.join(File.dirname(__FILE__), 'boot')  
Rails::Initializer.run do |config|  
  config.gem "haml"

I have a custom task in lib/tasks/db_fixtures.rake that requires ya2yaml:

namespace :export do
desc 'Create YAML test fixtures from data in an existing database.
Defaults to development database.  Set RAILS_ENV to override.'
require 'rubygems'
require 'ya2yaml'
task :fixtures => [:environment] do

When I rename this file it is not loaded by rake and I don't have the error anymore when I rake gems:install

So my guess is that it looks like rake gems:install tries to load the libs in my custom tasks before installing the gems for some reason and throw me an error.

What would be a solution?
Thanks,

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

九厘米的零° 2024-09-13 04:52:09

这可能有用吗? 从而延迟 rake 任务上的需求

task :fixtures => [:environment] do
    require 'rubygems'
    require 'ya2yaml'
    # ...

默认情况下,运行 rake 任务会“加载”所有 rake 文件,

this might work? delay the requires on your rake task by moving them into the task itself

task :fixtures => [:environment] do
    require 'rubygems'
    require 'ya2yaml'
    # ...

by default running rake tasks 'loads' all of the rake files

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文