安装 gems 会在安装之前尝试在我的自定义 rake 任务中加载 gem
我正在使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这可能有用吗? 从而延迟 rake 任务上的需求
默认情况下,运行 rake 任务会“加载”所有 rake 文件,
this might work? delay the requires on your rake task by moving them into the task itself
by default running rake tasks 'loads' all of the rake files