spring 2.0.2 → 4.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 42ad763baaed56f6c7dd36b05566eec2e008481b
4
- data.tar.gz: 6f228d8ea63046f99353e83e732a72ef1900b0fd
2
+ SHA256:
3
+ metadata.gz: 58ff21d566fae5a1ed7025a46e8237e45756ecbaaa219573e90cab80fe2fb0c8
4
+ data.tar.gz: 2831c92a62ae470829dfac0fc295942cafd33da7daa04e2f0c863fdd8859b098
5
5
  SHA512:
6
- metadata.gz: b049078c55028bbba601d2ca065fff5e3904cfd27b4ab6b719b7488e1bd044247cb88716126d46e5f26abb6296818d606b717ae4c0ad4c9c04726ff43e22c50e
7
- data.tar.gz: 12560b678ff15621efb6b479a443048330088f40ad328b920525785d59aa64064895565f96db5bb14801ce6c516106f3296ec8966a83b55142e915fa0df7bf74
6
+ metadata.gz: 2282af745105b6c7beed9d42ad9c6b3a801187eda13fe32c58a390b6a4461fafad7ac47ed13650d1efe25fceb4fb6b39fdd46dd7e96ba939024f770c04be6e06
7
+ data.tar.gz: 81ac1da9669749b949edd5e11a99ee1883eadaf0e845b5c02d164a9c44216c1628cd7d06298f92db52533906fdd0cf7469170e97ed6b8089c16cc260e245acc8
data/LICENSE.txt CHANGED
@@ -1,3 +1,4 @@
1
+ Copyright (c) 2017-2021 Rafael Mendonça França
1
2
  Copyright (c) 2012-2017 Jon Leighton
2
3
 
3
4
  MIT License
data/README.md CHANGED
@@ -1,10 +1,10 @@
1
1
  # Spring
2
2
 
3
- [![Build Status](https://travis-ci.org/rails/spring.svg?branch=master)](https://travis-ci.org/rails/spring)
4
- [![Gem Version](https://badge.fury.io/rb/spring.svg)](http://badge.fury.io/rb/spring)
3
+ [![Build Status](https://github.com/rails/spring/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/rails/spring/actions/workflows/ci.yml?branch=main)
4
+ [![Gem Version](https://badge.fury.io/rb/spring.svg)](https://badge.fury.io/rb/spring)
5
5
 
6
6
  Spring is a Rails application preloader. It speeds up development by
7
- keeping your application running in the background so you don't need to
7
+ keeping your application running in the background, so you don't need to
8
8
  boot it every time you run a test, rake task or migration.
9
9
 
10
10
  ## Features
@@ -16,9 +16,9 @@ boot it every time you run a test, rake task or migration.
16
16
 
17
17
  ## Compatibility
18
18
 
19
- * Ruby versions: MRI 1.9.3, MRI 2.0, MRI 2.1, MRI 2.2
20
- * Rails versions: 4.2, 5.0 (Spring is installed by default when you do
21
- `rails new` to generate your application)
19
+ * Ruby versions: MRI 2.7, MRI 3.0, MRI 3.1, MRI 3.2
20
+ * Rails versions: 6.0, 6.1, 7.0
21
+ * Bundler v2.1+
22
22
 
23
23
  Spring makes extensive use of `Process.fork`, so won't be able to
24
24
  provide a speed up on platforms which don't support forking (Windows, JRuby).
@@ -27,14 +27,14 @@ provide a speed up on platforms which don't support forking (Windows, JRuby).
27
27
 
28
28
  ### Setup
29
29
 
30
- Add spring to your Gemfile:
30
+ Add Spring to your Gemfile:
31
31
 
32
32
  ``` ruby
33
33
  gem "spring", group: :development
34
34
  ```
35
35
 
36
36
  (Note: using `gem "spring", git: "..."` *won't* work and is not a
37
- supported way of using spring.)
37
+ supported way of using Spring.)
38
38
 
39
39
  It's recommended to 'springify' the executables in your `bin/`
40
40
  directory:
@@ -50,21 +50,35 @@ code into relevant existing executables. The snippet looks like this:
50
50
  ``` ruby
51
51
  begin
52
52
  load File.expand_path('../spring', __FILE__)
53
- rescue LoadError
53
+ rescue LoadError => e
54
+ raise unless e.message.include?('spring')
54
55
  end
55
56
  ```
56
57
 
57
- On platforms where spring is installed and supported, this snippet
58
- hooks spring into the execution of commands. In other cases, the snippet
59
- will just be silently ignored and the lines after it will be executed as
58
+ On platforms where Spring is installed and supported, this snippet
59
+ hooks Spring into the execution of commands. In other cases, the snippet
60
+ will just be silently ignored, and the lines after it will be executed as
60
61
  normal.
61
62
 
62
63
  If you don't want to prefix every command you type with `bin/`, you
63
- can [use direnv](https://github.com/zimbatm/direnv#the-stdlib) to
64
+ can [use direnv](https://github.com/direnv/direnv#the-stdlib) to
64
65
  automatically add `./bin` to your `PATH` when you `cd` into your application.
65
66
  Simply create an `.envrc` file with the command `PATH_add bin` in your
66
67
  Rails directory.
67
68
 
69
+ ### Enable reloading
70
+
71
+ Spring reloads application code, and therefore needs the application to have
72
+ reloading enabled.
73
+
74
+ Ensure that `config.enable_reloading` is `true` in the environments that
75
+ Spring manages. That setting is typically configured in
76
+ `config/environments/*.rb`. In particular, make sure it is `true` for the
77
+ `test` environment.
78
+
79
+ Note: in versions of Rails before 7.1, the setting is called `cache_classes`,
80
+ and it needs to be `false` for Spring to work.
81
+
68
82
  ### Usage
69
83
 
70
84
  For this walkthrough I've generated a new Rails application, and run
@@ -90,7 +104,7 @@ user 0m0.281s
90
104
  sys 0m0.066s
91
105
  ```
92
106
 
93
- That wasn't particularly fast because it was the first run, so spring
107
+ That wasn't particularly fast because it was the first run, so Spring
94
108
  had to boot the application. It's now running:
95
109
 
96
110
  ```
@@ -167,8 +181,8 @@ Spring is running:
167
181
  26707 spring app | spring-demo-app | started 2 secs ago | development mode
168
182
  ```
169
183
 
170
- There's no need to "shut down" spring. This will happen automatically
171
- when you close your terminal. However if you do want to do a manual shut
184
+ There's no need to "shut down" Spring. This will happen automatically
185
+ when you close your terminal. However, if you do want to do a manual shut
172
186
  down, use the `stop` command:
173
187
 
174
188
  ```
@@ -176,9 +190,11 @@ $ bin/spring stop
176
190
  Spring stopped.
177
191
  ```
178
192
 
193
+ From within your code, you can check whether Spring is active with `if defined?(Spring)`.
194
+
179
195
  ### Removal
180
196
 
181
- To remove spring:
197
+ To remove Spring:
182
198
 
183
199
  * 'Unspring' your bin/ executables: `bin/spring binstub --remove --all`
184
200
  * Remove spring from your Gemfile
@@ -186,12 +202,13 @@ To remove spring:
186
202
  ### Deployment
187
203
 
188
204
  You must not install Spring on your production environment. To prevent it from
189
- being installed, provide the `--without development test` argument to the
205
+ being installed, run the `bundle config set without 'development test'` before
190
206
  `bundle install` command which is used to install gems on your production
191
207
  machines:
192
208
 
193
209
  ```
194
- $ bundle install --without development test
210
+ $ bundle config set without 'development test'
211
+ $ bundle install
195
212
  ```
196
213
 
197
214
  ## Commands
@@ -216,7 +233,7 @@ Spring::Commands::Rake.environment_matchers[:default] = "development"
216
233
  ### `rails console`, `rails generate`, `rails runner`
217
234
 
218
235
  These execute the rails command you already know and love. If you run
219
- a different sub command (e.g. `rails server`) then spring will automatically
236
+ a different sub command (e.g. `rails server`) then Spring will automatically
220
237
  pass it through to the underlying `rails` executable (without the
221
238
  speed-up).
222
239
 
@@ -230,18 +247,22 @@ You can add these to your Gemfile for additional commands:
230
247
  * [spring-commands-testunit](https://github.com/jonleighton/spring-commands-testunit) - useful for
231
248
  running `Test::Unit` tests on Rails 3, since only Rails 4 allows you
232
249
  to use `rake test path/to/test` to run a particular test/directory.
250
+ * [spring-commands-parallel-tests](https://github.com/DocSpring/spring-commands-parallel-tests) - Adds the `parallel_*` commands from [`parallel_tests`](https://github.com/grosser/parallel_tests).
233
251
  * [spring-commands-teaspoon](https://github.com/alejandrobabio/spring-commands-teaspoon.git)
234
252
  * [spring-commands-m](https://github.com/gabrieljoelc/spring-commands-m.git)
235
253
  * [spring-commands-rubocop](https://github.com/p0deje/spring-commands-rubocop)
254
+ * [spring-commands-rackup](https://github.com/wintersolutions/spring-commands-rackup)
255
+ * [spring-commands-rack-console](https://github.com/wintersolutions/spring-commands-rack-console)
256
+ * [spring-commands-standard](https://github.com/lakim/spring-commands-standard)
236
257
 
237
258
  ## Use without adding to bundle
238
259
 
239
- If you don't want spring-related code checked into your source
240
- repository, it's possible to use spring without adding to your Gemfile.
241
- However, using spring binstubs without adding spring to the Gemfile is not
260
+ If you don't want Spring-related code checked into your source
261
+ repository, it's possible to use Spring without adding to your Gemfile.
262
+ However, using Spring binstubs without adding Spring to the Gemfile is not
242
263
  supported.
243
264
 
244
- To use spring like this, do a `gem install spring` and then prefix
265
+ To use Spring like this, do a `gem install spring` and then prefix
245
266
  commands with `spring`. For example, rather than running `bin/rake -T`,
246
267
  you'd run `spring rake -T`.
247
268
 
@@ -252,12 +273,10 @@ run through Spring, set the `DISABLE_SPRING` environment variable.
252
273
 
253
274
  ## Class reloading
254
275
 
255
- Spring uses Rails' class reloading mechanism
256
- (`ActiveSupport::Dependencies`) to keep your code up to date between
257
- test runs. This is the same mechanism which allows you to see changes
258
- during development when you refresh the page. However, you may never
259
- have used this mechanism with your `test` environment before, and this
260
- can cause problems.
276
+ Spring uses Rails' class reloading mechanism to keep your code up to date
277
+ between test runs. This is the same mechanism which allows you to see changes
278
+ during development when you refresh the page. However, you may never have used
279
+ this mechanism with your `test` environment before, and this can cause problems.
261
280
 
262
281
  It's important to realise that code reloading means that the constants
263
282
  in your application are *different objects* after files have changed:
@@ -357,7 +376,7 @@ application restart, you can specify them with `Spring.watch`:
357
376
  Spring.watch "config/some_config_file.yml"
358
377
  ```
359
378
 
360
- By default Spring polls the filesystem for changes once every 0.2 seconds. This
379
+ By default, Spring polls the filesystem for changes once every 0.2 seconds. This
361
380
  method requires zero configuration, but if you find that it's using too
362
381
  much CPU, then you can use event-based file system listening by
363
382
  installing the
@@ -373,38 +392,46 @@ a command runs:
373
392
  Spring.quiet = true
374
393
  ```
375
394
 
395
+ You can also set the initial state of the `quiet` configuration option to true
396
+ by setting the `SPRING_QUIET` environment variable before executing Spring.
397
+ This is useful if you want to set quiet mode when invoking the Spring executable
398
+ in a subprocess, and cannot or prefer not to set it programmatically
399
+ via the `Spring.quiet` option in `~/.spring.rb` or the app's `config/spring.rb`.
400
+
376
401
  ### Environment variables
377
402
 
378
403
  The following environment variables are used by Spring:
379
404
 
380
- * `DISABLE_SPRING` - If set, Spring will be bypassed and your
405
+ * `DISABLE_SPRING` - If set, Spring will be bypassed, and your
381
406
  application will boot in a foreground process
382
407
  * `SPRING_LOG` - The path to a file which Spring will write log messages
383
408
  to.
384
409
  * `SPRING_TMP_PATH` - The directory where Spring should write its temporary
385
- files (a pidfile and a socket). By default we use the
410
+ files (a pidfile and a socket). By default, we use the
386
411
  `XDG_RUNTIME_DIR` environment variable, or else `Dir.tmpdir`, and then
387
412
  create a directory in that named `spring-$UID`. We don't use your
388
413
  Rails application's `tmp/` directory because that may be on a
389
414
  filesystem which doesn't support UNIX sockets.
390
415
  * `SPRING_APPLICATION_ID` - Used to identify distinct Rails
391
- applications. By default it is an MD5 hash of the current
416
+ applications. By default, it is an MD5 hash of the current
392
417
  `RUBY_VERSION`, and the path to your Rails project root.
393
418
  * `SPRING_SOCKET` - The path which should be used for the UNIX socket
394
419
  which Spring uses to communicate with the long-running Spring server
395
- process. By default this is `SPRING_TMP_PATH/SPRING_APPLICATION_ID`.
420
+ process. By default, this is `SPRING_TMP_PATH/SPRING_APPLICATION_ID`.
396
421
  * `SPRING_PIDFILE` - The path which should be used to store the pid of
397
- the long-running Spring server process. By default this is related to
422
+ the long-running Spring server process. By default, this is related to
398
423
  the socket path; if the socket path is `/foo/bar/spring.sock` the
399
424
  pidfile will be `/foo/bar/spring.pid`.
400
- * `SPRING_SERVER_COMMAND` - The command to run to start up the spring
425
+ * `SPRING_QUIET` - If set, the initial state of the `Spring.quiet`
426
+ configuration option will default to `true`.
427
+ * `SPRING_SERVER_COMMAND` - The command to run to start up the Spring
401
428
  server when it is not already running. Defaults to `spring _[version]_
402
429
  server --background`.
403
430
 
404
431
  ## Troubleshooting
405
432
 
406
- If you want to get more information about what spring is doing, you can
407
- run spring explicitly in a separate terminal:
433
+ If you want to get more information about what Spring is doing, you can
434
+ run Spring explicitly in a separate terminal:
408
435
 
409
436
  ```
410
437
  $ spring server
@@ -11,9 +11,15 @@ app = Spring::Application.new(
11
11
 
12
12
  Signal.trap("TERM") { app.terminate }
13
13
 
14
- Spring::ProcessTitleUpdater.run { |distance|
15
- "spring app | #{app.app_name} | started #{distance} ago | #{app.app_env} mode"
16
- }
14
+ Spring::ProcessTitleUpdater.run do |distance|
15
+ attributes = [
16
+ app.app_name,
17
+ "started #{distance} ago",
18
+ "#{app.app_env} mode",
19
+ app.spawn_env,
20
+ ].compact
21
+ "spring app | #{attributes.join(" | ")}"
22
+ end
17
23
 
18
24
  app.eager_preload if ENV.delete("SPRING_PRELOAD") == "1"
19
25
  app.run
@@ -1,5 +1,4 @@
1
1
  require "spring/boot"
2
- require "set"
3
2
  require "pty"
4
3
 
5
4
  module Spring
@@ -11,7 +10,8 @@ module Spring
11
10
  @original_env = original_env
12
11
  @spring_env = spring_env
13
12
  @mutex = Mutex.new
14
- @waiting = Set.new
13
+ @waiting = {}
14
+ @clients = {}
15
15
  @preloaded = false
16
16
  @state = :initialized
17
17
  @interrupt = IO.pipe
@@ -28,6 +28,11 @@ module Spring
28
28
  @interrupt.last.write "."
29
29
  end
30
30
 
31
+ def spawn_env
32
+ env = JSON.load(ENV["SPRING_SPAWN_ENV"].dup).map { |key, value| "#{key}=#{value}" }
33
+ env.join(", ") if env.any?
34
+ end
35
+
31
36
  def app_env
32
37
  ENV['RAILS_ENV']
33
38
  end
@@ -91,18 +96,20 @@ module Spring
91
96
 
92
97
  require Spring.application_root_path.join("config", "application")
93
98
 
94
- # config/environments/test.rb will have config.cache_classes = true. However
95
- # we want it to be false so that we can reload files. This is a hack to
96
- # override the effect of config.cache_classes = true. We can then actually
97
- # set config.cache_classes = false after loading the environment.
98
- Rails::Application.initializer :initialize_dependency_mechanism, group: :all do
99
- ActiveSupport::Dependencies.mechanism = :load
99
+ unless Rails.respond_to?(:gem_version) && Rails.gem_version >= Gem::Version.new('6.0.0')
100
+ raise "Spring only supports Rails >= 6.0.0"
100
101
  end
101
102
 
102
- require Spring.application_root_path.join("config", "environment")
103
+ Rails::Application.initializer :ensure_reloading_is_enabled, group: :all do
104
+ if Rails.application.config.cache_classes
105
+ raise <<-MSG.strip_heredoc
106
+ Spring reloads, and therefore needs the application to have reloading enabled.
107
+ Please, set config.cache_classes to false in config/environments/#{Rails.env}.rb.
108
+ MSG
109
+ end
110
+ end
103
111
 
104
- @original_cache_classes = Rails.application.config.cache_classes
105
- Rails.application.config.cache_classes = false
112
+ require Spring.application_root_path.join("config", "environment")
106
113
 
107
114
  disconnect_database
108
115
 
@@ -113,7 +120,7 @@ module Spring
113
120
  raise e unless initialized?
114
121
  ensure
115
122
  watcher.add loaded_application_features
116
- watcher.add Spring.gemfile, "#{Spring.gemfile}.lock"
123
+ watcher.add Spring.gemfile, Spring.gemfile_lock
117
124
 
118
125
  if defined?(Rails) && Rails.application
119
126
  watcher.add Rails.application.paths["config/initializers"]
@@ -125,7 +132,12 @@ module Spring
125
132
  end
126
133
 
127
134
  def eager_preload
128
- with_pty { preload }
135
+ with_pty do
136
+ # we can't see stderr and there could be issues when it's overflown
137
+ # see https://github.com/rails/spring/issues/396
138
+ STDERR.reopen("/dev/null")
139
+ preload
140
+ end
129
141
  end
130
142
 
131
143
  def run
@@ -147,10 +159,23 @@ module Spring
147
159
  log "got client"
148
160
  manager.puts
149
161
 
150
- stdout, stderr, stdin = streams = 3.times.map { client.recv_io }
162
+ @clients[client] = true
163
+
164
+ _stdout, stderr, _stdin = streams = 3.times.map { client.recv_io }
151
165
  [STDOUT, STDERR, STDIN].zip(streams).each { |a, b| a.reopen(b) }
152
166
 
153
- preload unless preloaded?
167
+ if preloaded?
168
+ client.puts(0) # preload success
169
+ else
170
+ begin
171
+ preload
172
+ client.puts(0) # preload success
173
+ rescue Exception
174
+ log "preload failed"
175
+ client.puts(1) # preload failure
176
+ raise
177
+ end
178
+ end
154
179
 
155
180
  args, env = JSON.load(client.read(client.gets.to_i)).values_at("args", "env")
156
181
  command = Spring.command(args.shift)
@@ -159,39 +184,39 @@ module Spring
159
184
  setup command
160
185
 
161
186
  if Rails.application.reloaders.any?(&:updated?)
162
- # Rails 5.1 forward-compat. AD::R is deprecated to AS::R in Rails 5.
163
- if defined? ActiveSupport::Reloader
164
- Rails.application.reloader.reload!
165
- else
166
- ActionDispatch::Reloader.cleanup!
167
- ActionDispatch::Reloader.prepare!
168
- end
187
+ Rails.application.reloader.reload!
169
188
  end
170
189
 
171
190
  pid = fork {
191
+ # Make sure to close other clients otherwise their graceful termination
192
+ # will be impossible due to reference from this fork.
193
+ @clients.each_key { |c| c.close if c != client }
194
+
172
195
  Process.setsid
173
196
  IGNORE_SIGNALS.each { |sig| trap(sig, "DEFAULT") }
174
197
  trap("TERM", "DEFAULT")
175
198
 
176
- STDERR.puts "Running via Spring preloader in process #{Process.pid}" unless Spring.quiet
199
+ unless Spring.quiet
200
+ STDERR.puts "Running via Spring preloader in process #{Process.pid}"
201
+
202
+ if Rails.env.production?
203
+ STDERR.puts "WARNING: Spring is running in production. To fix " \
204
+ "this make sure the spring gem is only present " \
205
+ "in `development` and `test` groups in your Gemfile " \
206
+ "and make sure you always use " \
207
+ "`bundle install --without development test` in production"
208
+ end
209
+ end
177
210
 
178
211
  ARGV.replace(args)
179
212
  $0 = command.exec_name
180
213
 
181
- # Delete all env vars which are unchanged from before spring started
214
+ # Delete all env vars which are unchanged from before Spring started
182
215
  original_env.each { |k, v| ENV.delete k if ENV[k] == v }
183
216
 
184
- # Load in the current env vars, except those which *were* changed when spring started
217
+ # Load in the current env vars, except those which *were* changed when Spring started
185
218
  env.each { |k, v| ENV[k] ||= v }
186
219
 
187
- # requiring is faster, so if config.cache_classes was true in
188
- # the environment's config file, then we can respect that from
189
- # here on as we no longer need constant reloading.
190
- if @original_cache_classes
191
- ActiveSupport::Dependencies.mechanism = :require
192
- Rails.application.config.cache_classes = true
193
- end
194
-
195
220
  connect_database
196
221
  srand
197
222
 
@@ -229,7 +254,7 @@ module Spring
229
254
  if exiting?
230
255
  # Ensure that we do not ignore subsequent termination attempts
231
256
  log "forced exit"
232
- @waiting.each { |pid| Process.kill("TERM", pid) }
257
+ @waiting.each_key { |pid| Process.kill("TERM", pid) }
233
258
  Kernel.exit
234
259
  else
235
260
  state! :terminating
@@ -282,13 +307,26 @@ module Spring
282
307
  Kernel.module_eval do
283
308
  old_raise = Kernel.method(:raise)
284
309
  remove_method :raise
285
- define_method :raise do |*args|
286
- begin
287
- old_raise.call(*args)
288
- ensure
289
- if $!
290
- lib = File.expand_path("..", __FILE__)
291
- $!.backtrace.reject! { |line| line.start_with?(lib) }
310
+ if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.2.0')
311
+ define_method :raise do |*args, **kwargs|
312
+ begin
313
+ old_raise.call(*args, **kwargs)
314
+ ensure
315
+ if $!
316
+ lib = File.expand_path("..", __FILE__)
317
+ $!.backtrace.reject! { |line| line.start_with?(lib) } unless $!.backtrace.frozen?
318
+ end
319
+ end
320
+ end
321
+ else
322
+ define_method :raise do |*args|
323
+ begin
324
+ old_raise.call(*args)
325
+ ensure
326
+ if $!
327
+ lib = File.expand_path("..", __FILE__)
328
+ $!.backtrace.reject! { |line| line.start_with?(lib) } unless $!.backtrace.frozen?
329
+ end
292
330
  end
293
331
  end
294
332
  end
@@ -321,7 +359,7 @@ module Spring
321
359
  end
322
360
 
323
361
  def wait(pid, streams, client)
324
- @mutex.synchronize { @waiting << pid }
362
+ @mutex.synchronize { @waiting[pid] = true }
325
363
 
326
364
  # Wait in a separate thread so we can run multiple commands at once
327
365
  Spring.failsafe_thread {
@@ -1,12 +1,14 @@
1
1
  module Spring
2
2
  class ApplicationManager
3
- attr_reader :pid, :child, :app_env, :spring_env, :status
3
+ attr_reader :pid, :child, :app_env, :spawn_env, :spring_env, :status
4
4
 
5
- def initialize(app_env, spring_env)
5
+ def initialize(app_env, spawn_env, spring_env)
6
6
  @app_env = app_env
7
+ @spawn_env = spawn_env
7
8
  @spring_env = spring_env
8
9
  @mutex = Mutex.new
9
10
  @state = :running
11
+ @pid = nil
10
12
  end
11
13
 
12
14
  def log(message)
@@ -92,16 +94,19 @@ module Spring
92
94
  def start_child(preload = false)
93
95
  @child, child_socket = UNIXSocket.pair
94
96
 
95
- Bundler.with_clean_env do
97
+ Bundler.with_original_env do
98
+ bundler_dir = File.expand_path("../..", $LOADED_FEATURES.grep(/bundler\/setup\.rb$/).first)
96
99
  @pid = Process.spawn(
97
100
  {
98
101
  "RAILS_ENV" => app_env,
99
102
  "RACK_ENV" => app_env,
100
103
  "SPRING_ORIGINAL_ENV" => JSON.dump(Spring::ORIGINAL_ENV),
101
- "SPRING_PRELOAD" => preload ? "1" : "0"
104
+ "SPRING_PRELOAD" => preload ? "1" : "0",
105
+ "SPRING_SPAWN_ENV" => JSON.dump(spawn_env),
106
+ **spawn_env,
102
107
  },
103
108
  "ruby",
104
- "-I", File.expand_path("../..", $LOADED_FEATURES.grep(/bundler\/setup\.rb$/).first),
109
+ *(bundler_dir != RbConfig::CONFIG["rubylibdir"] ? ["-I", bundler_dir] : []),
105
110
  "-I", File.expand_path("../..", __FILE__),
106
111
  "-e", "require 'spring/application/boot'",
107
112
  3 => child_socket,
@@ -1,26 +1,6 @@
1
1
  command = File.basename($0)
2
2
  bin_path = File.expand_path("../../../bin/spring", __FILE__)
3
3
 
4
- # When we run a command which does not go through Spring (e.g. DISABLE_SPRING
5
- # is used, or we just call 'rails' or something) then we get this warning from
6
- # Rubygems:
7
- #
8
- # WARN: Unresolved specs during Gem::Specification.reset: activesupport (<= 5.1, >= 4.2)
9
- # WARN: Clearing out unresolved specs.
10
- # Please report a bug if this causes problems.
11
- #
12
- # This happens due to our dependency on activesupport, when Bundler.setup gets
13
- # called. We don't actually *use* the dependency; it is purely there to
14
- # restrict the Rails version that we're compatible with.
15
- #
16
- # When the warning is shown, Rubygems just does the below.
17
- # Therefore, by doing it ourselves here, we can avoid the warning.
18
- if Gem::Specification.respond_to?(:unresolved_deps)
19
- Gem::Specification.unresolved_deps.clear
20
- else
21
- Gem.unresolved_deps.clear
22
- end
23
-
24
4
  if command == "spring"
25
5
  load bin_path
26
6
  else