简体   繁体   English

铁路新 <app> 或rails -h craps out with无法加载此类文件 - io / console

[英]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.

相关问题 无法在Rails控制台中加载此类文件 - cannot load such file in Rails console 尝试启动新的Rails应用程序时无法加载此类文件 - cannot load such file when trying to start new rails app rails console需要无法加载此类文件的readline - rails console require cannot load such file readline rails console(`require&#39;:无法加载此类文件) - rails console (`require': cannot load such file) 无法将Rack Middleware文件加载到Rails应用中 - Cannot load Rack Middleware file into Rails app 无法在Rails控制台中加载Ruby EventMachine-没有此类文件可加载 - Cannot load Ruby EventMachine in Rails console - no such file to load Rails 控制台:在“require”中:无法加载此类文件 — readline (LoadError) - Rails console: in `require': cannot load such file — readline (LoadError) rails console 无法加载这样的文件,但是一个字母大写它可以工作吗? - rails console cannot load such file but with one letter capitalized it works? 无法生成新的rails应用程序 - “load”:无法加载此类文件 - /home/***/.rvm/gems/ruby-2.2.0/gems/rails-4.2.0/bin/rails(LoadError) - Unable to generate new rails app - `load': cannot load such file — /home/***/.rvm/gems/ruby-2.2.0/gems/rails-4.2.0/bin/rails (LoadError) 制作新的Rails应用程序时,出现以下错误:`require&#39;:无法加载此类文件-捆绑程序(LoadError) - When making a new Rails app, I get the following error: `require': cannot load such file — bundler (LoadError)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM