8

I recently upgraded my Ruby to 2.5.0. Since then, I haven't been able to run the Rails Console properly. It either hangs indefinitely, or, after a few seconds, shows me this error:

before_session hook failed: NoMethodError: undefined method `reject!' for nil:NilClass

Full error:

Running via Spring preloader in process 6102
Loading development environment (Rails 5.1.4)
before_session hook failed: NoMethodError: undefined method `reject!' for nil:NilClass
Traceback (most recent call last):
/Users/zoro/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/spring-2.0.2/lib/spring/application.rb:171:in `fork': undefined method `reject!' for nil:NilClass (NoMethodError)

If I DISABLE_SPRING, I'm able to start up my console as expected. However, (Not sure if this is related, if it's not- I can figure this out separately) if any errors occur, the console "crashes" and kicks me back to the terminal:

⇒rails console
Loading development environment (Rails 5.1.4)
[1] pry(main)> a
Traceback (most recent call last):
bin/rails: undefined method `[]' for nil:NilClass (NoMethodError)
⇒

Any help on this would be greatly appreciated. Using rbenv to manage Rubies, and not having this error on other versions of Ruby.

dnsh
  • 3,516
  • 2
  • 22
  • 47
Rockster160
  • 1,579
  • 1
  • 15
  • 30

1 Answers1

16

This appears to be some strange issue with the binding_of_caller in conjunction with Spring. Removing that gem got things back working as expected. I knew I'd find the answer as soon as I asked.

There isn't currently a fix, but it does seem to have an open issue already: https://github.com/charliesome/better_errors/issues/411

Rockster160
  • 1,579
  • 1
  • 15
  • 30
  • 2
    Thanks. Checked this once again and found that it's already fixed in version `0.8.0`! – vlasiak Feb 16 '18 at 10:14
  • In my case, `binding_of_caller` was a dependency of another gem in my stack. I didn't want to bump the version of the primary gem blindly, but looking at the Gemfile.lock it required `binding_of_caller (>= 0.7.2)`. A simple `bundle update binding_of_caller` pulled in version 0.8.0 and resolved the issue in the console. – Chris Bloom Jan 28 '19 at 19:06
  • In my case, `binding_of_caller` was a dependency of `web-console`. Since I wasn't using it anyways, I removed it and my rails console went back to normal. – sandre89 Mar 28 '19 at 02:21