Anyone else experiencing problems with reloads for 'edit-method' and command line vim ?
It doesn't seem to reload the code after editing (:wq), only after another edit-method (so it looks like vim is handing back control to pry immediately after loading the file, and pry loads the unchanged module, rather than the changed one after save/quit).
After editing the file in vim and exiting type load _file_ or reload-method Your#method_name to manually reload the file. (where _file_ is a special local representing the last file accessed by Pry)
It should mostly work fine in 1.8.7 MRI and 1.8.7 RBX; i even backported Proc#source_location and Method#source_location so show-method and show-doc should work too, the only thing that doesnt work in 1.8.7 is source retrieval of methods defined inside the REPL; but it should be relatively rare you'd do this (i hope) :)
I have to admit I was disappointed when I saw the topic for this week's railscast. The name and description just weren't what I was hoping for. Each week I look forward to learning a new way to use ruby/rails to solve problems by writing code. Pry was just a replacement for irb "UGH".
THEN . . . I watched it.
Wow. Thank you, Ryan. I'm betting that in less than a week, Pry will have saved me hours worth of time.
Lesson learned: Never judge Ryan's screencasts before watching them.
WOW !!!!! been using this the whole day.....this is freaking awesome. Just tested it with RC6 rails and Sinatra...I think this is the best day of this month !
If i try
IRB = Pry
I get this:
ruby-1.8.7-p334/lib/ruby/1.8/irb/workspace.rb:19:in initialize': undefined methodconf' for Pry:Class (NoMethodError)
from /Users/dragos/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/1.8/irb/context.rb:27:in new'
from /Users/dragos/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/1.8/irb/context.rb:27:ininitialize'
from /Users/dragos/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/1.8/irb.rb:100:in new'
from /Users/dragos/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/1.8/irb.rb:100:ininitialize'
from /Users/dragos/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/1.8/irb.rb:59:in new'
from /Users/dragos/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/1.8/irb.rb:59:instart'
from /Users/dragos/.rvm/rubies/ruby-1.8.7-p334/bin/irb:17
could u solved this problem? when i run '$irb' ,give me a message 'Unable to load pry', when i run '$require 'pry'' i got
"LoadError: no such file to load -- pry
from (irb):1:in `require'
from (irb):1
"
how could i fix it how could i use pry instead rib
could u solved this problem? when i run '$irb' ,give me a message 'Unable to load pry', when i run '$require 'pry'' i got
"LoadError: no such file to load -- pry
from (irb):1:in `require'
from (irb):1
"
how could i fix it how could i use pry instead rib
Couldn't be more getting Pry right away: am running win764 bit, for some reason, I never can get color highlighting to work ANYWHERE; not even with a freshly installed system following every guide to the dot. If anyone here knows, please please enlighten.
Thank you! I took Pry for a spin several weeks ago but didn't take the time to fully explore getting Hirb working so I haven't been using it for Rails' console. I think I will now :-)
cldwalker is probably opinionated about Ripl, but I'll ask if he'll accept a patch to Hirb for built-in Pry support.
Edit: Just found this issue where he indeed says he doesn't want to support more shells in the gem itself (and you guys originally shared this .pryrc snippet =]).
I use binding.pry to break the app (start webrick with --debugger) but couldn't find how to step or next at the Pry prompt, though I can 'exit' to let the app continue. Is there anyway to have Pry work with ruby-debug?
Another thing i would like to do would be to bring ruby-debug commands into Pry itself, rather than having to use Pry from inside ruby-debug. This will be a task for the future (but should not be too difficult).
Also one thing I notice is that when using guard with rspec whenever I add a "binding.pry" line, the specs of course pause on that line. Would there be a way to avoid this? Well I guess I can always use...
It's hackish because it is a hack :) it's just a quick solution provided by a contributor to a specific issue -- remote sessions will be officially supported in a future version, but for now, this hack is ok, right? :)
I'm sorry i can't help you with your testing issue as i don't use RSpec :(
cool cool! I get it's a temp hack, sorry to sound so eager. Really excited about it I guess. =) And yes, it does work for the time being.
Regarding my RSpec "issue", I guess it's more of a situation that everyone who runs any sort of autotest suite runs into.. the moment you insert a debug hook in the code, the automated tests kick in because you save the file, and they fire the hook.
Thank you for such a wonderful screencast. Personally, I still feel the way may Rails developer debug their code is still elementary. Although you may be using debugger or even a Pry, it is still obtrusive, meaning you have directly insert lines into your code like debugger or binding.pry which is a very inefficient way.
Rails developers should start switching to IDEs already.
I have to agree with @EnricoCarlesso I would like to understand if there is a way to run Pry with Foreman. It seems that it works okay except you cannot see your input when running a web worker plus regular cron-esque worker. I set the unicorn web workers down to 1 so that it wouldn't conflict in that regard, but still the input is an issue.
As a general question Ryan, do you rehearse these until you can get them in one session or do you do a lot of edits. Just curious.
Or maybe you are just that good at it?
Either way tanks! Oops! Do you have a screen-cast showing how to use the new Rails4 error console?
Anyone else experiencing problems with reloads for 'edit-method' and command line vim ?
It doesn't seem to reload the code after editing (:wq), only after another edit-method (so it looks like vim is handing back control to pry immediately after loading the file, and pry loads the unchanged module, rather than the changed one after save/quit).
Works with nano, though.
After editing the file in vim and exiting type
load _file_
orreload-method Your#method_name
to manually reload the file. (where_file_
is a special local representing the last file accessed by Pry)Another great discovery Ryan! Do you know if Pry works with Ruby 1.8.7 or is it just for Ruby 1.9?
It should mostly work fine in 1.8.7 MRI and 1.8.7 RBX; i even backported Proc#source_location and Method#source_location so
show-method
andshow-doc
should work too, the only thing that doesnt work in 1.8.7 is source retrieval of methods defined inside the REPL; but it should be relatively rare you'd do this (i hope) :)Joshua Cheek's screeencast is also worth seeing, and includes a neater way to use Pry as IRB replacement for the rails console:
Simply add the following lines at the end of your config/environments/development.rb file, after the
YourAppName::Application.configure
block:And no more need to use the longer
pry -r config/environment
to start the console: simply use the usualrails console
/rails c
command.Great Tip! THX!
It is also worth noting that for this to work
gem 'pry'
must be in yourGemfile
.thank you Ryan!
finally a tool to see the source code of a method definition!
That was really a feature I missed from Lisp..
Is anyone using Pry with Rails 3.1 RC5/RC6?
Thanks.
Bharat
I just set it up using RC6, it seems to be working just fine, is that not the case for you?
Hello Ken,
Haven't tried yet. Thanks for letting me know. I will install it now.
I have to admit I was disappointed when I saw the topic for this week's railscast. The name and description just weren't what I was hoping for. Each week I look forward to learning a new way to use ruby/rails to solve problems by writing code. Pry was just a replacement for irb "UGH".
THEN . . . I watched it.
Wow. Thank you, Ryan. I'm betting that in less than a week, Pry will have saved me hours worth of time.
Lesson learned: Never judge Ryan's screencasts before watching them.
WOW !!!!! been using this the whole day.....this is freaking awesome. Just tested it with RC6 rails and Sinatra...I think this is the best day of this month !
Any way to replace the console with pry in 2.3.8 when you run
???
Yes, here is how to replace the rails console with pry
For those that don't like to click links:
If i try
IRB = Pry
I get this:
ruby-1.8.7-p334/lib/ruby/1.8/irb/workspace.rb:19:in
initialize': undefined method
conf' for Pry:Class (NoMethodError)from /Users/dragos/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/1.8/irb/context.rb:27:in
new'
initialize'from /Users/dragos/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/1.8/irb/context.rb:27:in
from /Users/dragos/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/1.8/irb.rb:100:in
new'
initialize'from /Users/dragos/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/1.8/irb.rb:100:in
from /Users/dragos/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/1.8/irb.rb:59:in
new'
start'from /Users/dragos/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/1.8/irb.rb:59:in
from /Users/dragos/.rvm/rubies/ruby-1.8.7-p334/bin/irb:17
could u solved this problem? when i run '$irb' ,give me a message 'Unable to load pry', when i run '$require 'pry'' i got
"LoadError: no such file to load -- pry
from (irb):1:in `require'
from (irb):1
"
how could i fix it how could i use pry instead rib
could u solved this problem? when i run '$irb' ,give me a message 'Unable to load pry', when i run '$require 'pry'' i got
"LoadError: no such file to load -- pry
from (irb):1:in `require'
from (irb):1
"
how could i fix it how could i use pry instead rib
could u solved this problem? i didn't resolve, could u tell me, how can i do?
bye rails console
Couldn't be more getting Pry right away: am running win764 bit, for some reason, I never can get color highlighting to work ANYWHERE; not even with a freshly installed system following every guide to the dot. If anyone here knows, please please enlighten.
I once got some colorful working with ansicon and those .irbrc . Some more fiddling may be required, hope that helps, Frank
Thanks for the the great RailsCast, Ryan - as always.
Has anyone figured out if it's possible to use 'binding.pry' for debugging if you're using Apache/Passenger rather than the built-in server?
I just realized it's why it's not stopping. I had moved to passenger. Did you find the solution?
Can you report this as an issue on https://github.com/pry/pry/issues with an exact explanation of your problem ?
Is there a way to reload the environment like
reload! from IRB ?
You can just type
reload!
in Pry as you are used toIs there any way to let methods like "show-method, edit, etc." use vim without binding to default editor?
you can set the environment variable
$EDITOR
in your shell instead and Pry will use that. Why do you want to avoid settingPry.config.editor
btw?I like vim but my colleagues not loving it and i can't use it as default on common server. But when i run pry $EDITOR=vim it still use nano =(
For Windows users, the amazing reloading mechanism on
edit-method
works fine when using GVIM andset EDITOR=vim
Thanks for the great screencast.
For those who wish to use Hirb with Pry add the following to your ~/.pryrb file
Thank you! I took Pry for a spin several weeks ago but didn't take the time to fully explore getting Hirb working so I haven't been using it for Rails' console. I think I will now :-)
I added a dirty
instance_eval
hack to makeHirb.disable/enable
work in-session:https://gist.github.com/1177892
cldwalker is probably opinionated about Ripl, but I'll ask if he'll accept a patch to Hirb for built-in Pry support.
Edit: Just found this issue where he indeed says he doesn't want to support more shells in the gem itself (and you guys originally shared this
.pryrc
snippet =]).I use
binding.pry
to break the app (start webrick with --debugger) but couldn't find how tostep
ornext
at the Pry prompt, though I can 'exit' to let the app continue. Is there anyway to have Pry work with ruby-debug?A few options at present:
https://github.com/AndrewO/ruby-debug-pry
Also you may be interested in:
https://github.com/mon-ouie/pry_debug
Another thing i would like to do would be to bring ruby-debug commands into Pry itself, rather than having to use Pry from inside ruby-debug. This will be a task for the future (but should not be too difficult).
How to use pry_debug in a rake file?
Has anyone had any success with using the "binding.pry" feature with Pow?
try this and let me know how you get on: https://github.com/mon-ouie/pry-remote
irb + rails debugger =pry...awesome.. makes life much easier..!
Is there a way to use Pry with Foreman?
check out https://github.com/mon-ouie/pry-remote
use
binding.pry_remote
in your code, andand then from another terminal
pry-remote
to connectYeah would be nice to run with Pow if possible. Any clues?
Hi, read the solution given in the following issue: https://github.com/pry/pry/issues/237
Let me know how you get on!
Hi John. It does work. Feels a bit hackish thou.
Also one thing I notice is that when using guard with rspec whenever I add a "binding.pry" line, the specs of course pause on that line. Would there be a way to avoid this? Well I guess I can always use...
It's hackish because it is a hack :) it's just a quick solution provided by a contributor to a specific issue -- remote sessions will be officially supported in a future version, but for now, this hack is ok, right? :)
I'm sorry i can't help you with your testing issue as i don't use RSpec :(
goodluck and i hope you like pry :)
cool cool! I get it's a temp hack, sorry to sound so eager. Really excited about it I guess. =) And yes, it does work for the time being.
Regarding my RSpec "issue", I guess it's more of a situation that everyone who runs any sort of autotest suite runs into.. the moment you insert a debug hook in the code, the automated tests kick in because you save the file, and they fire the hook.
I really do enjoy using Pry! thank you. =)
Looks like the
pry-remote
plugin may have been officially released now, try it and tell me if it's ok: https://github.com/mon-ouie/pry-remoteJust tried the
pry-remote
plugin with pow, and so far it works great.This is actually a feature, you can use binding.pry to troubleshoot why tests fail, I even did:
...but binding pry stopped working for me a week ago in tests, now it's throwing a
NoMethodError: undefined method
activate!' for nil:NilClass`update: bundle update fixed binding.pry in tests
Thank you for such a wonderful screencast. Personally, I still feel the way may Rails developer debug their code is still elementary. Although you may be using debugger or even a Pry, it is still obtrusive, meaning you have directly insert lines into your code like debugger or binding.pry which is a very inefficient way.
Rails developers should start switching to IDEs already.
I have to agree with @EnricoCarlesso I would like to understand if there is a way to run Pry with Foreman. It seems that it works okay except you cannot see your input when running a web worker plus regular cron-esque worker. I set the unicorn web workers down to 1 so that it wouldn't conflict in that regard, but still the input is an issue.
You can use the pry-rails gem to automatically use pry as the Rails console.
How to use pry_debug in a rake file?
Great screencast! Could definitely benefit from an update that uses the pry-rails gem.
I think it's not convenient to debug in action of rails, because there's no list, step, next method, while we can't call an action directly.
use pry-debugger plugin
As a general question Ryan, do you rehearse these until you can get them in one session or do you do a lot of edits. Just curious.
Or maybe you are just that good at it?
Either way tanks! Oops! Do you have a screen-cast showing how to use the new Rails4 error console?
why is this present here?