diff --git a/Gemfile.lock b/Gemfile.lock index 42cbad9c27..b5a9b9a3da 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -600,7 +600,7 @@ GEM axlsx_styler (>= 1.0.0, < 2) caxlsx (>= 2.0.2, < 4) rodf (>= 1.0.0, < 2) - spring (3.0.0) + spring (4.0.0) spring-commands-rspec (1.0.4) spring (>= 0.9.1) sprockets (3.7.2) diff --git a/bin/rails b/bin/rails index 5badb2fde0..40b071ea57 100755 --- a/bin/rails +++ b/bin/rails @@ -1,9 +1,5 @@ #!/usr/bin/env ruby -begin - load File.expand_path('../spring', __FILE__) -rescue LoadError => e - raise unless e.message.include?('spring') -end +load File.expand_path("spring", __dir__) APP_PATH = File.expand_path('../config/application', __dir__) require_relative '../config/boot' require 'rails/commands' diff --git a/bin/rake b/bin/rake index d87d5f5781..a5c86fcf1f 100755 --- a/bin/rake +++ b/bin/rake @@ -1,9 +1,5 @@ #!/usr/bin/env ruby -begin - load File.expand_path('../spring', __FILE__) -rescue LoadError => e - raise unless e.message.include?('spring') -end +load File.expand_path("spring", __dir__) require_relative '../config/boot' require 'rake' Rake.application.run diff --git a/bin/rspec b/bin/rspec index 6e6709219a..3c8368a4e2 100755 --- a/bin/rspec +++ b/bin/rspec @@ -1,8 +1,4 @@ #!/usr/bin/env ruby -begin - load File.expand_path('../spring', __FILE__) -rescue LoadError => e - raise unless e.message.include?('spring') -end +load File.expand_path("spring", __dir__) require 'bundler/setup' load Gem.bin_path('rspec-core', 'rspec') diff --git a/bin/spring b/bin/spring index d89ee495fa..37f429ba02 100755 --- a/bin/spring +++ b/bin/spring @@ -1,17 +1,14 @@ #!/usr/bin/env ruby -# This file loads Spring without using Bundler, in order to be fast. +# This file loads Spring without using loading other gems in the Gemfile, in order to be fast. # It gets overwritten when you run the `spring binstub` command. -unless defined?(Spring) - require 'rubygems' - require 'bundler' +if !defined?(Spring) && [nil, "development", "test"].include?(ENV["RAILS_ENV"]) + require "bundler" - lockfile = Bundler::LockfileParser.new(Bundler.default_lockfile.read) - spring = lockfile.specs.detect { |spec| spec.name == 'spring' } - if spring + Bundler.locked_gems.specs.find { |spec| spec.name == "spring" }&.tap do |spring| Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path - gem 'spring', spring.version - require 'spring/binstub' + gem "spring", spring.version + require "spring/binstub" end end