29

I have the follwing error:

NameError (undefined local variable or method `byebug'

Code is

def  test
  t = ""
  byebug
end

--

RAILS_ENV=development gem list | grep bye

byebug (3.5.1)

then I run :

RAILS_ENV=development rails s

but it shows:

NameError (undefined local variable or method `byebug'

Do you have any idea why?

Thanks!

TGI
  • 559
  • 1
  • 6
  • 15

3 Answers3

50

It seems you need to

require 'byebug'

I was in the same situation and require failed with 'cannot load such file' error but adding to the Gemfile worked.

tuxayo
  • 1,150
  • 1
  • 13
  • 20
  • 2
    Rails 5 development on windows like `LoadError: cannot load such file -- byebug` and I just want to throw my computer out the window. Sorry for hijacking your answer. – Jay Killeen May 11 '17 at 07:36
2

Make sure you haven't installed the gems with bundle install --without development option.

If that is the case just run bundle install --with development

Calin Ciobanu
  • 53
  • 1
  • 6
1

Add byebug gem into development group

group :development, :test do
   # Call 'byebug' anywhere in the code to stop execution and get a debugger console
   gem 'byebug'

   # Access an IRB console on exception pages or by using <%= console %> in views
   gem 'web-console', '~> 2.0.0.beta4' 
end

Then run this command bundle install --with development