简体   繁体   English

Rails服务器给出Readline支持错误

[英]Rails server giving Readline support error

I'm new to Ruby on Rails and I'm trying to start the RoR server. 我是Ruby on Rails的新手,我正在尝试启动RoR服务器。 But when I run the command rails server it gives me the following error: 但是,当我运行命令rails server它给我以下错误:

Sorry, you can't use byebug without Readline. To solve this, you need to
    rebuild Ruby with Readline support. If using Ubuntu, try `sudo apt-get
    install libreadline-dev` and then reinstall your Ruby.
bin/rails:6: warning: already initialized constant APP_PATH
/home/abraar/ror/bin/rails:6: warning: previous definition of     APP_PATH     was here
Usage: rails COMMAND [ARGS]

I'm using rbenv with Ruby 2.2.2 and Rails 4.2.1 I tried following the instructions on this blog post http://vvv.tobiassjosten.net/ruby/readline-in-ruby-with-rbenv/ but it's not working. 我正在使用rbenv与Ruby 2.2.2和Rails 4.2.1我尝试按照此博客文章http://vvv.tobiassjosten.net/ruby/readline-in-ruby-with-rbenv/上的说明进行操作,但它不能正常工作。

Any solutions? 有解决方案吗

Thanks! 谢谢!

要修复此问题(对于OSX,在Sierra上测试),请在shell中运行以下命令 -

ln -s /usr/local/opt/readline/lib/libreadline.dylib /usr/local/opt/readline/lib/libreadline.6.dylib

I solved the issue by (commands for mac with homebrew and rbenv): 我通过(带有自制软件和rbenv的mac命令)解决了这个问题:

  • installing readline brew install readline 安装readline brew install readline
  • reinstalling / recompiling ruby rbenv install 2.3.1 重新安装/重新编译ruby rbenv install 2.3.1

July 2019 on Mac 2019年7月在Mac上

I faced this same issue on my machine & running the following command solved it, note that even if you have version 8 of readline you still need to link to version 7 as shown: 我在我的机器上遇到了同样的问题并运行以下命令解决了它,请注意即使你有readline版本8,你仍然需要链接到版本7,如下所示:

ln -s /usr/local/opt/readline/lib/libreadline.dylib /usr/local/opt/readline/lib/libreadline.7.dylib

byebug is a gem used for debugging. byebug是一个用于调试的gem。

The new app generator for rails includes it by default in the development & test environments with the following lines : 新的rails应用程序生成器默认包含在开发和测试环境中,其中包含以下行

group :development, :test do
<% if RUBY_ENGINE == 'ruby' -%>
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug'

I don't think it is important for a newcomer to be able to use it. 我不认为新手能够使用它是很重要的。 I would recommend commenting out that line in the Gemfile, run bundle install and continue with your rails learning adventure. 我建议在Gemfile中注释掉那一行,运行bundle install并继续你的rails学习冒险。

I resolved it by follwing way 我通过以下方式解决了这个问题

brew unlink readline 
brew link readline --force

I was facing the following error: 我遇到了以下错误:

Sorry, you can't use byebug without Readline

Reinstalling ruby resolved this for me (using rvm): 重新安装ruby为我解决了这个问题(使用rvm):

rvm reinstall 2.1.5

You can replace ruby version ie, 2.1.5 with the one you want to reinstall. 您可以将ruby版本,即2.1.5替换为要重新安装的版本。

If you are in a hurry, 如果你赶时间,

Open your byebug's history.rb 打开你的byebug的history.rb

/Users/user/.rvm/gems/ruby-2.1.5@rails/gems/byebug-9.0.5/lib/byebug/history.rb

and comment out the following line, 并注释掉以下行,

require 'readline'

But, It is recommended to use byebug to debug. 但是,建议使用byebug进行调试。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM