Merge pull request #6032 from MikeMcQuaid/disable-gems
Disable RubyGems by default.
This commit is contained in:
commit
513dfa20f6
@ -127,6 +127,17 @@ then
|
||||
HOMEBREW_CACHE="${HOMEBREW_CACHE:-${HOME}/Library/Caches/Homebrew}"
|
||||
HOMEBREW_LOGS="${HOMEBREW_LOGS:-${HOME}/Library/Logs/Homebrew}"
|
||||
HOMEBREW_SYSTEM_TEMP="/private/tmp"
|
||||
|
||||
# Set a variable when the macOS system Ruby is new enough to avoid spawning
|
||||
# a Ruby process unnecessarily.
|
||||
if [[ "$HOMEBREW_MACOS_VERSION_NUMERIC" -lt "101303" ]]
|
||||
then
|
||||
unset HOMEBREW_MACOS_SYSTEM_RUBY_NEW_ENOUGH
|
||||
else
|
||||
# Used in ruby.sh.
|
||||
# shellcheck disable=SC2034
|
||||
HOMEBREW_MACOS_SYSTEM_RUBY_NEW_ENOUGH="1"
|
||||
fi
|
||||
else
|
||||
HOMEBREW_PROCESSOR="$(uname -m)"
|
||||
HOMEBREW_PRODUCT="${HOMEBREW_SYSTEM}brew"
|
||||
@ -157,6 +168,8 @@ else
|
||||
HOMEBREW_CACHE="${HOMEBREW_CACHE:-${CACHE_HOME}/Homebrew}"
|
||||
HOMEBREW_LOGS="${HOMEBREW_LOGS:-${CACHE_HOME}/Homebrew/Logs}"
|
||||
HOMEBREW_SYSTEM_TEMP="/tmp"
|
||||
|
||||
unset HOMEBREW_MACOS_SYSTEM_RUBY_NEW_ENOUGH
|
||||
fi
|
||||
|
||||
if [[ -n "$HOMEBREW_MACOS" || -n "$HOMEBREW_FORCE_HOMEBREW_ON_LINUX" ]]
|
||||
@ -327,6 +340,12 @@ then
|
||||
|
||||
# Don't allow non-developers to customise Ruby warnings.
|
||||
unset HOMEBREW_RUBY_WARNINGS
|
||||
|
||||
# Disable Ruby options we don't need. RubyGems provides a decent speedup.
|
||||
RUBY_DISABLE_OPTIONS="--disable=gems,did_you_mean,rubyopt"
|
||||
else
|
||||
# Don't disable did_you_mean for developers as it's useful.
|
||||
RUBY_DISABLE_OPTIONS="--disable=gems,rubyopt"
|
||||
fi
|
||||
|
||||
if [[ -z "$HOMEBREW_RUBY_WARNINGS" ]]
|
||||
@ -480,5 +499,5 @@ else
|
||||
|
||||
# Unshift command back into argument list (unless argument list was empty).
|
||||
[[ "$HOMEBREW_ARG_COUNT" -gt 0 ]] && set -- "$HOMEBREW_COMMAND" "$@"
|
||||
{ update-preinstall "$@"; exec "$HOMEBREW_RUBY_PATH" $HOMEBREW_RUBY_WARNINGS "$HOMEBREW_LIBRARY/Homebrew/brew.rb" "$@"; }
|
||||
{ update-preinstall "$@"; exec "$HOMEBREW_RUBY_PATH" $HOMEBREW_RUBY_WARNINGS "$RUBY_DISABLE_OPTIONS" "$HOMEBREW_LIBRARY/Homebrew/brew.rb" "$@"; }
|
||||
fi
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
module Homebrew
|
||||
module Assertions
|
||||
require "rubygems"
|
||||
require "test/unit/assertions"
|
||||
include ::Test::Unit::Assertions
|
||||
|
||||
|
||||
@ -1,13 +1,11 @@
|
||||
#!/bin/sh
|
||||
# Make sure this shim uses the same Ruby interpreter that is used by Homebrew.
|
||||
unset RUBYLIB
|
||||
unset RUBYOPT
|
||||
if [ -z "$HOMEBREW_RUBY_PATH" ]
|
||||
then
|
||||
echo "${0##*/}: The build tool has reset ENV; --env=std required." >&2
|
||||
exit 1
|
||||
fi
|
||||
exec "$HOMEBREW_RUBY_PATH" -x "$0" "$@"
|
||||
exec "$HOMEBREW_RUBY_PATH" --disable=gems,did_you_mean,rubyopt -x "$0" "$@"
|
||||
#!/usr/bin/env ruby -W0
|
||||
|
||||
require "pathname"
|
||||
|
||||
@ -100,7 +100,7 @@ module Homebrew
|
||||
raise "Invalid output_type for check_style_impl: #{output_type}"
|
||||
end
|
||||
|
||||
return !rubocop_success if !files.nil? && !has_non_formula
|
||||
return !rubocop_success if files.present? || !has_non_formula
|
||||
|
||||
shellcheck = which("shellcheck")
|
||||
shellcheck ||= which("shellcheck", ENV["HOMEBREW_PATH"])
|
||||
|
||||
@ -89,6 +89,7 @@ RSpec.shared_context "integration test" do
|
||||
"-I", $LOAD_PATH.join(File::PATH_SEPARATOR)
|
||||
]
|
||||
if ENV["HOMEBREW_TESTS_COVERAGE"]
|
||||
require "rubygems"
|
||||
simplecov_spec = Gem.loaded_specs["simplecov"]
|
||||
specs = [simplecov_spec]
|
||||
simplecov_spec.runtime_dependencies.each do |dep|
|
||||
|
||||
@ -12,6 +12,7 @@ module Homebrew
|
||||
end
|
||||
|
||||
def gem_user_bindir
|
||||
require "rubygems"
|
||||
"#{Gem.user_dir}/bin".freeze
|
||||
end
|
||||
|
||||
@ -39,6 +40,7 @@ module Homebrew
|
||||
ENV["GEM_PATH"] = ENV["GEM_HOME"]
|
||||
|
||||
# Make RubyGems notice environment changes.
|
||||
require "rubygems"
|
||||
Gem.clear_paths
|
||||
Gem::Specification.reset
|
||||
|
||||
@ -76,6 +78,7 @@ module Homebrew
|
||||
end
|
||||
|
||||
def install_bundler!
|
||||
require "rubygems"
|
||||
setup_gem_environment!(gem_home: Gem.user_dir, gem_bindir: gem_user_bindir)
|
||||
install_gem_setup_path!("bundler", version: ">=2", executable: "bundle", setup_gem_environment: false)
|
||||
end
|
||||
|
||||
@ -35,9 +35,12 @@ setup-ruby-path() {
|
||||
HOMEBREW_RUBY_PATH="$(type -P ruby)"
|
||||
fi
|
||||
|
||||
if [[ -n "$HOMEBREW_RUBY_PATH" && -z "$HOMEBREW_FORCE_VENDOR_RUBY" ]]
|
||||
if [[ -n "$HOMEBREW_MACOS_SYSTEM_RUBY_NEW_ENOUGH" ]]
|
||||
then
|
||||
ruby_version_new_enough="$("$HOMEBREW_RUBY_PATH" -rrubygems -e "puts Gem::Version.new(RUBY_VERSION.to_s.dup) >= Gem::Version.new('$minimum_ruby_version')")"
|
||||
ruby_version_new_enough="true"
|
||||
elif [[ -n "$HOMEBREW_RUBY_PATH" && -z "$HOMEBREW_FORCE_VENDOR_RUBY" ]]
|
||||
then
|
||||
ruby_version_new_enough="$("$HOMEBREW_RUBY_PATH" --disable=gems -rrubygems -e "puts Gem::Version.new(RUBY_VERSION.to_s.dup) >= Gem::Version.new('$minimum_ruby_version')")"
|
||||
fi
|
||||
|
||||
if [[ -z "$HOMEBREW_RUBY_PATH" || -n "$HOMEBREW_FORCE_VENDOR_RUBY" || "$ruby_version_new_enough" != "true" ]]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user