Search code examples
ruby-on-railspry

How to I start a rails console with pry turned off?


Sometimes I have reason to want to start the rails console as an irb repl rather than pry (as awesome as pry is). It will default to pry because pry has in the Gemfile. Hows is that done nowadays?

I think there used to be a --irb option when running rails console but that seems to be gone now. I get a deprecation error message when I try it.

More details

If I just run "rails console" it takes me to pry.

If I run "rails console -irb=irb":

$ rails c -irb=irb                                                                                                                                                                         
--irb option is no longer supported. Invoke `/your/choice/of/ruby script/rails console` instead

Relevent lines from my Gemfile:

gem 'rails', '3.2.18'
gem 'pry-rails'
gem 'pry-plus'

Solution

  • Launching pry when calling rails console or rails c is set up by the pry-rails gem. If you look in the pry-rails issues there is one that describes a solution.

    Define the environment variable DISABLE_PRY_RAILS as 1.

    So you can call rails console without pry with:

    DISABLE_PRY_RAILS=1 rails c