Closed jmuheim closed 10 years ago
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.
Thanks for at least thinking about it. :+1:
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
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 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.
@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. :)
try using gem pry-remote
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
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
?
I'm having this same issue as I'm upgrading from Rails 5 -> 6 🤔
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
):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.