ruby-changes:69556
From: David <ko1@a...>
Date: Tue, 2 Nov 2021 00:28:42 +0900 (JST)
Subject: [ruby-changes:69556] ed0f326e88 (master): [rubygems/rubygems] Leave ":" after MANPATH when not set
https://git.ruby-lang.org/ruby.git/commit/?id=ed0f326e88 From ed0f326e88ab695507d66729e3a4441d6888910b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= <deivid.rodriguez@r...> Date: Sat, 30 Oct 2021 09:48:57 +0200 Subject: [rubygems/rubygems] Leave ":" after MANPATH when not set So that system man pages still work after a gem with man pages overrides it. https://github.com/rubygems/rubygems/commit/1031879b87 --- lib/bundler/runtime.rb | 2 +- spec/bundler/runtime/setup_spec.rb | 71 ++++++++++++++++++++++++++------------ spec/bundler/support/filters.rb | 1 + 3 files changed, 51 insertions(+), 23 deletions(-) diff --git a/lib/bundler/runtime.rb b/lib/bundler/runtime.rb index 31e71388a68..c7276b0e251 100644 --- a/lib/bundler/runtime.rb +++ b/lib/bundler/runtime.rb @@ -265,7 +265,7 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/runtime.rb#L265 return if manuals.empty? Bundler::SharedHelpers.set_env "MANPATH", manuals.concat( - ENV["MANPATH"].to_s.split(File::PATH_SEPARATOR) + ENV["MANPATH"] ? ENV["MANPATH"].to_s.split(File::PATH_SEPARATOR) : [""] ).uniq.join(File::PATH_SEPARATOR) end diff --git a/spec/bundler/runtime/setup_spec.rb b/spec/bundler/runtime/setup_spec.rb index 3cf373fe1ca..00fed520118 100644 --- a/spec/bundler/runtime/setup_spec.rb +++ b/spec/bundler/runtime/setup_spec.rb @@ -745,41 +745,68 @@ end https://github.com/ruby/ruby/blob/trunk/spec/bundler/runtime/setup_spec.rb#L745 expect(err).to be_empty end - describe "$MANPATH" do - before do + context "when the user has `MANPATH` set", :man do + before { ENV["MANPATH"] = "/foo#{File::PATH_SEPARATOR}" } + + it "adds the gem's man dir to the MANPATH" do build_repo4 do build_gem "with_man" do |s| s.write("man/man1/page.1", "MANPAGE") end end + + install_gemfile <<-G + source "#{file_uri_for(gem_repo4)}" + gem "with_man" + G + + run "puts ENV['MANPATH']" + expect(out).to eq("#{default_bundle_path("gems/with_man-1.0/man")}#{File::PATH_SEPARATOR}/foo") end + end - context "when the user has one set" do - before { ENV["MANPATH"] = "/foo#{File::PATH_SEPARATOR}" } + context "when the user does not have `MANPATH` set", :man do + before { ENV.delete("MANPATH") } - it "adds the gem's man dir to the MANPATH" do - install_gemfile <<-G - source "#{file_uri_for(gem_repo4)}" - gem "with_man" - G + it "adds the gem's man dir to the MANPATH, leaving : in the end so that system man pages still work" do + build_repo4 do + build_gem "with_man" do |s| + s.write("man/man1/page.1", "MANPAGE") + end - run "puts ENV['MANPATH']" - expect(out).to eq("#{default_bundle_path("gems/with_man-1.0/man")}#{File::PATH_SEPARATOR}/foo") + build_gem "with_man_overriding_system_man" do |s| + s.write("man/man1/ls.1", "LS MANPAGE") + end end - end - context "when the user does not have one set" do - before { ENV.delete("MANPATH") } + install_gemfile <<-G + source "#{file_uri_for(gem_repo4)}" + gem "with_man" + G - it "adds the gem's man dir to the MANPATH" do - install_gemfile <<-G - source "#{file_uri_for(gem_repo4)}" - gem "with_man" - G + run <<~RUBY + puts ENV['MANPATH'] + require "open3" + puts Open3.capture2e("man", "ls")[1].success? + RUBY - run "puts ENV['MANPATH']" - expect(out).to eq(default_bundle_path("gems/with_man-1.0/man").to_s) - end + expect(out).to eq("#{default_bundle_path("gems/with_man-1.0/man")}#{File::PATH_SEPARATOR}\ntrue") + + install_gemfile <<-G + source "#{file_uri_for(gem_repo4)}" + gem "with_man_overriding_system_man" + G + + run <<~RUBY + puts ENV['MANPATH'] + require "open3" + puts Open3.capture2e("man", "ls")[0] + RUBY + + lines = out.split("\n") + + expect(lines).to include("#{default_bundle_path("gems/with_man_overriding_system_man-1.0/man")}#{File::PATH_SEPARATOR}") + expect(lines).to include("LS MANPAGE") end end diff --git a/spec/bundler/support/filters.rb b/spec/bundler/support/filters.rb index 0c1f27e4705..3b91897a2e1 100644 --- a/spec/bundler/support/filters.rb +++ b/spec/bundler/support/filters.rb @@ -34,6 +34,7 @@ RSpec.configure do |config| https://github.com/ruby/ruby/blob/trunk/spec/bundler/support/filters.rb#L34 config.filter_run_excluding :readline => Gem.win_platform? config.filter_run_excluding :jruby => RUBY_ENGINE != "jruby" config.filter_run_excluding :truffleruby => RUBY_ENGINE != "truffleruby" + config.filter_run_excluding :man => Gem.win_platform? config.filter_run_when_matching :focus unless ENV["CI"] end -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/