gpt4 book ai didi

ruby-on-rails - readline 有什么问题?

转载 作者:数据小太阳 更新时间:2023-10-29 06:44:23 28 4
gpt4 key购买 nike

我使用不同的操作系统以及 Rails 3 和 Rails 4 设置了三次 Rails 环境。直到我打开控制台输入一些 Ruby,或者使用 rails consoleRails 数据库控制台。我得到类似于:

$ rails console
/home/tobias/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/irb/completion.rb:9:in `require': no such file to load -- readline (LoadError)
from /home/tobias/.rvm/rubies/ruby-1.9.2-p18080/lib/ruby/1.9.1/irb/completion.rb:9:in `<top (required)>'
from /home/tobias/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.9/lib/rails/commands/console.rb:3:in `require'
from /home/tobias/.rvm/gems/ruby-1.9.2-p180/gemsems/railties-3.0.9/lib/rails/commands/console.rb:3:in `<top (required)>'
from /home/tobias/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.9/lib/rails/commands.commandsrb:20:in `require'
from /home/tobias/.rvm/gems/ruby-1.9.2-p180/gems/railsilties-3.0.9/lib/rails/commands.rb:20:in `<top (required)>'
from scriptt/rails:6:in `require'
from script/rails:6:in `<main>'

这来自“Fixing readline for the Ruby on Rails console”。这两次解决了我的问题。

现在我正在使用 Rails 4 和 Ruby 2,并且一切顺利,直到:

mto@mto-mint-vm ~/src/rpg $ rails console
/home/mto/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/irb/completion.rb:9:in `require': /usr/local/lib/libreadline.so.6: undefined symbol: UP - /home/mto/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/x86_64-linux/readline.so (LoadError)
from /home/mto/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/irb/completion.rb:9:in `<top (required)>'
from /home/mto/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/commands/console.rb:3:in `require'
from /home/mto/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/commands/console.rb:3:in `<top (required)>'
from /home/mto/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/commands.rb:53:in `require'
from /home/mto/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/commands.rb:53:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'

这次博客对我没有帮助。 Stackoverflow 有相关问题:

最后一个建议将 gem 'rb-readline' 添加到我的 gemfile。我添加了这一行,运行 bundle install 并得到了这个:

mto@mto-mint-vm ~/src/rpg $ rails console
Loading development environment (Rails 4.0.0)
/home/mto/.rvm/scripts/irbrc.rb:30:in `block in <top (required)>': uninitialized constant Readline (NameError)
/home/mto/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/irb/input-method.rb:150:in `gets': uninitialized constant IRB::ReadlineInputMethod::Readline (NameError)
from /home/mto/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/irb.rb:472:in `block (2 levels) in eval_input'
from /home/mto/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/irb.rb:624:in `signal_status'
from /home/mto/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/irb.rb:471:in `block in eval_input'
from /home/mto/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/irb/ruby-lex.rb:190:in `call'
from /home/mto/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/irb/ruby-lex.rb:190:in `buf_input'
from /home/mto/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/irb/ruby-lex.rb:105:in `getc'
from /home/mto/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/irb/slex.rb:206:in `match_io'
from /home/mto/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/irb/slex.rb:76:in `match'
from /home/mto/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/irb/ruby-lex.rb:290:in `token'
from /home/mto/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/irb/ruby-lex.rb:266:in `lex'
from /home/mto/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/irb/ruby-lex.rb:237:in `block (2 levels) in each_top_level_statement'
from /home/mto/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/irb/ruby-lex.rb:233:in `loop'
from /home/mto/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/irb/ruby-lex.rb:233:in `block in each_top_level_statement'
from /home/mto/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/irb/ruby-lex.rb:232:in `catch'
from /home/mto/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/irb/ruby-lex.rb:232:in `each_top_level_statement'
from /home/mto/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/irb.rb:488:in `eval_input'
from /home/mto/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/irb.rb:397:in `block in start'
from /home/mto/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/irb.rb:396:in `catch'
from /home/mto/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/irb.rb:396:in `start'
from /home/mto/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/commands/console.rb:90:in `start'
from /home/mto/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/commands/console.rb:9:in `start'
from /home/mto/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/commands.rb:64:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'

"Rails 3: uninitialized constant IRB::ReadlineInputMethod::Readline (NameError) in Heroku "通过将 gem 绑定(bind)到版本 0.4.2 解决了这个问题。我有 0.5.0。

为什么一个简单的库,它在 Rails 中占有如此重要的位置,我想在 Ruby 中也是如此,但会造成如此多的痛苦?是否正在采取任何措施使这更容易?

这只是一个用于从控制台读取行的库,对吗?上面的例子哪里出错了?我想知道为什么而不是什么以及如何。

最佳答案

你可以这样做,它对我有用:

gem install rb-readline

并将以下行添加到项目的 Gemfile 中:

gem 'rb-readline', '~> 0.4.2'

我将 gem 锁定到这个版本,因为更新版本会出现一些错误。

关于ruby-on-rails - readline 有什么问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18043397/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com