Skip to content

Instantly share code, notes, and snippets.

@acdimalev
Created August 4, 2011 10:51
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save acdimalev/1124953 to your computer and use it in GitHub Desktop.
Save acdimalev/1124953 to your computer and use it in GitHub Desktop.
Check for uninstalled gem dependencies.
#!/usr/bin/ruby
require 'rubygems'
installed_gems = Gem::Dependency.new '', Gem::Requirement.default
missing = []
# mind the short-hand, looping over installed gem specs
specs = Gem.source_index.search installed_gems
specs.each do |spec|
gem = Gem::Dependency.new spec.name, spec.version
# looping over gem dependencies
specs = Gem.source_index.search gem
deps = specs.first.runtime_dependencies
deps.each do |dep|
# check if the dependency is missing
specs = Gem.source_index.search dep
if specs === [] then
missing.push dep
end
end
end
print missing.sort.uniq.collect{|spec| "#{spec}\n"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment