9

I'm new to Ruby on Rails and I'm trying to start the RoR server. But when I run the command rails server it gives me the following error:

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.

Any solutions?

Thanks!

Abraar Arique Diganto
  • 1,215
  • 16
  • 24

8 Answers8

17

To fix this (for OSX, tested on Sierra), run following command in your shell -

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

Abhinav Mehta
  • 201
  • 2
  • 4
8

July 2019 on 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:

ln -s /usr/local/opt/readline/lib/libreadline.dylib /usr/local/opt/readline/lib/libreadline.7.dylib
Ahmed Elkoussy
  • 8,162
  • 10
  • 60
  • 85
5

I solved the issue by (commands for mac with homebrew and rbenv):

  • installing readline brew install readline
  • reinstalling / recompiling ruby rbenv install 2.3.1
dom
  • 509
  • 1
  • 7
  • 13
3

I was facing the following error:

Sorry, you can't use byebug without Readline

Reinstalling ruby resolved this for me (using rvm):

rvm reinstall 2.1.5

You can replace ruby version ie, 2.1.5 with the one you want to reinstall.

Faisal Raza
  • 1,337
  • 1
  • 10
  • 16
3

Add this to the development group of gem.

gem 'rb-readline'

https://github.com/deivid-rodriguez/byebug/issues/289#issuecomment-251383465

Hidehiro NAGAOKA
  • 417
  • 3
  • 12
2

byebug is a gem used for debugging.

The new app generator for rails includes it by default in the development & test environments with the following lines:

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.

Prakash Murthy
  • 12,923
  • 3
  • 46
  • 74
  • Great! My Rails server is up and running now... Your solution is working. Thanks! – Abraar Arique Diganto May 20 '15 at 16:04
  • Awesome. You can come back to `byebug` / other options for debugging in a rails app later on when you need it. – Prakash Murthy May 20 '15 at 16:06
  • Its working in my case as well. But I want to know why it is not working before as I have done what error says. I have installed the required package and then reinstalled ruby using 'rbenv' and by compiling from source as well but nothing works for me. – Neeraj Verma Sep 26 '15 at 19:38
  • 11
    this is not a solution to problem and why would beginner rails developer wouldn't need debugging, what if he comes from other language and is not a total newbie. – Przemek Mroczek Sep 30 '16 at 06:51
  • Agreed with prior comment. Not a solution. And, `byebug` is VERY useful, especially for beginners! – theUtherSide Oct 19 '16 at 01:56
2

I resolved it by follwing way

brew unlink readline 
brew link readline --force
Prakash
  • 676
  • 6
  • 22
1

If you are in a hurry,

Open your byebug's 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.

Balaji Radhakrishnan
  • 1,010
  • 2
  • 14
  • 28