简体   繁体   English

GEM版本要求已弃用

[英]GEM Version Requirements Deprecated

When creating a new Rails project using: 使用以下方法创建新的Rails项目时:

rails sample

Then creating a model using: 然后使用以下方法创建模型

script/generate model person first_name:string last_name:string

Everything is fine. 一切都好。 However, if I add any gems to my environment.rb: 但是,如果我将任何宝石添加到我的environment.rb:

config.gem "authlogic"

And run the same generator, I get the following: 并运行相同的生成器,我得到以下内容:

/Library/Ruby/Gems/1.8/gems/rails-2.3.5/lib/rails/gem_dependency.rb:119:Warning: Gem::Dependency#version_requirements is deprecated and will be removed on or after August 2010. /Library/Ruby/Gems/1.8/gems/rails-2.3.5/lib/rails/gem_dependency.rb:119:Warning:Gem :: Dependency#version_requirements已弃用,将于2010年8月或之后删除。

The warning just recently appeared (I think), but I would like to fix it if possible. 刚刚出现的警告(我认为),但我想尽可能修复它。 Any hints or similar experiences? 任何提示或类似的经历?

Thanks. 谢谢。

did you try: 你试过了吗:

rake gems:install 耙宝石:安装

Btw. 顺便说一句。 If you are using rubygems 1.3.6 then you get this deprecation warning. 如果您使用的是rubygems 1.3.6,则会收到此弃用警告。 Previous versions never gave a warning. 以前的版本从未发出警告。 Also i suggest installing any gem using the command line rather than adding it in the environment.rb file. 另外,我建议使用命令行安装任何gem,而不是在environment.rb文件中添加它。 If the gem(s) you have added in the file is/are not installed, then the generator or any rake task will simply not run. 如果未安装在文件中添加的gem,则生成器或任何rake任务将无法运行。 Its a minor bug. 这是一个小错误。

Here is an article that describes a way to prevent the warning: http://www.mattvsworld.com/blog/2010/03/version_requirements-deprecated-warning-in-rails/ 这篇文章描述了一种防止警告的方法: http//www.mattvsworld.com/blog/2010/03/version_requirements-deprecated-warning-in-rails/

Its no big deal though. 虽然没什么大不了的。 Just install gems the normal way and don't add any to your environment.rb file. 只需以正常方式安装gem,不要向environment.rb文件添加任何内容。 You'll never get the deprecation warning. 你永远不会得到弃用警告。

This may be irrelevant as it is rails 3.0 but the answer you are looking for is in this article: http://omgbloglol.com/post/353978923/the-path-to-rails-3-approaching-the-upgrade down by the section titled "config.gem is dead, long live bundler", although the article does explain some new things. 这可能是无关紧要的,因为它是rails 3.0,但您正在寻找的答案在本文中: http//omgbloglol.com/post/353978923/the-path-to-rails-3-approaching-the-upgrade down by标题为“config.gem is dead,long live bundler”的部分虽然文章确实解释了一些新的东西。

You may want to consider upgrading to rails 3.0 and when you do, you will be using the Gemfile inside your application. 您可能需要考虑升级到rails 3.0,当您这样做时,您将在应用程序中使用Gemfile。 in here, you will want to include the line: 在这里,您将要包含以下行:

gem 'authlogic' 宝石'authlogic'

and then on the command line, run 然后在命令行上运行

sudo bundle install sudo bundle install

After that, all should be set :) 之后,所有应该设置:)

Check https://gist.github.com/807008 they suggest to downgrade and upgrade again rubygems. 检查https://gist.github.com/807008他们建议降级并再次升级rubygems。

Worked for me... 为我工作......

Putting these lines in your config/environment.rb between your bootstrap and your initializer will remove the deprecation warning: 将这些行放在bootstrap和初始化程序之间的config / environment.rb中将删除弃用警告:

if Gem::VERSION >= "1.3.6"
  module Rails
    class GemDependency
      def requirement
        super == Gem::Requirement.default ? nil : super
      end
    end
  end
end

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM