From 18e46b3ec2068310a133f183564f41d183995346 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Wed, 13 Jun 2018 07:35:04 +0200 Subject: [PATCH] Fix usage of `HOMEBREW_LOAD_PATH`. --- Library/Homebrew/brew.rb | 7 ++++--- Library/Homebrew/config.rb | 5 ++++- Library/Homebrew/dev-cmd/ruby.rb | 2 +- Library/Homebrew/test/spec_helper.rb | 2 +- .../support/helper/spec/shared_context/integration_test.rb | 4 +--- Library/Homebrew/test/support/lib/config.rb | 6 +++++- 6 files changed, 16 insertions(+), 10 deletions(-) diff --git a/Library/Homebrew/brew.rb b/Library/Homebrew/brew.rb index 42ac131e14..92f50411bd 100644 --- a/Library/Homebrew/brew.rb +++ b/Library/Homebrew/brew.rb @@ -16,14 +16,15 @@ require "pathname" HOMEBREW_LIBRARY_PATH = Pathname.new(__FILE__).realpath.parent require "English" -unless $LOAD_PATH.include?(HOMEBREW_LIBRARY_PATH.to_s) - $LOAD_PATH.unshift(HOMEBREW_LIBRARY_PATH.to_s) -end unless $LOAD_PATH.include?("#{HOMEBREW_LIBRARY_PATH}/cask/lib") $LOAD_PATH.unshift("#{HOMEBREW_LIBRARY_PATH}/cask/lib") end +unless $LOAD_PATH.include?(HOMEBREW_LIBRARY_PATH.to_s) + $LOAD_PATH.unshift(HOMEBREW_LIBRARY_PATH.to_s) +end + require "global" begin diff --git a/Library/Homebrew/config.rb b/Library/Homebrew/config.rb index 38d7c80438..753616a8c8 100644 --- a/Library/Homebrew/config.rb +++ b/Library/Homebrew/config.rb @@ -47,4 +47,7 @@ unless defined? HOMEBREW_LIBRARY_PATH end # Load path used by standalone scripts to access the Homebrew code base -HOMEBREW_LOAD_PATH = HOMEBREW_LIBRARY_PATH +HOMEBREW_LOAD_PATH = [ + HOMEBREW_LIBRARY_PATH, + HOMEBREW_LIBRARY_PATH/"cask/lib", +].join(File::PATH_SEPARATOR) diff --git a/Library/Homebrew/dev-cmd/ruby.rb b/Library/Homebrew/dev-cmd/ruby.rb index c5696d6bba..c244bcdf13 100755 --- a/Library/Homebrew/dev-cmd/ruby.rb +++ b/Library/Homebrew/dev-cmd/ruby.rb @@ -8,6 +8,6 @@ module Homebrew module_function def ruby - exec ENV["HOMEBREW_RUBY_PATH"], "-I#{HOMEBREW_LIBRARY_PATH}", "-rglobal", "-rdev-cmd/irb", *ARGV + exec ENV["HOMEBREW_RUBY_PATH"], "-I", HOMEBREW_LOAD_PATH, "-rglobal", "-rdev-cmd/irb", *ARGV end end diff --git a/Library/Homebrew/test/spec_helper.rb b/Library/Homebrew/test/spec_helper.rb index a09afa11b6..b7a657bf60 100644 --- a/Library/Homebrew/test/spec_helper.rb +++ b/Library/Homebrew/test/spec_helper.rb @@ -14,8 +14,8 @@ require "rubocop" require "rubocop/rspec/support" require "find" -$LOAD_PATH.unshift(File.expand_path("#{ENV["HOMEBREW_LIBRARY"]}/Homebrew")) $LOAD_PATH.unshift(File.expand_path("#{ENV["HOMEBREW_LIBRARY"]}/Homebrew/cask/lib")) +$LOAD_PATH.unshift(File.expand_path("#{ENV["HOMEBREW_LIBRARY"]}/Homebrew")) $LOAD_PATH.unshift(File.expand_path("#{ENV["HOMEBREW_LIBRARY"]}/Homebrew/test/support/lib")) require "global" diff --git a/Library/Homebrew/test/support/helper/spec/shared_context/integration_test.rb b/Library/Homebrew/test/support/helper/spec/shared_context/integration_test.rb index 41d7174cc3..f8e59ad4b4 100644 --- a/Library/Homebrew/test/support/helper/spec/shared_context/integration_test.rb +++ b/Library/Homebrew/test/support/helper/spec/shared_context/integration_test.rb @@ -83,9 +83,7 @@ RSpec.shared_context "integration test" do @ruby_args ||= begin ruby_args = [ "-W0", - "-I", "#{HOMEBREW_LIBRARY_PATH}/test/support/lib", - "-I", HOMEBREW_LIBRARY_PATH.to_s, - "-I", "#{HOMEBREW_LIBRARY_PATH}/cask/lib", + "-I", HOMEBREW_LOAD_PATH, "-rconfig" ] if ENV["HOMEBREW_TESTS_COVERAGE"] diff --git a/Library/Homebrew/test/support/lib/config.rb b/Library/Homebrew/test/support/lib/config.rb index 7408b3e34a..c83a0eabaa 100644 --- a/Library/Homebrew/test/support/lib/config.rb +++ b/Library/Homebrew/test/support/lib/config.rb @@ -15,7 +15,11 @@ end # Paths pointing into the Homebrew code base that persist across test runs HOMEBREW_LIBRARY_PATH = Pathname.new(File.expand_path("../../..", __dir__)) HOMEBREW_SHIMS_PATH = HOMEBREW_LIBRARY_PATH.parent+"Homebrew/shims" -HOMEBREW_LOAD_PATH = [File.expand_path(__dir__), HOMEBREW_LIBRARY_PATH].join(":") +HOMEBREW_LOAD_PATH = [ + File.expand_path(__dir__), + HOMEBREW_LIBRARY_PATH, + HOMEBREW_LIBRARY_PATH.join("cask/lib"), +].join(File::PATH_SEPARATOR) # Paths redirected to a temporary directory and wiped at the end of the test run HOMEBREW_PREFIX = Pathname.new(TEST_TMPDIR).join("prefix")