summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel DeLeo <dan@opscode.com>2011-03-22 16:49:59 -0700
committerDaniel DeLeo <dan@opscode.com>2011-03-22 16:49:59 -0700
commit98c10267b98673e46fa658b1fcde0885c8a64aa2 (patch)
treed114d0e198b1f3ab2d5e0db19ea21b3ac32a9b99
parente4463d5c703141f87cbc329d410d446ed420e7ae (diff)
parent865173d0b68f6cd82a9a677ee4e158a79a66148a (diff)
downloadchef-98c10267b98673e46fa658b1fcde0885c8a64aa2.tar.gz
Merge branch 'CHEF-2124'
-rw-r--r--chef/lib/chef/knife.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/chef/lib/chef/knife.rb b/chef/lib/chef/knife.rb
index 768a1343ad..d1539e3b24 100644
--- a/chef/lib/chef/knife.rb
+++ b/chef/lib/chef/knife.rb
@@ -28,6 +28,9 @@ class Chef
include Mixlib::CLI
extend Chef::Mixin::ConvertToClassName
+ CHEF_FILE_IN_GEM = /chef-[\d]+\.[\d]+\.[\d]+/
+ CURRENT_CHEF_GEM = /chef-#{Regexp.escape(Chef::VERSION)}/
+
attr_accessor :name_args
def self.msg(msg="")
@@ -225,6 +228,12 @@ class Chef
# search all gems for chef/knife/*.rb
require 'rubygems'
files = Gem.find_files 'chef/knife/*.rb'
+ # wow, this is a sad hack :(
+ # Gem.find_files finds files in all versions of a gem, which
+ # means that if chef 0.10 and 0.9.x are installed, we'll try to
+ # require, e.g., chef/knife/ec2_server_create, which will cause
+ # a gem activation error. So remove files from older chef gems.
+ files.reject! {|f| f =~ CHEF_FILE_IN_GEM && f !~ CURRENT_CHEF_GEM }
files.map! do |file|
file[/(#{Regexp.escape File.join('chef', 'knife', '')}.*\.rb)/, 1]
end.uniq!