Skip to content

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

@thiagokokada

Description

@thiagokokada

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 3743228), 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: hanami/hanami#205 and #1471

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions