Skip to content

Support rdbg #158

Closed
Closed

Description

@link0ff

Ruby 3.1 added the bundled debugger that is activated either by the command rdbg or by adding a breakpoint with binding.break. But in any case the prompt displays the triangle character in the comint buffer and hangs. To support it, there is a need to set the environment variable RUBY_DEBUG_NO_RELINE. For example, the following code works ok:

(let ((process-environment (copy-sequence process-environment)))
  (setenv "RUBY_DEBUG_NO_RELINE" "true")
  (inf-ruby-console-run "rdbg -c -- bundle exec rails server" "rdbg"))

BTW, in some places inf-ruby.el modifies the environment without making its copy with (copy-sequence process-environment), so the environment is changed globally in those place (don't know if this is intentional).

Also for more support of rdbg, all places that mention another debugger rdb, could also add rdbg.

Activity

  1. dgutov commented on Jan 19, 2022

    @dgutov
    Collaborator

    BTW, in some places inf-ruby.el modifies the environment without making its copy with (copy-sequence process-environment), so the environment is changed globally in those place (don't know if this is intentional).

    Good catch. We do call setenv in one place (as opposed to changing process-environment immutably in another), and that one should use copy-sequence.

    We can add the new setenv call to run-ruby-new as well.

    Will that be enough? E.g. the case with binding.break will probably usually happen in the middle of an RSpec run. Those are lanuched by code not controlled by inf-ruby. Though I suppose we can also add something like the above to rspec-mode.

  2. link0ff commented on Jan 19, 2022

    @link0ff
    Author

    An alternative to setting env.variable RUBY_DEBUG_NO_RELINE is to add such line to ~/.rdbgrc:

    config set no_reline true
    

    Maybe this could be mentioned in README. But after trying to add this line and running RSpec, it prints to stdout:

    # (rdbg:~/.rdbgrc) config set no_reline true
    # no_reline = true               # UI: Do not use Reline library (default: false)
    

    but still shows the triangle and hangs, I don't know why. But env.variable still helps in any case.

  3. dgutov commented on Jan 21, 2022

    @dgutov
    Collaborator

    ... but still shows the triangle and hangs

    That's unfortunate.

    But if not running RSpec, what is the main scenario .rdbgrc does fix? Putting a breakpoint somewhere inside the code and then running rails server to trigger it?

    But env.variable still helps in any case.

    Env variable when running RSpec?

  4. link0ff commented on Jan 31, 2022

    @link0ff
    Author

    But if not running RSpec, what is the main scenario .rdbgrc does fix? Putting a breakpoint somewhere inside the code and then running rails server to trigger it?

    Right, the main scenario is a breakpoint with running rails server.
    But config set no_reline true in .rdbgrc still has no effect,
    maybe because it's too late at this point to disable reline
    when the debugger was already started.

    But env.variable still helps in any case.

    Env variable when running RSpec?

    Env variable helps in all cases: in RSpec, in rails server, etc.

  5. dgutov commented on Feb 3, 2022

    @dgutov
    Collaborator

    Please check that it works for you now.

    And I'll try to put a similar fix in rspec-mode.

  6. added a commit that references this issue on Feb 3, 2022
  7. link0ff commented on Feb 8, 2022

    @link0ff
    Author

    Thanks for the fix. I confirm it's working nicely now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions