Skip to content

Commit 7310755

Browse files
committed
Abort when bin/spring is called and Spring is already defined
See #252. If you have a Spring 1.0 binstub, but Spring 1.1 on your system, then the Spring 1.0 binstub will activate Spring 1.1, which will then try to load your bin/rails, which will then load spring... and on in on in a loop until you run out of memory. This prevents that and prompts you to upgrade your binstubs.
1 parent 61a8eaa commit 7310755

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## Next release
2+
3+
* Detect old binstubs generated with Spring 1.0 and exit with an error.
4+
This prevents a situation where you can get stuck in an infinite loop
5+
of spring invocations.
6+
17
## 1.1.1
28

39
* Fix `$0` so that it is no longer prefixed with "spring ", as doing

bin/spring

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
11
#!/usr/bin/env ruby
22

3+
if defined?(Spring)
4+
$stderr.puts "You've tried to invoke Spring when it's already loaded (i.e. the Spring " \
5+
"constant is defined)."
6+
$stderr.puts
7+
$stderr.puts "This is probably because you generated binstubs with " \
8+
"Spring 1.0, and you now have a Spring version > 1.0 on your system. To solve " \
9+
"this, upgrade your bundle to the latest Spring version and then run " \
10+
"`bundle exec spring binstub --all` to regenerate your binstubs. This is a one-time " \
11+
"step necessary to upgrade from 1.0 to 1.1."
12+
$stderr.puts
13+
$stderr.puts "Here's the backtrace:"
14+
$stderr.puts
15+
$stderr.puts caller
16+
exit 1
17+
end
18+
319
if defined?(Gem)
420
if Gem::Version.new(Gem::VERSION) < Gem::Version.new("2.1.0")
521
warn "Warning: You're using Rubygems #{Gem::VERSION} with Spring. " \

0 commit comments

Comments
 (0)