How to handle deprecated gem warning (SourceIndex#

2019-04-04 06:18发布

Got this message today after running bundle update:

$ bundle update
NOTE: Gem::SourceIndex#all_gems is deprecated with no replacement. It will be removed on or after 2011-10-01.
Gem::SourceIndex#all_gems called from /Users/meltemi/.rvm/gems/ruby-1.9.2-p180@ppr3/gems/bundler-1.0.13/lib/bundler/rubygems_integration.rb:256
.

Anyone know what it means and how to address it?

Note: This is a Rails 3.0.7 environment

7条回答
姐就是有狂的资本
2楼-- · 2019-04-04 06:28

It was called from the Bundler gem. Try updating bundler to see if it helps

sudo gem update bundler
查看更多
Rolldiameter
3楼-- · 2019-04-04 06:30

I updated bundler ('gem update bundler') from 1.0.12 to 1.0.15. Now all is well.

查看更多
乱世女痞
4楼-- · 2019-04-04 06:31

Bundler 1.0.13 (version released May 4, 2011) running with rubygems 1.7.2 issues this annoying deprecation warning:

NOTE: Gem::SourceIndex#all_gems is deprecated with no replacement. It will be removed on or after 2011-10-01. Gem::SourceIndex#all_gems called from /Users/me/.rvm/gems/ruby-1.9.2-p180@composer/gems/bundler-1.0.13/lib/bundler/rubygems_integration.rb:256

A fix was committed on 5/11/2011 in the Bundler repo to correct an issue submitted 5/6/2011.

Pending release of Bundler 1.1, you can try this solution:

$ gem uninstall bundler

$ gem install bundler --version=1.0.12

I hope this helps. Took some digging to find it.

查看更多
走好不送
5楼-- · 2019-04-04 06:32

The Pry gem uses the rubygems API directly and can't be fixed by just running gem pristine --all unfortunately.

I forked the Pry gem and added fixes using non-deprecated API calls. Pending a merge to master, here is the fork: https://github.com/dvdplm/pry

查看更多
爱情/是我丢掉的垃圾
6楼-- · 2019-04-04 06:35

I deleted and reinstalled ruby 1.9.2 via RVM and then uninstalled all gems:

gem list --no-versions

Put the result in a file called gems (cut out the error messages). Then do:

GEMS=`cat gems`
for x in $GEMS ; do gem uninstall $x -aIx; done

After that I was able to run the pristine command suggested by others:

gem pristine --all --no-extensions

That's when the errors disappeared.

查看更多
对你真心纯属浪费
7楼-- · 2019-04-04 06:44

Qoute:

As far as I see from the sources:
Simply patch rubygems_integration.rb, line 256:
- Gem.source_index.all_gems.values
+ Gem.source_index.gems.values
Reason:
Gem::SourceIndex#all_gems was just returning @gems, and now there is an attr_reader for @gems. I think that was the reason to remove the all_gems method.

Source: ruby-forum.com

查看更多
登录 后发表回答