Skip to content

Commit c9716c2

Browse files
authored
Merge pull request #621 from adrianna-chang-shopify/spring-process-should-use-working-dir
Start Spring server process in directory where command was called
2 parents 647b8c3 + 7abf456 commit c9716c2

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## Next Release
2+
3+
* Start server process in directory where command was called
4+
15
## 2.1.0
26

37
* Add explicit support for Rails 6 (no changes were needed)

lib/spring/application.rb

+6
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,11 @@ def serve(client)
172172
end
173173
end
174174

175+
# Ensure we boot the process in the directory the command was called from,
176+
# not from the directory Spring started in
177+
original_dir = Dir.pwd
178+
Dir.chdir(env['PWD'] || original_dir)
179+
175180
pid = fork {
176181
Process.setsid
177182
IGNORE_SIGNALS.each { |sig| trap(sig, "DEFAULT") }
@@ -237,6 +242,7 @@ def serve(client)
237242
# (i.e. to prevent `spring rake -T | grep db` from hanging forever),
238243
# even when exception is raised before forking (i.e. preloading).
239244
reset_streams
245+
Dir.chdir(original_dir)
240246
end
241247

242248
def terminate

0 commit comments

Comments
 (0)