[英]rails new <app> or rails -h craps out with cannot load such file — io/console
[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. 我使用$ gem install rails安装了Ruby on Rails,它也完成了。 I had checked the process status with $echo $?
我用$ 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. 这是64位的Amazon Web Services AMI映像。 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
You would need to install io-console gem
. 你需要安装
io-console gem
。 Install it using following command: 使用以下命令安装它:
gem install io-console
After this run rails -h
在此之后运行
rails -h
Also, run echo $PATH
and make sure that you have /usr/local/bin
in the path. 另外,运行
echo $PATH
并确保echo $PATH
有/usr/local/bin
。 If not, then you would need to add it. 如果没有,那么你需要添加它。
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. 所以我在同一天晚上解决了这个问题,但不知何故,Stackoverflow没有向我发送有关问题回复的任何通知,所以我不知道这些回复。 This is what I ended up doing.
这就是我最终做的事情。 It was essentially removing the ruby on rails installation and installing it from scratch.
它基本上是删除了rails安装上的ruby并从头开始安装它。 This was on a Amazon Web services server - linux flavor.
这是在Amazon Web服务器上 - linux风格。
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. 之后它工作得很好。
I had exactly the same issue on AWS Elastic Beanstalk (Puma, Ruby 2, Rails 4.0): 我在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. 在我的Gemfile顶部,再次在盒子上运行bundle install,取得了巨大的成功。 Hopefully quicker than reinstalling rails for anyone else who runs in to this.
希望比为其他任何运行此功能的人重新安装rails更快。
Thanks; 谢谢; you need io-console indeed.
你确实需要io-console。 To make that work, install GCC.
要做到这一点,请安装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. 工作,我可以继续安装。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.