diff options
author | danielsdeleo <dan@opscode.com> | 2013-06-13 11:27:52 -0700 |
---|---|---|
committer | danielsdeleo <dan@opscode.com> | 2013-06-13 11:27:52 -0700 |
commit | aac76577b7a08b32c26222c946257644ee32809c (patch) | |
tree | 920c7d85316297da0539d68fccb5f17cc83e6d12 | |
parent | 35da53b9dd889045ecea1b48e70a1dcb5ababc9e (diff) | |
download | chef-aac76577b7a08b32c26222c946257644ee32809c.tar.gz |
Fix rubygems > 2.0 heuristic test
In some cases, upgrading to rubygems 2.0 from 1.8 can leave both
installations available in the load path. The 2.0 install is ahead of
the 1.8 install, but it is possible to load a file from the 1.8 install
if that file does not exist in rubygems 2.0. In particular,
rubygems/format does not exist in 2.0, so `require "rubygems/format"`
loads from rubygems 1.8.
When Chef "accidentally" loads the old rubygems/format, it defeats the
version detection heuristic (check if Gem::Format) is defined, which
eventually causes an error calling Gem::Package.open. Adding a check to
see if Gem::Package defines open resolves this problem.
-rw-r--r-- | lib/chef/provider/package/rubygems.rb | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/chef/provider/package/rubygems.rb b/lib/chef/provider/package/rubygems.rb index c694b215fe..28d332420b 100644 --- a/lib/chef/provider/package/rubygems.rb +++ b/lib/chef/provider/package/rubygems.rb @@ -121,7 +121,7 @@ class Chef # Compatibility note: Rubygems 1.x uses Gem::Format, 2.0 moved this # code into Gem::Package. def spec_from_file(file) - if defined?(Gem::Format) + if defined?(Gem::Format) and Gem::Package.respond_to?(:open) Gem::Format.from_file_by_path(file).spec else Gem::Package.new(file).spec |