Skip to content

Spring hangs if the project directory gets removed. #247

Open
@gylaz

Description

@gylaz

In a situation where spring server has started but then the project directory is deleted, spring throws an error:

/Users/greg/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/spring-1.1.0/lib/spring/configuration.rb:37:in `pwd': No such file or directory - getcwd (Errno::ENOENT)
    from /Users/greg/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/spring-1.1.0/lib/spring/configuration.rb:37:in `project_root_path'
    from /Users/greg/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/spring-1.1.0/lib/spring/configuration.rb:28:in `application_root_path'
    from /Users/greg/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/spring-1.1.0/lib/spring/application.rb:241:in `loaded_application_features'
    from /Users/greg/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/spring-1.1.0/lib/spring/application.rb:102:in `ensure in preload'
    from /Users/greg/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/spring-1.1.0/lib/spring/application.rb:107:in `preload'
    from /Users/greg/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/spring-1.1.0/lib/spring/application/boot.rb:15:in `<top (required)>'
    from /Users/greg/.rbenv/versions/2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /Users/greg/.rbenv/versions/2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from -e:1:in `<main>'

caused by Dir.pwd from here.

One solution is that spring could shut down upon encountering that error.

This can be replicated for version 1.1.0 by following these steps (app setup):

rails new spring-test -B
cd spring-test
vi Gemfile

# add `gem 'spring'` to the Gemfile and save.

bundle install
bundle exec spring binstub --all
rails g model person

By now spring server should be running. Now if we remove the app directory

cd .. && rm -rf spring-test

and try to re-run the steps from above (the app setup steps), the last command rails g ... will hang.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions