Try to activate a gem containing
path. Returns true if
activation succeeded or wasn’t needed because it was already activated.
Returns false if it can’t find the path in a gem.
# File lib/rubygems.rb, line 197
def self.try_activate path
# TODO: deprecate when 1.9.3 comes out.
# finds the _latest_ version... regardless of loaded specs and their deps
# TODO: use find_all and bork if ambiguous
spec = Gem::Specification.find_by_path path
return false unless spec
begin
spec.activate
rescue Gem::LoadError # this could fail due to gem dep collisions, go lax
Gem::Specification.find_by_name(spec.name).activate
end
return true
end