summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Rodríguez <deivid.rodriguez@riseup.net>2019-02-20 12:25:23 +0100
committerDavid Rodríguez <deivid.rodriguez@riseup.net>2019-02-20 12:25:23 +0100
commit4bf058b56c8d9ab37f22dbd4a0c70b11a1950d2d (patch)
tree4ce72a0feca99a878fdf88999dc0498c3b68196c
parent18ca920b429be478ebf5c02827d938eca82e5463 (diff)
downloadbundler-4bf058b56c8d9ab37f22dbd4a0c70b11a1950d2d.tar.gz
Fix git source error message recommendations
So the we suggest an actually working command.
-rw-r--r--lib/bundler/source/git.rb9
-rw-r--r--spec/install/gemfile/git_spec.rb20
2 files changed, 25 insertions, 4 deletions
diff --git a/lib/bundler/source/git.rb b/lib/bundler/source/git.rb
index 31e0985ddf..225e214dd5 100644
--- a/lib/bundler/source/git.rb
+++ b/lib/bundler/source/git.rb
@@ -118,18 +118,19 @@ module Bundler
def local_override!(path)
return false if local?
+ original_path = path
path = Pathname.new(path)
path = path.expand_path(Bundler.root) unless path.relative?
unless options["branch"] || Bundler.settings[:disable_local_branch_check]
raise GitError, "Cannot use local override for #{name} at #{path} because " \
":branch is not specified in Gemfile. Specify a branch or use " \
- "`bundle config unset` to remove the local override"
+ "`bundle config unset local.#{override_for(original_path)}` to remove the local override"
end
unless path.exist?
raise GitError, "Cannot use local override for #{name} because #{path} " \
- "does not exist. Check `bundle config unset` to remove the local override"
+ "does not exist. Check `bundle config unset local.#{override_for(original_path)}` to remove the local override"
end
set_local!(path)
@@ -328,6 +329,10 @@ module Bundler
def extension_cache_slug(_)
extension_dir_name
end
+
+ def override_for(path)
+ Bundler.settings.local_overrides.key(path)
+ end
end
end
end
diff --git a/spec/install/gemfile/git_spec.rb b/spec/install/gemfile/git_spec.rb
index 90ba8a7cfb..ac2849c8d8 100644
--- a/spec/install/gemfile/git_spec.rb
+++ b/spec/install/gemfile/git_spec.rb
@@ -497,7 +497,7 @@ RSpec.describe "bundle install with git sources" do
expect(lockfile1).not_to eq(lockfile0)
end
- it "explodes if given path does not exist on install" do
+ it "explodes and gives correct solution if given path does not exist on install" do
build_git "rack", "0.8"
install_gemfile <<-G
@@ -508,9 +508,17 @@ RSpec.describe "bundle install with git sources" do
bundle %(config local.rack #{lib_path("local-rack")})
bundle :install
expect(err).to match(/Cannot use local override for rack-0.8 because #{Regexp.escape(lib_path('local-rack').to_s)} does not exist/)
+
+ solution = "config unset local.rack"
+ expect(err).to match(/Check `bundle #{solution}` to remove the local override/)
+
+ bundle solution
+ bundle :install
+
+ expect(last_command.stderr).to be_empty
end
- it "explodes if branch is not given on install" do
+ it "explodes and gives correct solution if branch is not given on install" do
build_git "rack", "0.8"
FileUtils.cp_r("#{lib_path("rack-0.8")}/.", lib_path("local-rack"))
@@ -522,6 +530,14 @@ RSpec.describe "bundle install with git sources" do
bundle %(config local.rack #{lib_path("local-rack")})
bundle :install
expect(err).to match(/Cannot use local override for rack-0.8 at #{Regexp.escape(lib_path('local-rack').to_s)} because :branch is not specified in Gemfile/)
+
+ solution = "config unset local.rack"
+ expect(err).to match(/Specify a branch or use `bundle #{solution}` to remove the local override/)
+
+ bundle solution
+ bundle :install
+
+ expect(last_command.stderr).to be_empty
end
it "does not explode if disable_local_branch_check is given" do