summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Giddins <segiddins@segiddins.me>2017-06-22 11:48:51 -0500
committerSamuel Giddins <segiddins@segiddins.me>2017-06-22 11:49:00 -0500
commit194706060e50d27269cbdce930310fa8a8f05b80 (patch)
tree1c401ad0577ef992209def578dbfc502e74f969c
parent212ad80f85766624888272ceb5f2adecf673beb9 (diff)
downloadbundler-seg-dont-hit-remote-twice.tar.gz
[Definition] Allow installing in deployment mode when an unused path source is missingseg-dont-hit-remote-twice
-rw-r--r--lib/bundler/definition.rb17
-rw-r--r--spec/install/deploy_spec.rb29
2 files changed, 45 insertions, 1 deletions
diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb
index 51179c61d3..e0b983730c 100644
--- a/lib/bundler/definition.rb
+++ b/lib/bundler/definition.rb
@@ -593,6 +593,9 @@ module Bundler
# order here matters, since Index#== is checking source.specs.include?(locked_index)
locked_index != source.specs
+ rescue PathError, GitError => e
+ Bundler.ui.debug "Assuming that #{source} has not changed since fetching its specs errored (#{e})"
+ false
end
# Get all locals and override their matching sources.
@@ -770,7 +773,19 @@ module Bundler
# Path sources have special logic
if s.source.instance_of?(Source::Path) || s.source.instance_of?(Source::Gemspec)
- other = s.source.specs[s].first
+ other_sources_specs = begin
+ s.source.specs
+ rescue PathError, GitError
+ # if we won't need the source (according to the lockfile),
+ # don't error if the path/git source isn't available
+ next if @locked_specs.
+ for(requested_dependencies, [], false, true, false).
+ none? {|locked_spec| locked_spec.source == s.source }
+
+ raise
+ end
+
+ other = other_sources_specs[s].first
# If the spec is no longer in the path source, unlock it. This
# commonly happens if the version changed in the gemspec
diff --git a/spec/install/deploy_spec.rb b/spec/install/deploy_spec.rb
index c6747764b1..032ff01b66 100644
--- a/spec/install/deploy_spec.rb
+++ b/spec/install/deploy_spec.rb
@@ -135,6 +135,35 @@ RSpec.describe "install with --deployment or --frozen" do
expect(out).not_to include("You have changed in the Gemfile")
end
+ it "works if a path gem is missing but is in a without group" do
+ build_lib "path_gem"
+ install_gemfile! <<-G
+ source "file://#{gem_repo1}"
+ gem "rake"
+ gem "path_gem", :path => "#{lib_path("path_gem-1.0")}", :group => :development
+ G
+ expect(the_bundle).to include_gems "path_gem 1.0"
+ FileUtils.rm_r lib_path("path_gem-1.0")
+
+ bundle! :install, :path => ".bundle", :without => "development", :deployment => true, :env => { :DEBUG => "1" }
+ run! "puts :WIN"
+ expect(out).to eq("WIN")
+ end
+
+ it "explodes if a path gem is missing" do
+ build_lib "path_gem"
+ install_gemfile! <<-G
+ source "file://#{gem_repo1}"
+ gem "rake"
+ gem "path_gem", :path => "#{lib_path("path_gem-1.0")}", :group => :development
+ G
+ expect(the_bundle).to include_gems "path_gem 1.0"
+ FileUtils.rm_r lib_path("path_gem-1.0")
+
+ bundle :install, :path => ".bundle", :deployment => true
+ expect(out).to include("The path `#{lib_path("path_gem-1.0")}` does not exist.")
+ end
+
it "can have --frozen set via an environment variable" do
gemfile <<-G
source "file://#{gem_repo1}"