diff options
author | Samuel Cochran <sj26@sj26.com> | 2016-03-23 19:09:10 +1100 |
---|---|---|
committer | Samuel Cochran <sj26@sj26.com> | 2016-03-23 19:09:47 +1100 |
commit | e35b4e74a2f7f629203dbab7602df17a01a73c4f (patch) | |
tree | 96d1d52278963363d270a927d1e8343f7db19561 | |
parent | 4c54e5f64594986ab187aafa0068b16be8959408 (diff) | |
download | bundler-e35b4e74a2f7f629203dbab7602df17a01a73c4f.tar.gz |
Open editor with clean env
Editors which have ruby embedded may be confused by bundler's
environment, so strip it before launching the editor process.
-rw-r--r-- | lib/bundler/cli/open.rb | 4 | ||||
-rw-r--r-- | spec/commands/open_spec.rb | 5 |
2 files changed, 8 insertions, 1 deletions
diff --git a/lib/bundler/cli/open.rb b/lib/bundler/cli/open.rb index d4dba703cd..0bbfa63d34 100644 --- a/lib/bundler/cli/open.rb +++ b/lib/bundler/cli/open.rb @@ -16,7 +16,9 @@ module Bundler path = Bundler::CLI::Common.select_spec(name, :regex_match).full_gem_path Dir.chdir(path) do command = Shellwords.split(editor) + [path] - system(*command) || Bundler.ui.info("Could not run '#{command.join(" ")}'") + Bundler.with_clean_env do + system(*command) + end || Bundler.ui.info("Could not run '#{command.join(" ")}'") end end end diff --git a/spec/commands/open_spec.rb b/spec/commands/open_spec.rb index 6fa219f889..1776eed6e9 100644 --- a/spec/commands/open_spec.rb +++ b/spec/commands/open_spec.rb @@ -78,4 +78,9 @@ describe "bundle open" do bundle "open rails", :env => { "EDITOR" => "echo editor", "VISUAL" => "", "BUNDLER_EDITOR" => "" } expect(out).to include("Installing foo 1.0") end + + it "opens the editor with a clean env" do + bundle "open", :env => { "EDITOR" => "sh -c 'env'", "VISUAL" => "", "BUNDLER_EDITOR" => "" } + expect(out).not_to include("BUNDLE_GEMFILE=") + end end |