utils/gems: use Gem API rather than ENV to set paths
This commit is contained in:
parent
25d0987642
commit
a5b12a33c2
@ -90,12 +90,16 @@ RSpec.shared_context "integration test" do # rubocop:disable RSpec/ContextWordin
|
||||
ruby_args = HOMEBREW_RUBY_EXEC_ARGS.dup
|
||||
if ENV["HOMEBREW_TESTS_COVERAGE"]
|
||||
simplecov_spec = Gem.loaded_specs["simplecov"]
|
||||
specs = [simplecov_spec]
|
||||
simplecov_spec.runtime_dependencies.each do |dep|
|
||||
parallel_tests_spec = Gem.loaded_specs["parallel_tests"]
|
||||
specs = []
|
||||
[simplecov_spec, parallel_tests_spec].each do |spec|
|
||||
specs << spec
|
||||
spec.runtime_dependencies.each do |dep|
|
||||
specs += dep.to_specs
|
||||
rescue Gem::LoadError => e
|
||||
onoe e
|
||||
end
|
||||
end
|
||||
libs = specs.flat_map do |spec|
|
||||
full_gem_path = spec.full_gem_path
|
||||
# full_require_paths isn't available in RubyGems < 2.2.
|
||||
|
||||
@ -53,17 +53,15 @@ module Homebrew
|
||||
def setup_gem_environment!(gem_home: nil, gem_bindir: nil, setup_path: true)
|
||||
# Match where our bundler gems are.
|
||||
gem_home ||= "#{ENV["HOMEBREW_LIBRARY"]}/Homebrew/vendor/bundle/ruby/#{RbConfig::CONFIG["ruby_version"]}"
|
||||
ENV["GEM_HOME"] = gem_home
|
||||
ENV["GEM_PATH"] = gem_home
|
||||
Gem.paths = {
|
||||
"GEM_HOME" => gem_home,
|
||||
"GEM_PATH" => gem_home,
|
||||
}
|
||||
|
||||
# Set TMPDIR so Xcode's `make` doesn't fall back to `/var/tmp/`,
|
||||
# which may be not user-writable.
|
||||
ENV["TMPDIR"] = ENV["HOMEBREW_TEMP"]
|
||||
|
||||
# Make RubyGems notice environment changes.
|
||||
Gem.clear_paths
|
||||
Gem::Specification.reset
|
||||
|
||||
return unless setup_path
|
||||
|
||||
# Add necessary Ruby and Gem binary directories to `PATH`.
|
||||
|
||||
@ -2,6 +2,9 @@
|
||||
# typed: false
|
||||
# frozen_string_literal: true
|
||||
|
||||
require_relative "gems"
|
||||
Homebrew.setup_gem_environment!
|
||||
|
||||
require_relative "../warnings"
|
||||
|
||||
Warnings.ignore :parser_syntax do
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user