开发者

GEM Version Requirements Deprecated

When creating a new Rails project using:

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:

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::Depen开发者_开发知识库dency#version_requirements is deprecated and will be removed on or after August 2010.

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. 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. 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. 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/

Its no big deal though. Just install gems the normal way and don't add any to your environment.rb file. 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.

You may want to consider upgrading to rails 3.0 and when you do, you will be using the Gemfile inside your application. in here, you will want to include the line:

gem 'authlogic'

and then on the command line, run

sudo bundle install

After that, all should be set :)


Check https://gist.github.com/807008 they suggest to downgrade and upgrade again rubygems.

Worked for me...


Putting these lines in your config/environment.rb between your bootstrap and your initializer will remove the deprecation warning:

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜