From 3347aa13ef3e333ec7ad828e4ded3fe20b48bb42 Mon Sep 17 00:00:00 2001 From: Matthew O'Riordan Date: Thu, 20 Oct 2016 09:05:43 +0100 Subject: [PATCH] Fix terminal-notifier Bundler issue MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes issue https://github.com/alexch/rerun/issues/108 `which` is used to determine if terminal-notifier can run, but then it’s run inside a Bundler environment where terminal-notifier may not exist in the Gemfile. This then results in: /gems/bundler-1.12.5/lib/bundler/rubygems_integration.rb:322:in `block in replace_gem': terminal-notifier is not part of the bundle. Add it to Gemfile. (Gem::LoadError) from /gems/ruby-2.2.5/bin/terminal-notifier:22:in `
' from /gems/ruby-2.2.5/bin/ruby_executable_hooks:15:in `eval' from /gems/ruby-2.2.5/bin/ruby_executable_hooks:15:in `
' --- lib/rerun/notification.rb | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/rerun/notification.rb b/lib/rerun/notification.rb index 6663d47..06bc722 100644 --- a/lib/rerun/notification.rb +++ b/lib/rerun/notification.rb @@ -44,7 +44,9 @@ def command_named(name) def send(background = true) return unless command - `#{command}#{" &" if background}` + with_clean_env do + `#{command}#{" &" if background}` + end end def app_name @@ -60,5 +62,14 @@ def icon_dir File.expand_path("#{here}/../../icons") end + def with_clean_env + if defined?(Bundler) + Bundler.with_clean_env do + yield + end + else + yield + end + end end end