Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

binding.pry doesn't work #24

Closed
jmuheim opened this issue Feb 28, 2014 · 10 comments
Closed

binding.pry doesn't work #24

jmuheim opened this issue Feb 28, 2014 · 10 comments

Comments

@jmuheim
Copy link

jmuheim commented Feb 28, 2014

When starting rails server on the console, I can add a binding.pry wherever I want it, hit reload, and then execution is halted at this line and I can interact with pry in the given context.

With Guard-Rails, this doesn't seem to work. The binding.pry is recognised, but simply omitted, which means that execution is continued without giving me the chance to interact with pry.

The output (which proves that binding.pry is recognised, see => 5: - binding.pry):


Frame number: 0/106

From: /Users/josh/Documents/Work/MuheimWebdesign/base/app/views/dashboards/show.html.slim @ line 5 ActionView::CompiledTemplates#_app_views_dashboards_show_html_slim__130432664906313828_70093845884840:

    1: h1
    2:   i.glyphicon.glyphicon-home
    3:   |Dashboards#show
    4: 
 => 5: - binding.pry

[1] base(#<#<Class:0x007f7ffd913c80>>) »  
  Rendered dashboards/show.html.slim within layouts/application (116.0ms)
  Rendered app/cells/mini_hub/show.html.slim (3.7ms)
Completed 200 OK in 255ms (Views: 230.1ms | ActiveRecord: 0.0ms)
  Rendered /Users/josh/.rvm/gems/ruby-2.0.0-p353@base/gems/xray-rails-0.1.12/app/views/_xray_bar.html.erb (8.8ms)
12:21:29 - INFO - Browser disconnected.
12:21:30 - INFO - Browser connected.
12:21:45 - INFO - Browser connected.

This question on stackoverflow asks the same, and is over a year old already:
http://stackoverflow.com/questions/14153585/guard-rails-not-providing-repl-for-binding-pry

It would be really useful to have the rails output and guard input in the same window, but without pry, I'm not able to do my work.

Thanks a lot for help.

@ranmocy
Copy link
Owner

ranmocy commented Mar 4, 2014

I can try to find how to do it.
But my first feeling is that it's not easy to do.
Because currently Guard-Rails start the rails process in a sub-process shell for capability.
And I can't join the process since that will block the whole guard process with other guard plugins.

If I do want to support binding.pry, I think I have to rewrite the whole runner to start the rails in ruby rather than in shell.
Which means it depends on how rails started and may potentially break some other gems of rails.

I think I have to study it and rethink again.

@jmuheim
Copy link
Author

jmuheim commented Mar 5, 2014

Thanks for at least thinking about it. 👍

@jmuheim
Copy link
Author

jmuheim commented Mar 19, 2014

For others facing this issue: I'm using the rerun gem now to achieve what I want. More infos here: http://stackoverflow.com/questions/22465596/tell-webrick-to-load-everything-restart-on-next-request-something-like-restar/22500887#22500887

@ranmocy
Copy link
Owner

ranmocy commented May 10, 2014

I peek into the rerun gem, it use thread and join which can't be use in guard-rails case.
That will block the whole guard.

https://github.com/alexch/rerun/blob/master/lib/rerun/runner.rb#L7

def self.keep_running(cmd, options)
  runner = new(cmd, options)
  runner.start
  runner.join
  # apparently runner doesn't keep running anymore (as of Listen 2) so we have to sleep forever :-(
  sleep 10000 while true  # :-(
end

I think this is impossible with guard system.

Reopen this if you have further idea.

@ranmocy ranmocy closed this as completed May 10, 2014
@gerrywastaken
Copy link

@ranmocy Can guard-rails at least output some sort of warning when it finds pry? At the moment there is no indication as to what is going wrong, the call is just skipped. I just spent a few hours trying to track down the issue and I imagine it will be the same for others.

@ranmocy
Copy link
Owner

ranmocy commented May 30, 2014

@gerrywastaken guard can only notice pry when user run in bundle exec guard, also user commonly can directly require pry when they want to use it (I did at least).
So, I'm lazy and just update the README. :)

@westonganger
Copy link

try using gem pry-remote

@atd
Copy link

atd commented Jan 4, 2019

For those who might be interested, I implemented a solution using pry-remote

https://github.com/atd/guard-rails

I don't care about blocking the whole guard process because I want to focus on debugging the code and I can live with handling file modifications after I exit pry-remote

@suranyami
Copy link

This issue doesn't seem to be a problem any more.

binding.pry works as expected using rails 5.x, ruby 2.4.

Should the documentation in the README.md?

@timolehto
Copy link

I'm having this same issue as I'm upgrading from Rails 5 -> 6 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants