From 4367dbe4b05cdd1db66e6d8d4512c87737aee873 Mon Sep 17 00:00:00 2001 From: aidewoode Date: Mon, 1 Feb 2021 17:28:32 +0800 Subject: [PATCH] fix spring error on build image --- bin/rails | 5 ----- bin/rake | 5 ----- bin/spring | 21 +++++++++------------ 3 files changed, 9 insertions(+), 22 deletions(-) diff --git a/bin/rails b/bin/rails index efd0486f..21d3e02d 100755 --- a/bin/rails +++ b/bin/rails @@ -1,9 +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__) APP_PATH = File.expand_path('../config/application', __dir__) require_relative "../config/boot" diff --git a/bin/rake b/bin/rake index 9a8820a8..7327f471 100755 --- a/bin/rake +++ b/bin/rake @@ -1,9 +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_relative "../config/boot" require "rake" diff --git a/bin/spring b/bin/spring index d89ee495..9675cce6 100755 --- a/bin/spring +++ b/bin/spring @@ -1,17 +1,14 @@ #!/usr/bin/env ruby +if !defined?(Spring) && [nil, "development", "test"].include?(ENV["RAILS_ENV"]) + gem "bundler" + require "bundler" -# This file loads Spring without using Bundler, in order to be fast. -# It gets overwritten when you run the `spring binstub` command. - -unless defined?(Spring) - require 'rubygems' - require 'bundler' - - lockfile = Bundler::LockfileParser.new(Bundler.default_lockfile.read) - spring = lockfile.specs.detect { |spec| spec.name == 'spring' } - if spring + # Load Spring without loading other gems in the Gemfile, for speed. + 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" + rescue Gem::LoadError + # Ignore when Spring is not installed. end end