diff options
author | The Bundler Bot <bot@bundler.io> | 2017-06-17 13:42:31 +0000 |
---|---|---|
committer | The Bundler Bot <bot@bundler.io> | 2017-06-17 13:42:31 +0000 |
commit | 79511d27da949090cf8bb826b5c69dd5e632156c (patch) | |
tree | 8bd5a9643fdd0acced0c5665d31244847287a238 | |
parent | be637c55ecae0032d506151364b62c08958e075d (diff) | |
parent | bf5bf106230772934602768bb31a68dc925691f0 (diff) | |
download | bundler-79511d27da949090cf8bb826b5c69dd5e632156c.tar.gz |
Auto merge of #5783 - bundler:seg-fix-manpath, r=segiddins
[EnvironmentPreserver] Allow preserving MANPATH
### What was the end-user problem that led to this PR?
The problem was Bundler could throw an exception during setup when a gem contained manpages we were adding to `$MANPATH`.
Fixes #5730.
### Was was your diagnosis of the problem?
My diagnosis was that `$MANPATH` wasn't whitelisted as a key we preserved / were 'allowed' to override via `SharedHelpers.set_env`.
### What is your fix for the problem, implemented in this PR?
My fix is to add `$MANPATH` to that list of keys, as @jules2689 suggested. I also added some test coverage around us setting the proper man path.
### Why did you choose this fix out of the possible options?
I chose this fix because it treats that env var in the same way as others bundler sets.
-rw-r--r-- | lib/bundler/environment_preserver.rb | 1 | ||||
-rw-r--r-- | spec/runtime/setup_spec.rb | 38 |
2 files changed, 39 insertions, 0 deletions
diff --git a/lib/bundler/environment_preserver.rb b/lib/bundler/environment_preserver.rb index 9a254bdd05..f78872442a 100644 --- a/lib/bundler/environment_preserver.rb +++ b/lib/bundler/environment_preserver.rb @@ -9,6 +9,7 @@ module Bundler BUNDLER_VERSION GEM_HOME GEM_PATH + MANPATH PATH RUBYLIB RUBYOPT diff --git a/spec/runtime/setup_spec.rb b/spec/runtime/setup_spec.rb index 8418f63c3b..909378ab02 100644 --- a/spec/runtime/setup_spec.rb +++ b/spec/runtime/setup_spec.rb @@ -740,6 +740,44 @@ end expect(err).to lack_errors end + describe "$MANPATH" do + before do + build_repo4 do + build_gem "with_man" do |s| + s.write("man/man1/page.1", "MANPAGE") + end + end + end + + context "when the user has one set" do + before { ENV["MANPATH"] = "/foo:" } + + it "adds the gem's man dir to the MANPATH" do + install_gemfile! <<-G + source "file:#{gem_repo4}" + gem "with_man" + G + + run! "puts ENV['MANPATH']" + expect(out).to eq("#{system_gem_path("gems/with_man-1.0/man")}:/foo") + end + end + + context "when the user does not have one set" do + before { ENV.delete("MANPATH") } + + it "adds the gem's man dir to the MANPATH" do + install_gemfile! <<-G + source "file:#{gem_repo4}" + gem "with_man" + G + + run! "puts ENV['MANPATH']" + expect(out).to eq(system_gem_path("gems/with_man-1.0/man").to_s) + end + end + end + it "should prepend gemspec require paths to $LOAD_PATH in order" do update_repo2 do build_gem("requirepaths") do |s| |