diff --git a/CHANGELOG.md b/CHANGELOG.md index bcaeaf43..59febc8b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## Next Release + +* Start server process in directory where command was called + ## 2.1.0 * Add explicit support for Rails 6 (no changes were needed) diff --git a/lib/spring/application.rb b/lib/spring/application.rb index f072be73..2332bd98 100644 --- a/lib/spring/application.rb +++ b/lib/spring/application.rb @@ -172,6 +172,11 @@ def serve(client) end end + # Ensure we boot the process in the directory the command was called from, + # not from the directory Spring started in + original_dir = Dir.pwd + Dir.chdir(env['PWD'] || original_dir) + pid = fork { Process.setsid IGNORE_SIGNALS.each { |sig| trap(sig, "DEFAULT") } @@ -237,6 +242,7 @@ def serve(client) # (i.e. to prevent `spring rake -T | grep db` from hanging forever), # even when exception is raised before forking (i.e. preloading). reset_streams + Dir.chdir(original_dir) end def terminate