Skip to content

Commit

Permalink
GEM_PATH should be a string
Browse files Browse the repository at this point in the history
  • Loading branch information
tenderlove committed Feb 5, 2016
1 parent 69db955 commit 27a436e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 12 deletions.
2 changes: 1 addition & 1 deletion lib/rubygems.rb
Original file line number Diff line number Diff line change
Expand Up @@ -941,7 +941,7 @@ def self.ui
def self.use_paths(home, *paths)
paths = nil if paths == [nil]
paths = paths.first if Array === Array(paths).first
self.paths = { "GEM_HOME" => home, "GEM_PATH" => paths }
self.paths = { "GEM_HOME" => home, "GEM_PATH" => paths.join(Gem.path_separator) }
end

##
Expand Down
14 changes: 5 additions & 9 deletions lib/rubygems/path_support.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,11 @@ def path=(gpaths)
gpaths ||= (ENV['GEM_PATH'] || "").empty? ? nil : ENV["GEM_PATH"]

if gpaths
if gpaths.kind_of?(Array)
gem_path = gpaths.dup
else
gem_path = gpaths.split(Gem.path_separator)
# Handle the path_separator being set to a regexp, which will cause
# end_with? to error
if gpaths =~ /#{Gem.path_separator}\z/
gem_path += default_path
end
gem_path = gpaths.split(Gem.path_separator)
# Handle the path_separator being set to a regexp, which will cause
# end_with? to error
if gpaths =~ /#{Gem.path_separator}\z/
gem_path += default_path
end

if File::ALT_SEPARATOR then
Expand Down
4 changes: 2 additions & 2 deletions test/rubygems/test_gem_path_support.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def test_initialize_home_normalize
end

def test_initialize_path
ps = Gem::PathSupport.new ENV.to_hash.merge("GEM_PATH" => %W[#{@tempdir}/foo #{@tempdir}/bar])
ps = Gem::PathSupport.new ENV.to_hash.merge("GEM_PATH" => %W[#{@tempdir}/foo #{@tempdir}/bar].join(Gem.path_separator))

assert_equal ENV["GEM_HOME"], ps.home

Expand Down Expand Up @@ -90,7 +90,7 @@ def test_initialize_path_with_defaults

def test_initialize_home_path
ps = Gem::PathSupport.new("GEM_HOME" => "#{@tempdir}/foo",
"GEM_PATH" => %W[#{@tempdir}/foo #{@tempdir}/bar])
"GEM_PATH" => %W[#{@tempdir}/foo #{@tempdir}/bar].join(Gem.path_separator))

assert_equal File.join(@tempdir, "foo"), ps.home

Expand Down

0 comments on commit 27a436e

Please sign in to comment.