Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

executing spring outside RAILS_ROOT results in NoMethodError #3

Closed
senny opened this issue Dec 29, 2012 · 10 comments
Closed

executing spring outside RAILS_ROOT results in NoMethodError #3

senny opened this issue Dec 29, 2012 · 10 comments

Comments

@senny
Copy link
Member

senny commented Dec 29, 2012

When calling spring outside the RAILS_ROOT directory I get the following error:

/Users/senny/.rvm/gems/ruby-1.9.3-p194@equis/gems/spring-0.0.2/lib/spring.rb:66:in `ensure in run': undefined method `close' for nil:NilClass (NoMethodError)
    from /Users/senny/.rvm/gems/ruby-1.9.3-p194@equis/gems/spring-0.0.2/lib/spring.rb:66:in `run'
    from /Users/senny/.rvm/gems/ruby-1.9.3-p194@equis/gems/spring-0.0.2/lib/spring.rb:19:in `run'
    from /Users/senny/.rvm/gems/ruby-1.9.3-p194@equis/gems/spring-0.0.2/bin/spring:5:in `<top (required)>'
    from /Users/senny/.rvm/gems/ruby-1.9.3-p194@equis/bin/spring:19:in `load'
    from /Users/senny/.rvm/gems/ruby-1.9.3-p194@equis/bin/spring:19:in `<main>'

This happens for subdirectories of your rails application as well as directories outside a rails app.

@jonleighton
Copy link
Member

I think we should traverse up the directory tree until we find a Gemfile.

@senny
Copy link
Member Author

senny commented Feb 2, 2013

I think that's a good idea. We would then:

  1. run up the directory tree until we find a Gemfile
  2. detect the application type from that directory (rails app | engine | unknown => error)

@jonleighton
Copy link
Member

I'm not sure how we'd detect if it's a rails app specifically?

@senny
Copy link
Member Author

senny commented Feb 2, 2013

we could look for config/boot.rb. For an engine we could peek inside lib/<root_dir_name>/engine.rb this is would be very brittle tough.

@jonleighton
Copy link
Member

Yeah, seems quite brittle. Let's do this:

  • Traverse up to the Gemfile
  • Look for config/application.rb
  • If it doesn't exist, look for test/dummy/config/application.rb ("test/dummy" is what the generator creates in all cases, so seems reasonable to hardcode it)
  • Otherwise show an error saying that we couldn't find config/application.rb

Sound ok?

@senny
Copy link
Member Author

senny commented Feb 2, 2013

I don't like the idea to hardcode test/dummy. We use spec/dummy in our engines.

@senny
Copy link
Member Author

senny commented Feb 2, 2013

There is even a generator option to supply a path where to generate the dummy app.

@jonleighton
Copy link
Member

Ah good point. What do you think about linking config/application.rb to ../spec/dummy/config/application.rb? Do you reckon that's better/worse than having to create a config/spring.rb with some config pointing to the app root?

@senny
Copy link
Member Author

senny commented Feb 2, 2013

I'm fine either way. We could think about adding something to rails to make it possible to detect engines or more specifically to reach the dummy application. If the symlink must be created manually I would favor the configuration option in config/spring.rb. In my opinion this would be a more reasonable place to look for specific stuff.

@jonleighton
Copy link
Member

Yeah I'm coming back around to the config option. Let's merge your patch then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants