rails console fails with `Switch to inspect mode` in windows
Asked Answered
K

3

16

I create a rails project by rails new foo, then cd foo, and run rails c.

Then I got message like this.

DL is deprecated, please use Fiddle
Loading development environment (Rails 4.0.2)
Switch to inspect mode.

That's all. I can't use rails console.

Have you any idea what am I doing wrong?

I'm using railsinstaller with ruby 1.9.3 and 2.0.0 both, and ruby 2.0.0p451 (2014-02-24) [i386-mingw32] from Rubyinstaller. All versions fails with same error.

There is no problem with simple irb command.

Edit

By following Graeme's advice, I updated rb-readline from 0.5.0 to 0.5.1. and uninstalled old one.

$ gem list | grep rb-readline
rb-readline (0.5.1)

But the message remains same.

Kuvasz answered 10/5, 2014 at 7:40 Comment(3)
Do you have rb-readline gem? And if so what version?Mosa
I have rb-readline (0.5.0) with ruby 2.0.0p195 in Railsinstaller.Kuvasz
Probably related question #11221845Lianne
S
42

In case anyone gets this error with Docker, I got it because I ran docker run rails but needed -it.

> docker run rails
Switch to inspect mode. # fail
> docker run -it rails
irb(main):001:0> # yay
Scarron answered 26/9, 2015 at 23:53 Comment(4)
Is there a way to do this with docker-compose?Hove
Here's an alias to dive into the rails console on a running machine (including a machine you started with dockre-compose) function dbrailsc { docker exec -it $(docker ps | grep app_name| awk '{print $1;}') bundle exec rails c; } (you have to replace app_name with the name of the rails machine in your docker-compose.yml)Scarron
Happened to me too when running docker exec container_name rails c instead of docker exec -it container_name rails cGarderobe
I ran into this issue multiple times now, and for me, it was because the command to actually start the server (foreman start) was commented out of my docker-compose.yml so it didn't know what to start.British
M
1

This is a known problem caused by the rb-readline gem in version 0.5.0. It has been subsequently fixed in 0.5.1 which came out a few months ago.

You should therefore upgrade the rb-readline gem to v0.5.1 to fix this problem.

You can see here more details about the issue and the resolution.

Mosa answered 10/5, 2014 at 9:41 Comment(5)
Thanks for advice, but after updating I still have same error.Kuvasz
Updating should have fixed the DL deprecated warning but not the automatic switch to inspect mode. Do you have a .irbrc file in your home directory?Mosa
DL deprecated warning still remains. And I don't have .irbrc in my home directory. I have had the file, but I already removed, because it caused another rails console's error.Kuvasz
Back then, the problem was solved once, but now I run into similar problem. The answer is no, I can't type commands into the console. Just after the message, it return to command line.Kuvasz
It's year 2015, the same error in Rails 5.0 on Windows 10 the Rails console command produces Loading development environment (Rails 5.0.0.1) Switch to inspect mode. no prompt It is a fresh install.Glazunov
M
0

In docker-compose.yaml, add command: sleep infinity under ruby-part seems work. inspired by this

Moslemism answered 30/6, 2023 at 6:37 Comment(1)
As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.Glyn

© 2022 - 2024 — McMap. All rights reserved.