From da755abdf448858946e236b53e2c9753f5b03510 Mon Sep 17 00:00:00 2001 From: Tomohiro Nishimura Date: Sat, 17 Oct 2020 03:59:08 +0900 Subject: [PATCH 1/3] gemfile should return Pathname to follow Bundler.default_gemfile --- lib/spring/configuration.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/spring/configuration.rb b/lib/spring/configuration.rb index eba8e9a7..d9d2b3f1 100644 --- a/lib/spring/configuration.rb +++ b/lib/spring/configuration.rb @@ -6,7 +6,7 @@ class << self def gemfile if /\s1.9.[0-9]/ === Bundler.ruby_scope.gsub(/[\/\s]+/,'') - ENV["BUNDLE_GEMFILE"] || "Gemfile" + Pathname.new(ENV["BUNDLE_GEMFILE"] || "Gemfile").expand_path else Bundler.default_gemfile end From 55eb5f5b608110cba91d77ba009f49637ac9bb30 Mon Sep 17 00:00:00 2001 From: Tomohiro Nishimura Date: Sat, 17 Oct 2020 03:59:48 +0900 Subject: [PATCH 2/3] Introduce new method named gemfile_lock --- lib/spring/configuration.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/spring/configuration.rb b/lib/spring/configuration.rb index d9d2b3f1..e7d4defb 100644 --- a/lib/spring/configuration.rb +++ b/lib/spring/configuration.rb @@ -12,6 +12,15 @@ def gemfile end end + def gemfile_lock + case gemfile.to_s + when /\bgems\.rb\z/ + gemfile.sub_ext('.locked') + else + gemfile.sub_ext('.lock') + end + end + def after_fork_callbacks @after_fork_callbacks ||= [] end From 394ee9a896a3bd4f5c5a9a0dde65d2e1b0498c53 Mon Sep 17 00:00:00 2001 From: Tomohiro Nishimura Date: Sat, 17 Oct 2020 04:00:13 +0900 Subject: [PATCH 3/3] Watch `gems.locked` instead of `Gemfile.lock` when using `gems.rb` --- lib/spring/application.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/spring/application.rb b/lib/spring/application.rb index 6d23d8fa..42ef54d8 100644 --- a/lib/spring/application.rb +++ b/lib/spring/application.rb @@ -117,7 +117,7 @@ def preload raise e unless initialized? ensure watcher.add loaded_application_features - watcher.add Spring.gemfile, "#{Spring.gemfile}.lock" + watcher.add Spring.gemfile, Spring.gemfile_lock if defined?(Rails) && Rails.application watcher.add Rails.application.paths["config/initializers"]