spring
spring copied to clipboard
in `rescue in preload': undefined method `map' for nil:NilClass
In Rails 4.2.6 when I run "rails g scaffold Post title:string content:text"
The following error is appear:
/home/xxx/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/spring-1.7.2/lib/spring/application.rb:102:in rescue in preload': undefined methodmap' for nil:NilClass
happened for me in Rails 4.0.8 as well when I try to open a rails console. This is the stacktrace it returns:
/home/user/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/spring-1.7.2/lib/spring/application.rb:102:in `rescue in preload': undefined method `map' for nil:NilClass
Did you mean? tap (NoMethodError)
from /home/user/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/spring-1.7.2/lib/spring/application.rb:115:in `preload'
from /home/user/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/spring-1.7.2/lib/spring/application.rb:143:in `serve'
from /home/user/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/spring-1.7.2/lib/spring/application.rb:131:in `block in run'
from /home/user/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/spring-1.7.2/lib/spring/application.rb:125:in `loop'
from /home/user/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/spring-1.7.2/lib/spring/application.rb:125:in `run'
from /home/user/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/spring-1.7.2/lib/spring/application/boot.rb:19:in `<top (required)>'
from /home/user/.rbenv/versions/2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /home/user/.rbenv/versions/2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from -e:1:in `<main>'
pointing to the line where it tries to access the backtrace:
disconnect_database
@preloaded = :success
rescue Exception => e
@preloaded = :failure
watcher.add e.backtrace.map { |line| line[/^(.*)\:\d+/, 1] } # <<< here
raise e unless initialized?
ensure
Which makes no sense for me. Why should e be nil?
However, I had an error in a gem (had it locally with path: in the Gemfile) which caused this strange behaviour.
So it isn't an issue anymore for me but I wanted to share my findings.
PS: do you really want to rescue Exception instead of StandardError? Is it because it's about requiring files?
I've experiencing this too in rails 4.1.16
I got this exception when I had a syntax error in my config/application.rb, because SyntaxError doesn't have a backtrace. I'm using Rails 5.0.1, Spring 2.0.0.