19
[ec2-user@ip-XX-XXX-XXX-XXX rails]$ rails -h
/usr/share/ruby/vendor_ruby/2.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- io/console (LoadError)
    from /usr/share/ruby/vendor_ruby/2.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /usr/local/share/ruby/gems/2.0/gems/thor-0.19.1/lib/thor/shell/basic.rb:2:in `<top (required)>'
    from /usr/share/ruby/vendor_ruby/2.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /usr/share/ruby/vendor_ruby/2.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /usr/local/share/ruby/gems/2.0/gems/thor-0.19.1/lib/thor/shell/color.rb:1:in `<top (required)>'
    from /usr/local/share/ruby/gems/2.0/gems/thor-0.19.1/lib/thor/shell.rb:17:in `shell'
    from /usr/local/share/ruby/gems/2.0/gems/thor-0.19.1/lib/thor/base.rb:439:in `start'
    from /usr/local/share/ruby/gems/2.0/gems/railties-4.1.0/lib/rails/commands/application.rb:17:in `<top (required)>'
    from /usr/share/ruby/vendor_ruby/2.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /usr/share/ruby/vendor_ruby/2.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /usr/local/share/ruby/gems/2.0/gems/railties-4.1.0/lib/rails/cli.rb:14:in `<top (required)>'
    from /usr/share/ruby/vendor_ruby/2.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /usr/share/ruby/vendor_ruby/2.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /usr/local/share/ruby/gems/2.0/gems/railties-4.1.0/bin/rails:9:in `<top (required)>'
    from /usr/local/bin/rails:23:in `load'
    from /usr/local/bin/rails:23:in `<main>'

I did install Ruby on Rails using $ gem install rails and it completed fine as well. I had checked the process status with $echo $? and it was 0 meaning successful.

Interestingly these two commands work fine:

$ which rails
/usr/local/bin/rails

$ rails -v
Rails 4.1.0

This is a Amazon Web Services AMI image 64 bit. Please help me figure this out.

I have the bundler installed:

$ gem install bundler
Fetching: bundler-1.6.2.gem (100%)
Successfully installed bundler-1.6.2
Parsing documentation for bundler-1.6.2
Installing ri documentation for bundler-1.6.2
Done installing documentation for bundler after 5 seconds
1 gem installed

I checked for duplicate installs:

$ find / 2>/dev/null| grep bin/ruby
/usr/bin/ruby
/usr/bin/ruby2.0

$ find / 2>/dev/null| grep bin/rails
/usr/local/share/ruby/gems/2.0/gems/railties-4.1.0/bin/rails
/usr/local/share/ruby/gems/2.0/gems/railties-4.1.0/lib/rails/generators/rails/plugin/templates/bin/rails.tt
/usr/local/share/ruby/gems/2.0/gems/railties-4.1.0/lib/rails/generators/rails/app/templates/bin/rails
/usr/local/share/ruby/gems/2.0/gems/rails-4.1.0/guides/code/getting_started/bin/rails
/usr/local/bin/rails
/home/ec2-user/.gem/ruby/2.0/gems/rails-4.1.0/guides/code/getting_started/bin/rails
2
  • What do gem env and gem list --local say? Commented Apr 20, 2014 at 18:57
  • When I hit this I needed to quit my ssh session and try again -- something about installing rvm and rails had left me in a bad state. Commented Apr 3, 2017 at 18:28

4 Answers 4

23

You would need to install io-console gem. Install it using following command:

gem install io-console

After this run rails -h

Also, run echo $PATH and make sure that you have /usr/local/bin in the path. If not, then you would need to add it.

Sign up to request clarification or add additional context in comments.

5 Comments

I'm a complete rails newb and I had the same problem as the OP. when I try to do install the io-console gem I get: Fetching: io-console-0.4.2.gem (100%) Building native extensions. This could take a while... ERROR: Error installing io-console: ERROR: Failed to build gem native extension. /usr/bin/ruby2.0 extconf.rb mkmf.rb can't find header files for ruby at /usr/share/ruby/include/ruby.h Gem files will remain installed in /home/ec2-user/.gem/ruby/2.0/gems/io-console-0.4.2 for inspection. Results logged to /home/ec2-user/.gem/ruby/2.0/gems/io-console-0.4.2/./gem_make.out wth?
Thanks! It actually turned out to be directory permissions that I had fubared pretty badly. I killed the instance I had messed up and launched a new one, and this time this solution worked for me.
@DaveMunger Thats great! Glad my answer helped in some way.
I'd like to add for everyone who's using AWS and facing this problem, this properly solves it instead of the accepted answer.
9

So I had resolved this the same night, but somehow Stackoverflow didnt send me any notifications on the responses to the question, so I didnt know of these responses. This is what I ended up doing. It was essentially removing the ruby on rails installation and installing it from scratch. This was on a Amazon Web services server - linux flavor.

sudo yum update

$wget  https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer

$ bash -s stable < rvm-installer

$ source /home/ec2-user/.rvm/scripts/rvm

$ rvm requirements

$ sudo yum erase ruby

$ rvm install ruby

$ rvm use ruby --default

$ rvm rubygems current

$ gem install rails   # this takes forever

After that it worked just fine.

Comments

7

I had exactly the same issue on AWS Elastic Beanstalk (Puma, Ruby 2, Rails 4.0):

> rails generate simple_form:install --bootstrap

/usr/local/share/ruby/gems/2.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `require': cannot load such file -- io/console (LoadError)

I simply added:

gem 'io-console'

To the top of my Gemfile and ran bundle install again on the box for great success. Hopefully quicker than reinstalling rails for anyone else who runs in to this.

2 Comments

I had a similar issue with rails new myapp on an amazon ec2 micro instance and did gem install io-console and that cleared it up
Still relevant for me today on fresh EC2 image. gem install io-console fixed it, no rails necessary.
2

Thanks; you need io-console indeed. To make that work, install GCC. Rest is needed later on so:

yum -y install gcc mysql-devel ImageMagick-devel

Then,

gem install io-console

works and I could continue installing.

1 Comment

I had to install the ruby development header files: $ sudo yum install ruby-devel

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.