Skip to content

Commit

Permalink
Install gems automatically on newer Ruby
Browse files Browse the repository at this point in the history
  • Loading branch information
Bo98 committed Sep 4, 2023
1 parent 27902f0 commit 93fc26f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
8 changes: 0 additions & 8 deletions Library/Homebrew/brew.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,6 @@

std_trap = trap("INT") { exit! 130 } # no backtrace thanks

# check ruby version before requiring any modules.
REQUIRED_RUBY_X, REQUIRED_RUBY_Y, = ENV.fetch("HOMEBREW_REQUIRED_RUBY_VERSION").split(".").map(&:to_i)
RUBY_X, RUBY_Y, = RUBY_VERSION.split(".").map(&:to_i)
if RUBY_X < REQUIRED_RUBY_X || (RUBY_X == REQUIRED_RUBY_X && RUBY_Y < REQUIRED_RUBY_Y)
raise "Homebrew must be run under Ruby #{REQUIRED_RUBY_X}.#{REQUIRED_RUBY_Y}! " \
"You're running #{RUBY_VERSION}."
end

require_relative "global"

begin
Expand Down
11 changes: 11 additions & 0 deletions Library/Homebrew/standalone/load_path.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
# typed: true
# frozen_string_literal: true

# check ruby version before requiring any modules.
required_ruby_major, required_ruby_minor, = ENV.fetch("HOMEBREW_REQUIRED_RUBY_VERSION").split(".").map(&:to_i)
ruby_major, ruby_minor, = RUBY_VERSION.split(".").map(&:to_i)
if ruby_major < required_ruby_major || (ruby_major == required_ruby_major && ruby_minor < required_ruby_minor)
raise "Homebrew must be run under Ruby #{required_ruby_major}.#{required_ruby_minor}! " \
"You're running #{RUBY_VERSION}."
end

# We trust base Ruby to provide what we need.
# Don't look into the user-installed sitedir, which may contain older versions of RubyGems.
require "rbconfig"
Expand All @@ -12,6 +20,9 @@
require_relative "../utils/gems"
Homebrew.setup_gem_environment!(setup_path: false)

# Install gems for Rubies we don't vendor for
Homebrew.install_bundler_gems! if ruby_major != required_ruby_major || ruby_minor != required_ruby_minor

$LOAD_PATH.push HOMEBREW_LIBRARY_PATH.to_s unless $LOAD_PATH.include?(HOMEBREW_LIBRARY_PATH.to_s)
require_relative "../vendor/bundle/bundler/setup"
$LOAD_PATH.uniq!

0 comments on commit 93fc26f

Please sign in to comment.