Pry: Pry does not show code in Hanami's #call

Created on 8 Jul 2017  路  5Comments  路  Source: pry/pry

Trying to call binding.pry in a Hanami Interactor/Controller #call method results in nothing showing up and needing to use Ctrl+C to stop the execution of code. You can workaround this limitation by using:

module Web::Controllers::Home
  class Index
    include Web::Action

    def call(params)
      _call(params)
    end

    def _call(params)
      # Code that normally would go directly in #call and you need to debug
      binding.pry
    end
  end
end

As a test case, I prepared a small Hanami project showing the bug:

hanami_pry_bug.zip

The problematic code is in apps/web/controllers/home/index.rb, while the test is in spec/web/features/visit_home_spec.rb. You can reproduce the bug simply by running:

$ bundle install
$ HANAMI_ENV=test bundle exec hanami db prepare
$ bundle exec rake test

Tested with pry 0.10.4 and current master (commit 3743228846cda5cf3c90bda7ceb787ef71cfbaad), ruby 2.3.0 and hanami 1.0 (however it also occurs in older versions of hanami, like 0.9).

BTW, the problem does not seem related to Hanami, because https://github.com/deivid-rodriguez/byebug works.

Related issues: https://github.com/hanami/hanami/issues/205 and https://github.com/pry/pry/issues/1471

bug important

Most helpful comment

Hello! any progress on this?

All 5 comments

thanks for the zip, last two commands don't run ok for me:

$ HANAMI_ENV=test bundle exec hanami db prepare
bundler: failed to load command: hanami
Hanami::Model::MigrationError: Current adapter () doesn't support create.
$ bundle exec rake test
LoadError: cannot load such file -- sequel/adapters/ (Hanami::Model::Error)

Sorry, zip file was missing some dotfiles. Here is the correct one:

hanamy_pry_bug.zip

Hello! any progress on this?

confirmed https://github.com/pry/pry/pull/1689 fixes this for me using the sample app.

thanks @m45t3r

Was this page helpful?
0 / 5 - 0 ratings