Instantly share code, notes, and snippets.

What would you like to do?
#!/usr/bin/env ruby
puts "looking for the gems to upgrade..."
gem_info =, :version)
to_reinstall = []
Dir.glob('/Library/Ruby/Gems/**/*.bundle').map do |path|
path =~ /.*1.8\/gems\/(.*)-(.*?)\/.*/
name, version = $1, $2
bundle_info = `file path`
to_reinstall <<, version) unless bundle_info =~ /bundle x86_64/
gemnames ={|ginfo|}.uniq.delete_if{|name| name =~ /mysql|passenger/}
puts "***"
puts "Please reinstall:"
gemnames.each do |name|
gems ={|ginfo| == name}
puts "#{name} versions: #{{|ginfo| ginfo.version}.join(', ')}"
puts "or uninstall all gems that need to be reinstalled:\n"
puts "$ sudo gem uninstall #{gemnames.join(' ')}"
puts " "
puts "and reinstall them:\n"
puts "$ sudo gem install #{gemnames.join(' ')}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment