我的Rails应用程序中出现了一些错误,我试图通过发出以下命令来启动Rails控制台:
rails console
无论我尝试什么,我总会得到同样的错误:
/usr/local/rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/irb/completion.rb:9:in `require': cannot load such file -- readline (LoadError)
from /usr/local/rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/irb/completion.rb:9:in `<top (required)>'
from /opt/mammie/web/icosole/vendor/bundle/ruby/2.1.0/gems/railties-3.1.3/lib/rails/commands/console.rb:3:in `require'
from /opt/mammie/web/icosole/vendor/bundle/ruby/2.1.0/gems/railties-3.1.3/lib/rails/commands/console.rb:3:in `<top (required)>'
from /opt/mammie/web/icosole/vendor/bundle/ruby/2.1.0/gems/railties-3.1.3/lib/rails/commands.rb:37:in `require'
from /opt/mammie/web/icosole/vendor/bundle/ruby/2.1.0/gems/railties-3.1.3/lib/rails/commands.rb:37:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
我真的尝试过在网上找到的所有可能的解决方案,因为很多人遇到了同样的错误。不幸的是,似乎没有任何效果。当我尝试以下命令时:
ruby /usr/local/rvm/src/ruby-2.1.1/ext/readline/extconf.rb
我得到以下输出
checking for tgetnum() in -lncurses... yes
checking for readline/readline.h... yes
checking for readline/history.h... yes
checking for readline() in -lreadline... no
checking for readline() in -ledit... no
checking for editline/readline.h... no
*** /usr/local/rvm/src/ruby-2.1.1/ext/readline/extconf.rb failed ***
表示缺少某些内容,但使用apt-get安装readline也没有任何区别。我猜它可能与不兼容的gem版本有关,因为控制台前一段时间曾短暂工作过。 readline是否存在任何已知版本问题?很多人似乎都遇到过这个宝石的问题。
答案 0 :(得分:12)
尝试将rb-readline
放入您的Gemfile中并查看https://stackoverflow.com/a/9595841/1905235
答案 1 :(得分:4)
我终于找到了解决方案。它是几个问题的结合(gem版本,冲突的readline库)。
首先,我重新阅读了readline lib
sudo apt-get install libreadline-dev
然后我卸载了ruby
rvm remove 2.1.1
我再次安装了红宝石
rvm install 2.1.1
我告诉RVM使用默认的(2.1.1)Ruby
rvm use default
我重新安装了Rails和readline
gem install rails
gem install readline
我再次启动控制台时遇到错误,但稍有不同:
/usr/local/rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/irb/completion.rb:9:in `require': /usr/local/lib/libreadline.so.6: undefined symbol: UP - /usr/local/rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/x86_64-linux/readline.so (LoadError)
from /usr/local/rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/irb/completion.rb:9:in `<top (required)>'
from /opt/mammie/web/icosole/vendor/bundle/ruby/2.1.0/gems/railties-3.1.3/lib/rails/commands/console.rb:3:in `require'
from /opt/mammie/web/icosole/vendor/bundle/ruby/2.1.0/gems/railties-3.1.3/lib/rails/commands/console.rb:3:in `<top (required)>'
from /opt/mammie/web/icosole/vendor/bundle/ruby/2.1.0/gems/railties-3.1.3/lib/rails/commands.rb:37:in `require'
from /opt/mammie/web/icosole/vendor/bundle/ruby/2.1.0/gems/railties-3.1.3/lib/rails/commands.rb:37:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
所以按照这个说明(http://vkarthickeyan.wordpress.com/2012/02/16/mysql-symbol-lookup-error-usrlocalliblibreadline-so-6-undefined-symbol-up/),我得到了它的工作:
cd /usr/local/lib
mkdir temp
mv libreadline* temp
ldconfig
apt-get update
感谢hunterboerner的帮助!
答案 2 :(得分:1)
我有一段时间遇到这个问题,通过键入:rvm requirements
并安装返回的内容解决了这个问题。似乎,虽然这是rvm的旧版本,所以可能不再相关
答案 3 :(得分:1)
这在没有readline的Solaris机器上运行正常,可能对您有用:
$ bundle exec irb
irb(main):001:0> require File.expand_path('config/boot')
=> true
irb(main):002:0> require File.expand_path('config/environment')
NOTE: Gem.source_index is deprecated, use Specification. It will be removed on or after 2011-11-01.
Gem.source_index called from /export/home/deploy/recon/shared/bundle/ruby/1.8/gems/rails-2.3.18/lib/rails/gem_dependency.rb:21.
Warning: NLS_LANG is not set. fallback to US7ASCII.
=> true
irb(main):027:0> require 'console_app'
=> true
答案 4 :(得分:1)
答案 5 :(得分:0)
int[][] prerequisites = { { 1, 0 }, { 2, 0 }, { 3, 1 }, { 3, 2 } };
Map<Integer,List<Integer>> map =
Arrays.stream(prerequisites)
.map(arr -> new AbstractMap.SimpleEntry<>(arr[0], arr[1]))
.collect(Collectors.groupingBy(
Map.Entry::getKey,
Collectors.mapping(Map.Entry::getValue, Collectors.toList())));
为我工作