diff --git a/bundler/lib/bundler/dsl.rb b/bundler/lib/bundler/dsl.rb index cbe7b6bb8efd..1cc7908b8a88 100644 --- a/bundler/lib/bundler/dsl.rb +++ b/bundler/lib/bundler/dsl.rb @@ -63,7 +63,7 @@ def gemspec(opts = nil) development_group = opts[:development_group] || :development expanded_path = gemfile_root.join(path) - gemspecs = Dir[File.join(expanded_path, "{,*}.gemspec")].map {|g| Bundler.load_gemspec(g) }.compact + gemspecs = Gem::Util.glob_files_in_dir("{,*}.gemspec", expanded_path).map {|g| Bundler.load_gemspec(g) }.compact gemspecs.reject! {|s| s.name != name } if name Index.sort_specs(gemspecs) specs_by_name_and_version = gemspecs.group_by {|s| [s.name, s.version] } diff --git a/bundler/lib/bundler/source/path.rb b/bundler/lib/bundler/source/path.rb index 29e01e93ed2f..2c2e9023b3d4 100644 --- a/bundler/lib/bundler/source/path.rb +++ b/bundler/lib/bundler/source/path.rb @@ -171,7 +171,7 @@ def load_spec_files if File.directory?(expanded_path) # We sort depth-first since `<<` will override the earlier-found specs - Dir["#{expanded_path}/#{@glob}"].sort_by {|p| -p.split(File::SEPARATOR).size }.each do |file| + Gem::Util.glob_files_in_dir(@glob, expanded_path).sort_by {|p| -p.split(File::SEPARATOR).size }.each do |file| next unless spec = load_gemspec(file) spec.source = self diff --git a/bundler/spec/commands/install_spec.rb b/bundler/spec/commands/install_spec.rb index 0d17e7900eaf..d1b8585114b3 100644 --- a/bundler/spec/commands/install_spec.rb +++ b/bundler/spec/commands/install_spec.rb @@ -511,7 +511,7 @@ end describe "when Bundler root contains regex chars" do - it "doesn't blow up" do + it "doesn't blow up when using the `gem` DSL" do root_dir = tmp("foo[]bar") FileUtils.mkdir_p(root_dir) @@ -526,6 +526,22 @@ bundle :install, :dir => root_dir end + + it "doesn't blow up when using the `gemspec` DSL" do + root_dir = tmp("foo[]bar") + + FileUtils.mkdir_p(root_dir) + + build_lib "foo", :path => root_dir + gemfile = <<-G + gemspec + G + File.open("#{root_dir}/Gemfile", "w") do |file| + file.puts gemfile + end + + bundle :install, :dir => root_dir + end end describe "when requesting a quiet install via --quiet" do