Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get rid of Spring warning: Running `gem pristine --all`?

I'm using the Spring application preloader and just upgraded to v 0.9.0. Now I'm getting the following warning:

Warning: Running gem pristine --all to regenerate your installed gemspecs will improve the startup performance of Spring.

I tried running that command but it fails to install some of my gems, which may have to do with my recent upgrade to OS X Mavericks. How do I get rid of this warning?

like image 698
Peter Brown Avatar asked Nov 01 '13 11:11

Peter Brown


1 Answers

This was because previous versions of rubygems would load all the gemspecs whenever queried.

This is slow to begin with and gets slower the more gems are installed.

But with Rubygems 2.1 it has a "stubbed" gemspec that is very fast to load. See https://github.com/rubygems/rubygems/pull/435 for more info.

The spring people take advantage of this to not load every single gemspec when just loading bin/spring which uses just a small number to call out to the spring server.

The test it was doing (assuming you have RubyGems 2.1 or later) was essentially:

ruby -e 'p Gem::Specification.stubs.reject(&:stubbed?).reject(&:default_gem?).map(&:name)'

If that list was not empty, it knew that you had older gems; gems installed with RubyGems < 2.1.

You can use that information to generate a list of gems to run gem pristine on:

# /tmp/dirty.rb
require 'shellwords'


Gem::Specification.stubs.reject(&:stubbed?).reject(&:default_gem?).each do |gemspec|
  puts "gem pristine #{Shellwords.escape gemspec.name} --version #{Shellwords.escape gemspec.version.to_s}"
end

Then just run:

ruby /tmp/dirty.rb | bash

But it is easier to run gem pristine --all and as @Beerlington mentioned, gem uninstall any gems giving it a problem.

like image 112
docwhat Avatar answered Oct 13 '22 01:10

docwhat