Git Product home page Git Product logo

Comments (5)

deivid-rodriguez avatar deivid-rodriguez commented on May 18, 2024

HI @bitaxis, thanks for the feedback! I got that same issue when I first started developing and using byebug, but didn't investigate further. I am pretty sure what I did was just starting the server in normal mode (without the -uflag) and it worked just right without having to install debugger.

Could you try that and let me know whether it works for you?

from byebug.

bitaxis avatar bitaxis commented on May 18, 2024

@deivid-rodriguez Yes. If I leave out the -u flag, then the error goes away, and I can still break into my code using byebug. I also verified that I can break into my code using the debugger gem also. Which begs the question, what is the -u flag for exactly?

Anyhow, I will close this ticket now. Thanks!

from byebug.

deivid-rodriguez avatar deivid-rodriguez commented on May 18, 2024

That's a good question. If I find out I will let you know! :)

from byebug.

deivid-rodriguez avatar deivid-rodriguez commented on May 18, 2024

Hi again @bitaxis! I investigated this today. Some answers:

what's the -u flag for exactly?

Starting the server in debugging mode allows you to have full stack information in your rails application. That means that the debugger is started when the server is started. If you don't use the debugging flag, the debugger will be started when the byebug or debugger call is issued inside your application, so you will only have debug information from that point on.
That's the reason why the first time you break into your code, if you issue the command where, the backtrace will only contain one entry, because byebug was just started. On the other hand, if you use the -u flag you will get full stack information from the beggining.

does the -u flag work with byebug?

No, it doesn't. Rails specifically requires and starts debugger (see here). To workaround this, you can monkeypatch rails by adding a file config/initializers/rack_byebug.rb (for example) to your app with the following contents:

module Rails
  module Rack
    class Debugger
      def initialize(app)
        @app = app

        # clear ARGV so that rails server options aren't passed to IRB
        ARGV.clear

        require 'byebug'

        ::Byebug.start
        puts "=> Byebug enabled"
      rescue LoadError
        puts "You're missing the 'byebug' gem. Add it to your Gemfile, bundle " \
               "it and try again."
        exit(1)
      end

      def call(env)
        @app.call(env)
      end
    end
  end
end

I will probably include a similar monkeypatch inside byebug but in the meantime this should work.

from byebug.

deivid-rodriguez avatar deivid-rodriguez commented on May 18, 2024

Since byebug 1.5.0 rails debugging flag is no longer necessary. Don't use it.

from byebug.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.