rails console fails with `Switch to inspect mode` in windows - ruby-on-rails

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.

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

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.

Related

how can i find what version of rails my app is running on?

I am trying to run an old rails app, but I am receiving this error after calling $ rails server:
uninitialized constant AppGenerator::Config
Did you mean? RbConfig
I am brand new to Rails, and I really don't know what this means/where to start. The app is supposedly built on 2.3.8. My computer says I have 2.4.1 and 2.3.18 installed.
I would like to know if I should install 2.3.8, or if I should upgrade to the latest version? Also I don't understand the error that is coming up, where should I look in the app to fix this - or is this a Rails problem?
Verify the version your project is built type bundle show inside it. It's gonna show all the gems and your respective versions.
And to check the rails version just type rails -v in your terminal.
The gemfile in the app folder should tell you what version of rails it is.
You can use bundle update to update the version or if you have a newer version and want an older version, do gem uninstall rails and then gem install rails -v "version number" for example, gem install rails -v 2.3.8.
You can check the rails version on Gemfile.
Try the command rake about to see the application environment.
I would suggest to have your environment setup same on the Gemfile, your application might have compatibility issues if you use a lower version.

Error trying to use Ruby on Rails

It's supposed that I installed Ruby on Rails using RailsInstaller (Windows), but when I try to use the command:
rails -v
The command prompt shows something like:
"System can not find the specified path."
I've uninstalled Rails with 'gem' command and reinstall it, but error still alive.
Is there another way to install Ruby on Rails?
How can I solve this problem?
NOTE: Ruby\bin is in PATH variable.
I found a solution: installing the previous version of RailsInstaller.
I was trying to use: railsinstaller-3.2.0 (Ruby 2.2.4, Rails 4.2)
It worked good with: railsinstaller-3.1.1 (Ruby 2.1.8, Rails 4.2)
NOTE: I'm using W7 OS.
Check out the answer on this one. You have to add rails to path.
Installing Ruby on Rails on windows

error Could not find i18n-0.7.0 in any of the sources

This Saturday (27th, December), I upgraded my project Rails version from version 4.1.5 to version 4.2.0. And I also upgraded the Ruby version from 2.1.2 to 2.1.5.
Today, I was trying to run a Controller generator: bin/rails g controller Clients index and I realized that the command is not working. I am getting this error:
Could not find i18n-0.7.0 in any of the sources
I tried other commands like: bin/rake db:migrate, bin/rake and the same problem.
But I can run the server using: bin/rails s. I can navigate through the website too.
I solved the problem.
The problem was, I upgraded the Rails version but I did not upgrade the bin/ folder.
So, to do that, I had to run the following command, and override everything:
$ bundle exec rake rails:update:bin
Thanks.
Try:
bin/bundle install
Solves the problem ;)
Earlier version was i18n --version 0.6.1
Issue got resolved using the below command.
sudo gem install i18n --version 0.7
I had the same issue and solved it by deleting the Gemfile.lock and running another bundle command.
After that, I was back to an earlier version of i18n (0.6.11) and everything worked as expected.
If you is using RVM you need reset your RVM gemsets, try this:
https://github.com/phusion/passenger/wiki/Resetting-RVM-gemsets
I did all of the above without result. Then I discovered that i18n couldn't be installed because my Ruby version was too low. (Said message was lost in the blast that bundler emits.) I updated Ruby and voila! i18n installed. NB: for some reason, Gemfile.lock showed it as installed even before this success, but RubyMine didn't show it as one of the installed libraries. Go figure.

Error using heroku_san gem: Your Ruby version is x.x.x, but your Gemfile specified x.x.x (Bundler::RubyVersionMismatch)

After upgrading a Rails application to use Ruby 2.0.0 (from 1.9.3), I started receiving this error when attempting to deploy to Heroku via rake <stage> deploy.
Your Ruby version is 1.9.3, but your Gemfile specified 2.0.0 (Bundler::RubyVersionMismatch)
It also seems to cause this error, (but I can run the Heroku commands manually without the heroku_san helpers, so authorization is not the issue).
Expected(200) <=> Actual(401 Unauthorized)
I updated the gems to the latest version, and also updated the Heroku Toolbelt.
I found this pull request and patched my version, but the error persisted.
How do I solve this (on both Ubuntu & OSX)?
Other info:
Ubuntu 12.04 LTS x64
Rails 3.2.13
Ruby 2.0.0-p247
heroku-api-0.3.15
heroku_san-4.0.8
heroku-toolbelt/2.41.0 (x86_64-linux)
rvm 1.22.10
The solution for me on Ubuntu was to modify
/usr/local/heroku/bin/heroku
And change the shebang line to
#!/usr/bin/env ruby
Thanks goes to Pivotal Labs for this.
(I don't use a Mac.)
Another issue I found with this error (1.9.2 not 1.9.3) is having BUNDLE_GEMFILE env variable set on heroku which causes heroku ruby build pack to freak and default to 1.9.2.

Rails Server Error: Ruby version is 1.8.7, but your Gemfile specified 1.9.3

I entered a existing ruby application, and type:
$ rails s
wanted to start rails server here.
but it said:
Your Ruby version is 1.8.7, but your Gemfile specified 1.9.3
Actually, I had a 1.8.7, but I deleted it. And if I do:
$ ruby -v
it said:
ruby 1.9.3p286 (2012-10-12 revision 37165) [x86_64-darwin11.4.2]
So I don't know how can I fix it. Can you give me a help?
If you are using rvm, run this:
$ rvm use 1.9.3
try using bundler
bundle exec rails s
I had similar problem:
$ bundle install
Your Ruby version is 2.1.0, but your Gemfile specified 1.9.3
but:
$ ruby -v
1.9.3-p484
$ which ruby
/home/malo/.rvm/rubies/ruby-1.9.3-p484/bin/ruby
I've found five answers: 1, 2, 3, 4, 5. Also it was open issue on github. However, I've resolved the problem as follows:
Got path to my bundler:
$ which bundle
/home/malo/.rvm/gems/ruby-1.9.3-p484#global/bin/bundle
Opened it to edit (or just cat it), and saw that it has invalid link to ruby in the first line:
$ cat $(which bundler)|head -n 1
#!/home/malo/.rvm/rubies/ruby-2.1.0/bin/ruby
Then I get the path to current valid ruby, and just replaced that invalid with it:
$ which ruby
/home/malo/.rvm/rubies/ruby-1.9.3-p484/bin/ruby
Of course you can also try replace it with the common form:
#!/usr/bin/env ruby
This should pick up the currently used ruby version.
I found out the reason I was getting this error was that I was shelling out to a Heroku command line program inside of my configuration files and Heroku Toolbelt comes with it's own version of Ruby.
The two solutions to that problem are to either not shell out to Heroku or use a Bundler.with_clean_env block instead of the backticks to shell out the heroku command.
Please try this:
1. Open your gemfile
2. Specify rails version
3. Run bundle update
4. Run rails server - rails s
Every now and then this happens with me. However I often don't like switching ruby versions here and there. So instead what I do is I just go to the Gemfile and switch the ruby version to the one that I am using. Doing this allows me to fire up my server and keep working on things.
so for instance, right now for the app i'm working on, my Gemfile is at
ruby ENV["CUSTOM_RUBY_VERSION"] || "2.1.6"
and I would just alter it to
ruby ENV["CUSTOM_RUBY_VERSION"] || "1.9.3"

Resources