diff options
author | joyicecloud <joyicecloud@gmail.com> | 2013-08-29 17:12:05 -0700 |
---|---|---|
committer | Andre Arko <andre@arko.net> | 2013-09-11 16:14:46 -0700 |
commit | 7bd82641de44de6601a03ae455ce9277bcdf04b0 (patch) | |
tree | ab8e384491585136e669744125e39a318593bccf | |
parent | 940123fe859268037df59a0e704695cf733f5cf0 (diff) | |
download | bundler-7bd82641de44de6601a03ae455ce9277bcdf04b0.tar.gz |
Print a better error when git is not installed.
-rw-r--r-- | lib/bundler.rb | 4 | ||||
-rw-r--r-- | lib/bundler/source/git/git_proxy.rb | 2 | ||||
-rw-r--r-- | spec/install/git_spec.rb | 16 |
3 files changed, 21 insertions, 1 deletions
diff --git a/lib/bundler.rb b/lib/bundler.rb index 2db880eca5..f6e75dd7c0 100644 --- a/lib/bundler.rb +++ b/lib/bundler.rb @@ -352,6 +352,10 @@ module Bundler @gemspec_cache = {} end + def git_present? + @git_present ||= Bundler.which("git") + end + private def eval_yaml_gemspec(path, contents) diff --git a/lib/bundler/source/git/git_proxy.rb b/lib/bundler/source/git/git_proxy.rb index 19e297fcc2..fa398215bc 100644 --- a/lib/bundler/source/git/git_proxy.rb +++ b/lib/bundler/source/git/git_proxy.rb @@ -85,6 +85,8 @@ module Bundler def git(command, check_errors=true) if allow? + raise GitError, "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" if !Bundler.git_present? + out = SharedHelpers.with_clean_git_env { %x{git #{command}} } if check_errors && $?.exitstatus != 0 diff --git a/spec/install/git_spec.rb b/spec/install/git_spec.rb index aec8430e9d..ef36fb5b57 100644 --- a/spec/install/git_spec.rb +++ b/spec/install/git_spec.rb @@ -897,4 +897,18 @@ describe "bundle install with git sources" do end end -end + describe "without git installed" do + it "prints a better error message" do + build_git "foo" + + install_gemfile <<-G + git "#{lib_path('foo-1.0')}" do + gem 'foo' + end + G + + bundle "update", :env => {"PATH" => ""} + expect(out).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 + end +end
\ No newline at end of file |