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_CACHE="${HOMEBREW_CACHE:-${HOME}/Library/Caches/Homebrew}"
|
||||||
HOMEBREW_LOGS="${HOMEBREW_LOGS:-${HOME}/Library/Logs/Homebrew}"
|
HOMEBREW_LOGS="${HOMEBREW_LOGS:-${HOME}/Library/Logs/Homebrew}"
|
||||||
HOMEBREW_SYSTEM_TEMP="/private/tmp"
|
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
|
else
|
||||||
HOMEBREW_PROCESSOR="$(uname -m)"
|
HOMEBREW_PROCESSOR="$(uname -m)"
|
||||||
HOMEBREW_PRODUCT="${HOMEBREW_SYSTEM}brew"
|
HOMEBREW_PRODUCT="${HOMEBREW_SYSTEM}brew"
|
||||||
@ -157,6 +168,8 @@ else
|
|||||||
HOMEBREW_CACHE="${HOMEBREW_CACHE:-${CACHE_HOME}/Homebrew}"
|
HOMEBREW_CACHE="${HOMEBREW_CACHE:-${CACHE_HOME}/Homebrew}"
|
||||||
HOMEBREW_LOGS="${HOMEBREW_LOGS:-${CACHE_HOME}/Homebrew/Logs}"
|
HOMEBREW_LOGS="${HOMEBREW_LOGS:-${CACHE_HOME}/Homebrew/Logs}"
|
||||||
HOMEBREW_SYSTEM_TEMP="/tmp"
|
HOMEBREW_SYSTEM_TEMP="/tmp"
|
||||||
|
|
||||||
|
unset HOMEBREW_MACOS_SYSTEM_RUBY_NEW_ENOUGH
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -n "$HOMEBREW_MACOS" || -n "$HOMEBREW_FORCE_HOMEBREW_ON_LINUX" ]]
|
if [[ -n "$HOMEBREW_MACOS" || -n "$HOMEBREW_FORCE_HOMEBREW_ON_LINUX" ]]
|
||||||
@ -327,6 +340,12 @@ then
|
|||||||
|
|
||||||
# Don't allow non-developers to customise Ruby warnings.
|
# Don't allow non-developers to customise Ruby warnings.
|
||||||
unset HOMEBREW_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
|
fi
|
||||||
|
|
||||||
if [[ -z "$HOMEBREW_RUBY_WARNINGS" ]]
|
if [[ -z "$HOMEBREW_RUBY_WARNINGS" ]]
|
||||||
@ -480,5 +499,5 @@ else
|
|||||||
|
|
||||||
# Unshift command back into argument list (unless argument list was empty).
|
# Unshift command back into argument list (unless argument list was empty).
|
||||||
[[ "$HOMEBREW_ARG_COUNT" -gt 0 ]] && set -- "$HOMEBREW_COMMAND" "$@"
|
[[ "$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
|
fi
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
module Homebrew
|
module Homebrew
|
||||||
module Assertions
|
module Assertions
|
||||||
|
require "rubygems"
|
||||||
require "test/unit/assertions"
|
require "test/unit/assertions"
|
||||||
include ::Test::Unit::Assertions
|
include ::Test::Unit::Assertions
|
||||||
|
|
||||||
|
|||||||
@ -1,13 +1,11 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# Make sure this shim uses the same Ruby interpreter that is used by Homebrew.
|
# Make sure this shim uses the same Ruby interpreter that is used by Homebrew.
|
||||||
unset RUBYLIB
|
|
||||||
unset RUBYOPT
|
|
||||||
if [ -z "$HOMEBREW_RUBY_PATH" ]
|
if [ -z "$HOMEBREW_RUBY_PATH" ]
|
||||||
then
|
then
|
||||||
echo "${0##*/}: The build tool has reset ENV; --env=std required." >&2
|
echo "${0##*/}: The build tool has reset ENV; --env=std required." >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
exec "$HOMEBREW_RUBY_PATH" -x "$0" "$@"
|
exec "$HOMEBREW_RUBY_PATH" --disable=gems,did_you_mean,rubyopt -x "$0" "$@"
|
||||||
#!/usr/bin/env ruby -W0
|
#!/usr/bin/env ruby -W0
|
||||||
|
|
||||||
require "pathname"
|
require "pathname"
|
||||||
|
|||||||
@ -100,7 +100,7 @@ module Homebrew
|
|||||||
raise "Invalid output_type for check_style_impl: #{output_type}"
|
raise "Invalid output_type for check_style_impl: #{output_type}"
|
||||||
end
|
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")
|
||||||
shellcheck ||= which("shellcheck", ENV["HOMEBREW_PATH"])
|
shellcheck ||= which("shellcheck", ENV["HOMEBREW_PATH"])
|
||||||
|
|||||||
@ -89,6 +89,7 @@ RSpec.shared_context "integration test" do
|
|||||||
"-I", $LOAD_PATH.join(File::PATH_SEPARATOR)
|
"-I", $LOAD_PATH.join(File::PATH_SEPARATOR)
|
||||||
]
|
]
|
||||||
if ENV["HOMEBREW_TESTS_COVERAGE"]
|
if ENV["HOMEBREW_TESTS_COVERAGE"]
|
||||||
|
require "rubygems"
|
||||||
simplecov_spec = Gem.loaded_specs["simplecov"]
|
simplecov_spec = Gem.loaded_specs["simplecov"]
|
||||||
specs = [simplecov_spec]
|
specs = [simplecov_spec]
|
||||||
simplecov_spec.runtime_dependencies.each do |dep|
|
simplecov_spec.runtime_dependencies.each do |dep|
|
||||||
|
|||||||
@ -12,6 +12,7 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
|
|
||||||
def gem_user_bindir
|
def gem_user_bindir
|
||||||
|
require "rubygems"
|
||||||
"#{Gem.user_dir}/bin".freeze
|
"#{Gem.user_dir}/bin".freeze
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -39,6 +40,7 @@ module Homebrew
|
|||||||
ENV["GEM_PATH"] = ENV["GEM_HOME"]
|
ENV["GEM_PATH"] = ENV["GEM_HOME"]
|
||||||
|
|
||||||
# Make RubyGems notice environment changes.
|
# Make RubyGems notice environment changes.
|
||||||
|
require "rubygems"
|
||||||
Gem.clear_paths
|
Gem.clear_paths
|
||||||
Gem::Specification.reset
|
Gem::Specification.reset
|
||||||
|
|
||||||
@ -76,6 +78,7 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
|
|
||||||
def install_bundler!
|
def install_bundler!
|
||||||
|
require "rubygems"
|
||||||
setup_gem_environment!(gem_home: Gem.user_dir, gem_bindir: gem_user_bindir)
|
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)
|
install_gem_setup_path!("bundler", version: ">=2", executable: "bundle", setup_gem_environment: false)
|
||||||
end
|
end
|
||||||
|
|||||||
@ -35,9 +35,12 @@ setup-ruby-path() {
|
|||||||
HOMEBREW_RUBY_PATH="$(type -P ruby)"
|
HOMEBREW_RUBY_PATH="$(type -P ruby)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -n "$HOMEBREW_RUBY_PATH" && -z "$HOMEBREW_FORCE_VENDOR_RUBY" ]]
|
if [[ -n "$HOMEBREW_MACOS_SYSTEM_RUBY_NEW_ENOUGH" ]]
|
||||||
then
|
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
|
fi
|
||||||
|
|
||||||
if [[ -z "$HOMEBREW_RUBY_PATH" || -n "$HOMEBREW_FORCE_VENDOR_RUBY" || "$ruby_version_new_enough" != "true" ]]
|
if [[ -z "$HOMEBREW_RUBY_PATH" || -n "$HOMEBREW_FORCE_VENDOR_RUBY" || "$ruby_version_new_enough" != "true" ]]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user