开发者

How to handle deprecated gem warning (SourceIndex#all_gems)? [duplicate]

开发者 https://www.devze.com 2023-03-03 11:52 出处:网络
This question already has answers he开发者_JAVA百科re: Gem.source_index is deprecated, use Specification. Should I re-install Gem or Rails?
This question already has answers he开发者_JAVA百科re: Gem.source_index is deprecated, use Specification. Should I re-install Gem or Rails? (5 answers) Closed 9 years ago.

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


I got the same errors for a bunch of my gems in a non-Rails environment when I upgraded to rubygems 1.8.0. I got the warnings any time rubygems is required. Looking around the 'Net, it seems like it might be a problem also with rubygems 1.7.x, but I never had one of those versions installed so I'm not sure. I fixed this by running:

gem pristine --all --no-extensions

I had to run it a few times - it kept erroring out (but usually not in the same place from run to run). Eventually it got far enough that it had addressed the majority of my gems.

There were a few gems that didn't get their specifications regenerated correctly (json and sequel, specifically in my case) because they needed to build an extension. (The gem command output indicated it was skipping them, though it was easy to miss that message amidst all the deprecation warnings.) For those gems, I uninstalled them and then reinstalled them again (they'd previously been installed by bundler in rubygems 1.5.x) and that fixed the remaining warnings. It may be that I could have started with that plan of attack originally, but I didn't try.


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

sudo gem update bundler


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


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


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


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.


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.

0

精彩评论

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