diff options
-rw-r--r-- | lib/bundler/source/rubygems.rb | 10 | ||||
-rw-r--r-- | spec/install/gems/simple_case_spec.rb | 16 |
2 files changed, 25 insertions, 1 deletions
diff --git a/lib/bundler/source/rubygems.rb b/lib/bundler/source/rubygems.rb index 3a285ae0ff..8333a48ac0 100644 --- a/lib/bundler/source/rubygems.rb +++ b/lib/bundler/source/rubygems.rb @@ -68,7 +68,7 @@ module Bundler end def install(spec) - return ["Using #{version_message(spec)}", nil] if installed_specs[spec].any? + return ["Using #{version_message(spec)}", nil] if installed_specs[spec].any? && gem_dir_exists?(spec) # Download the gem to get the spec, because some specs that are returned # by rubygems.org are broken and wrong. @@ -273,6 +273,14 @@ module Bundler Bundler.rubygems.sources = old end end + + def gem_dir_exists?(spec) + if spec.name == "bundler" + true + else + File.directory?(spec.full_gem_path) + end + end end end diff --git a/spec/install/gems/simple_case_spec.rb b/spec/install/gems/simple_case_spec.rb index 250681f48b..20a9ffdd13 100644 --- a/spec/install/gems/simple_case_spec.rb +++ b/spec/install/gems/simple_case_spec.rb @@ -337,6 +337,22 @@ describe "bundle install with gem sources" do G expect(exitstatus).to eq(0) end + + it "reinstalls the gem if the gem dir is missing but the specification file exists" do + gemfile(<<-G) + source "file://#{gem_repo1}" + + gem 'foo' + G + + bundle "install --path vendor/bundle" + + FileUtils.rm_rf(vendored_gems('gems/foo-1.0')) + + bundle "install" + + expect(vendored_gems('gems/foo-1.0')).to exist + end end describe "when Bundler root contains regex chars" do |