Ruby – Check for Ruby Gem availability


Is there a way to check if some gem is currently installed, via the Gem module? From ruby code, not by executing 'gem list'…

To clarify – I don't want to load the library. I just want to check if it's available, so all the rescue LoadError solutions don't help me. Also I don't care if the gem itself will work or not, only whether it's installed.

Best Solution

In Ruby 1.9.3 only there is also:


You can use regex expressions too. Handy if I want to allow 'rcov' and GitHub variants like 'relevance-rcov':