Sundered Peak

through the mind of kyle tolle

Make All Gems Pristine After Upgrading Ruby

I upgraded to Ruby 2.3.0 today after using 2.2.3 for some time. Next, I ran a Ruby script I’d used many times before only to get a terminal full of output like this:

Ignoring iconv-1.0.4 because its extensions are not built.  Try: gem pristine iconv --version 1.0.4
Ignoring json-1.8.2 because its extensions are not built.  Try: gem pristine json --version 1.8.2
Ignoring nokogiri-1.6.6.2 because its extensions are not built.  Try: gem pristine nokogiri --version 1.6.6.2
Ignoring rdiscount-2.1.7.1 because its extensions are not built.  Try: gem pristine rdiscount --version 2.1.7.1
Ignoring redcarpet-3.2.2 because its extensions are not built.  Try: gem pristine redcarpet --version 3.2.2

Looks like gems with native extensions didn’t work after upgrading Ruby. Makes sense, but how could I reinstall all these gems without having to manually run all of those pristine commands? Fortunately, there’s a way to make all your gems pristine.

gem pristine --all

Beware that, if you have made changes to any gems locally, that this will clobber those changes. Thanks, StackExchange, for leading me to the answer.

I was happy to see the solution was easy, even if it did take a few minutes to process all the gems. I’m sure I’ll need to refer to this post again when I upgrade Ruby in the future.