Just installed Rails and getting cannot load such file -- io/console?


So, you've followed the normal process of installing Rails - you've either installed, or already had installed, ruby and sqlite3. You've done a gem install rails, and it all seems to have worked.

rails --version yields something sensible.

Now you try and create your first application on this server with rails new <myapp>. It doesn't work! You get something like

usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- io/console (LoadError)
        from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in `require'
        from /home/mark/.gem/ruby/gems/thor-0.19.1/lib/thor/shell/basic.rb:2:in `<top (required)>'
        from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in `require'
        from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in `require'
        from /home/mark/.gem/ruby/gems/thor-0.19.1/lib/thor/shell/color.rb:1:in `<top (required)>'
        from /home/mark/.gem/ruby/gems/thor-0.19.1/lib/thor/shell.rb:17:in `shell'
        from /home/mark/.gem/ruby/gems/thor-0.19.1/lib/thor/base.rb:439:in `start'
        from /home/mark/.gem/ruby/gems/railties-4.2.4/lib/rails/commands/application.rb:17:in `<top (required)>'
        from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in `require'
        from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in `require'
        from /home/mark/.gem/ruby/gems/railties-4.2.4/lib/rails/cli.rb:14:in `<top (required)>'
        from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in `require'
        from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in `require'
        from /home/mark/.gem/ruby/gems/railties-4.2.4/bin/rails:9:in `<top (required)>'
        from /home/mark/bin/rails:23:in `load'
        from /home/mark/bin/rails:23:in `<main>'

What went wrong?

The answer is that in some instances the installation of ruby that you had before installing rails doesn't have an io-console. Hence, all that is needed is

gem install io-console

 and all will be well.