ruby-changes:69527
From: David <ko1@a...>
Date: Sat, 30 Oct 2021 06:11:50 +0900 (JST)
Subject: [ruby-changes:69527] f634d1ee00 (master): [rubygems/rubygems] Better error when installing a git lockfile and git not present
https://git.ruby-lang.org/ruby.git/commit/?id=f634d1ee00 From f634d1ee00e8327f1e91a5af3792c0e30c38c330 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= <deivid.rodriguez@r...> Date: Fri, 29 Oct 2021 15:51:07 +0200 Subject: [rubygems/rubygems] Better error when installing a git lockfile and git not present https://github.com/rubygems/rubygems/commit/28f4842196 --- lib/bundler/source/git/git_proxy.rb | 7 ++++-- spec/bundler/install/gemfile/git_spec.rb | 39 +++++++++++++++++++++++++++++++- 2 files changed, 43 insertions(+), 3 deletions(-) diff --git a/lib/bundler/source/git/git_proxy.rb b/lib/bundler/source/git/git_proxy.rb index 7555561edd5..e37ff8724a3 100644 --- a/lib/bundler/source/git/git_proxy.rb +++ b/lib/bundler/source/git/git_proxy.rb @@ -56,7 +56,6 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/source/git/git_proxy.rb#L56 @ref = ref @revision = revision @git = git - raise GitNotInstalledError.new if allow? && !Bundler.git_present? end def revision @@ -208,7 +207,11 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/source/git/git_proxy.rb#L207 end def allow? - @git ? @git.allow_git_ops? : true + allowed = @git ? @git.allow_git_ops? : true + + raise GitNotInstalledError.new if allowed && !Bundler.git_present? + + allowed end def with_path(&blk) diff --git a/spec/bundler/install/gemfile/git_spec.rb b/spec/bundler/install/gemfile/git_spec.rb index df2650989fa..150fcf2c420 100644 --- a/spec/bundler/install/gemfile/git_spec.rb +++ b/spec/bundler/install/gemfile/git_spec.rb @@ -1436,7 +1436,44 @@ In Gemfile: https://github.com/ruby/ruby/blob/trunk/spec/bundler/install/gemfile/git_spec.rb#L1436 end describe "without git installed" do - it "prints a better error message" do + it "prints a better error message when installing" do + build_git "foo" + + gemfile <<-G + source "#{file_uri_for(gem_repo1)}" + + gem "rake", git: "https://github.com/ruby/rake" + G + + lockfile <<-L + GIT + remote: https://github.com/ruby/rake + revision: 5c60da8644a9e4f655e819252e3b6ca77f42b7af + specs: + rake (13.0.6) + + GEM + remote: https://rubygems.org/ + specs: + + PLATFORMS + #{lockfile_platforms} + + DEPENDENCIES + rake! + + BUNDLED WITH + #{Bundler::VERSION} + L + + with_path_as("") do + bundle "install", :raise_on_error => false + end + expect(err). + to include("You need to install git to be able to use gems from git repositories. For help installing git, please refer to GitHub's tutorial at https://help.github.com/articles/set-up-git") + end + + it "prints a better error message when updating" do build_git "foo" install_gemfile <<-G -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/