How to use Byebug with a remote process (e.g., pow)

Joseph Siefers picture Joseph Siefers · Apr 1, 2014 · Viewed 11.2k times · Source

How do I connect to a remote debugging instance of Byebug (for use with Pow, etc)?

Answer

Nick Gronow picture Nick Gronow · Sep 13, 2014

Joseph's answer was good but confusing in some small ways. He places the starting of the byebug server in config/environments/development.rb, when it would be better in an initializer. Additionally the exporting of the environment variable go in .powenv or .powrc. This is how I got it to work.

In your gemfile:

gem 'byebug'

On the command line:

bundle install

If you are using Pow, add the following to .powenv:

export BYEBUGPORT=3001

If you are using other frameworks (e.g. just foreman), you may have to modify .env instead.

In config/initializers/byebug.rb

if Rails.env.development? and ENV['BYEBUGPORT']
  require 'byebug/core'
  Byebug.start_server 'localhost', ENV['BYEBUGPORT'].to_i
end

And finally on the command line:

touch tmp/restart.txt

Once you go to your pow site, the byebug server should be started. On the command line you can now do:

[bundle exec] byebug -R localhost:3001