Skip to content

Commit 338a360

Browse files
committedJan 26, 2016
Improve error message for missing gemfile dependencies
If you hadn't run `bundle install --gemfile=<overcommit-gemfile>`, you would get an error during a hook run that lead you to believe there was a problem with your `Gemfile`, when it was the separate Overcommit gem file. Fix this by improving the error message to make this clearer.
1 parent 2e7077a commit 338a360

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed
 

‎CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
[`mdl`](https://github.com/mivok/markdownlint) on Markdown files
88
* Add `--without-color` flag to `RailsBestPractices` pre-commit hook
99
to fix parsing issues due to color escape sequences
10+
* Improve error message when `gemfile` has not had a dependency installed
1011

1112
## 0.30.0
1213

‎template-dir/hooks/overcommit-hook

+9-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,15 @@ require 'yaml'
3030
# rubocop:disable Style/RescueModifier
3131
if gemfile = YAML.load_file('.overcommit.yml')['gemfile'] rescue nil
3232
ENV['BUNDLE_GEMFILE'] = gemfile
33-
require 'bundler/setup'
33+
require 'bundler'
34+
35+
begin
36+
Bundler.setup
37+
rescue Bundler::BundlerError => ex
38+
puts "Problem loading '#{gemfile}': #{ex.message}"
39+
puts "Try running:\nbundle install --gemfile=#{gemfile}" if ex.is_a?(Bundler::GemNotFound)
40+
exit 78 # EX_CONFIG
41+
end
3442
end
3543
# rubocop:enable Style/RescueModifier
3644

0 commit comments

Comments
 (0)