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

pry-byebug not worked directly in $lOAD_PATH. #53

Closed
zw963 opened this issue Feb 12, 2015 · 25 comments
Closed

pry-byebug not worked directly in $lOAD_PATH. #53

zw963 opened this issue Feb 12, 2015 · 25 comments

Comments

@zw963
Copy link

zw963 commented Feb 12, 2015

Because some special reason, I use $LOAD_PATH directly. some gem is not manager by
gem, just directly put into $LOAD_PATH, make it work.

But, from 1.3.2 update to 3.0.1, it not worked for me.

/home/zw963/Dropbox/common/ruby/gems/looksee/core_ext.rb:17:in `method_missing': undefined method `commands' for Pry:Class (NoMethodError)
    from /home/zw963/Dropbox/common/ruby/gems/pry/commands/breakpoint.rb:218:in `<class:Pry>'
    from /home/zw963/Dropbox/common/ruby/gems/pry/commands/breakpoint.rb:9:in `<top (required)>'
    from /home/zw963/Dropbox/common/ruby/gems/pry/commands.rb:5:in `block in <top (required)>'
    from /home/zw963/Dropbox/common/ruby/gems/pry/commands.rb:4:in `each'
    from /home/zw963/Dropbox/common/ruby/gems/pry/commands.rb:4:in `<top (required)>'
    from /home/zw963/Dropbox/common/ruby/gems/pry.rb:145:in `<top (required)>'
    from /home/zw963/.rvm/gems/ruby-2.2.0@neil-rails-app/gems/pry-0.10.1/bin/pry:9:in `<top (required)>'
    from /home/zw963/.rvm/gems/ruby-2.2.0@neil-rails-app/bin/pry:23:in `load'
    from /home/zw963/.rvm/gems/ruby-2.2.0@neil-rails-app/bin/pry:23:in `<main>'
    from /home/zw963/.rvm/gems/ruby-2.2.0@neil-rails-app/bin/ruby_executable_hooks:15:in `eval'
    from /home/zw963/.rvm/gems/ruby-2.2.0@neil-rails-app/bin/ruby_executable_hooks:15:in `<main>'

it caused only by pry-byebug, byebug is work file.

Thanks.

@deivid-rodriguez
Copy link
Owner

@zw963 Sorry I missed this issue. Do you think you can try a pull request to fix this?

@zw963
Copy link
Author

zw963 commented Mar 9, 2015

OK, I will have a try to use Pry new API add command in.

@deivid-rodriguez
Copy link
Owner

Does this need a new command??

@zw963
Copy link
Author

zw963 commented Mar 12, 2015

I think should do so.

It seem like add breakpoint.rb and stepping.rb into pry gem commands directory, cause pry autoload those two commands failed. (when require 'pry')

pry use a new way to add commands in, so I thought should rewrite those two commands

But, I don't know why it worked when install as gem ...

@deivid-rodriguez
Copy link
Owner

Ah, ok, you're talking about rewriting the commands, not adding new ones.

@zw963
Copy link
Author

zw963 commented Mar 14, 2015

Hi, I try rewriting command with following gist, original error is fixed,
But still not worked, seem like Pry::Commands::helpers it not in effect.

from wiki, I got this:

  # You can define your own private helper methods for this command. If you want
  # to share helpers, then define them using Pry::Commands.helpers{ def foo; end }
  # instead.

But it not worked for me.

(pry):0> next
NoMethodError: undefined method `breakout_navigation' for #<Pry::Command::Next:0x00000002e34bb0>

breakpoint.rb
https://gist.github.com/ebc8f60cf864c61d0d69

stepping.rb
https://gist.github.com/5ae49e1dd304eb586f55

I am missing too much pry context, what I can do is just this, sorry.

@zw963
Copy link
Author

zw963 commented Mar 14, 2015

I make a new issue for Pry::Commands.helpers.

link here: pry/pry#1396

@deivid-rodriguez
Copy link
Owner

@zw963 Thanks for your help and effort. I understand you might want to give up trying but I'd like to ask for a pleasure:

  • Could you correct the links to the gists? Ideally, they could be in patch format so I can easily see what are the changes you added to pry-byebug.
  • Could you link to the issue you opened in pry?

This will help me a lot when I work on this issue to see where you left it and be able to reuse your work.

@zw963
Copy link
Author

zw963 commented Mar 16, 2015

I update commit. : )

@deivid-rodriguez
Copy link
Owner

I saw that you updated the commit, thanks!

@zw963
Copy link
Author

zw963 commented Apr 2, 2015

I add a new pull request for this, seem like it worked : )

#59

@zw963
Copy link
Author

zw963 commented Apr 4, 2015

I update to pry-byebug 3.1.0, and remove unrelated gems affect, the finally backtrace output like this:

/home/zw963/Dropbox/common/ruby/gems/pry/commands/breakpoint.rb:215:in `<class:Pry>': undefined method `commands' for Pry:Class (NoMethodError)
    from /home/zw963/Dropbox/common/ruby/gems/pry/commands/breakpoint.rb:8:in `<top (required)>'
    from /home/zw963/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
    from /home/zw963/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
    from /home/zw963/Dropbox/common/ruby/gems/pry/commands.rb:5:in `block in <top (required)>'
    from /home/zw963/Dropbox/common/ruby/gems/pry/commands.rb:4:in `each'
    from /home/zw963/Dropbox/common/ruby/gems/pry/commands.rb:4:in `<top (required)>'
    from /home/zw963/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
    from /home/zw963/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
    from /home/zw963/Dropbox/common/ruby/gems/pry.rb:145:in `<top (required)>'
    from /home/zw963/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
    from /home/zw963/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
    from /home/zw963/Dropbox/common/ruby/gems/bin/pry:9:in `<main>'

What I does is simple enough, I setting environment variable RUBYLIB=/home/zw963/Dropbox/common/ruby/gems, and put pry-byebug, byebug, pry etc .. gems files inside lib into $RUBYLIB, it work fine for me
with much gems and earlier version pry-byebug, But it not work any more since update to pry-byebug 3.xx.

Could you give me a clue about how to fix this? (and no need rewrite command.)

@deivid-rodriguez
Copy link
Owner

Thanks @zw963, I'll have a look when I can.

@deivid-rodriguez
Copy link
Owner

@zw963 This should be fixed in latest master. Could you please confirm?

@zw963
Copy link
Author

zw963 commented May 18, 2015

It seem fix in newest github version, currently, pry can load successfully.

but, it seem like cause another problems.

binding.pry is not worked for me.

#!/usr/bin/env ruby

require 'pry'
binding.pry

run this file, nothing happen. binding.pry is not intercept.

binding.of_caller is not worked for me.

when I use binding.of_caller(2).pry, it not position me to correct place.

    196:       end
    197:     else
    198:       warn "loading pry ..."
    199:       binding.of_caller(2).pry
    200:     end
 => 201:   end

the corrent position is:

    1: #!/usr/bin/env ruby
    2: 
 => 3: pry!

the trace to code is here:

https://github.com/zw963/ass/blob/master/common/ruby/lib/addition.rb#L197

@zw963
Copy link
Author

zw963 commented May 18, 2015

pry-byebug version: ca01c53

byebug: 4.0.5, this version worked with old version pry-byebug, so, it seem like
caused by HEAD version pry-byebug.

Thank very much!

@deivid-rodriguez
Copy link
Owner

@zw963 Could you explain better the new issue? Notice that due to #45, if binding.pry is the last line of your program, you will not get a debugging prompt.

@zw963
Copy link
Author

zw963 commented May 19, 2015

Hi, I only could give some clue for this, and I will try reproduce possibly bugs about this:

position location error.

   $ cat test1.rb
     1  #!/usr/bin/env ruby
     2  
     3  require 'pry-byebug'
     4  binding.pry
     5  puts 'hello'
     6  

☠ $ ruby test1.rb

Frame number: 0/6

From: /home/zw963/Dropbox/common/code/ruby/test1.rb @ line 5 :

    1: #!/usr/bin/env ruby
    2: 
    3: require 'pry-byebug'
    4: binding.pry
 => 5: puts 'hello'

(pry):0>

If change to require pry, it worked.

   $ ruby test1.rb

Frame number: 0/0

From: /home/zw963/Dropbox/common/code/ruby/test1.rb @ line 4 :

    1: #!/usr/bin/env ruby
    2: 
    3: require 'pry'
 => 4: binding.pry
    5: puts 'hello'

(pry):0>

Use binding_of_caller gems can reproduce the same bug:

   $ cat test1.rb
     1  #!/usr/bin/env ruby
     2  
     3  require 'binding_of_caller'
     4  
     5  def pry!
     6    require 'pry-byebug'
     7    binding.of_caller(1).pry
     8  end
     9  
    10  pry!
    11  puts 'hello'
    12
   $ ruby test1.rb

Frame number: 0/7

From: /home/zw963/Dropbox/common/code/ruby/test1.rb @ line 8 Object#pry!:

    5: def pry!
    6:   require 'pry-byebug'
    7:   binding.of_caller(1).pry
 => 8: end

(pry):0> 

If change require 'pry-byebug' to require 'pry'.

   $ ruby test1.rb

Frame number: 0/1
Frame type: main

From: /home/zw963/Dropbox/common/code/ruby/test1.rb @ line 10 :

     5: def pry!
     6:   require 'pry'
     7:   binding.of_caller(1).pry
     8: end
     9: 
 => 10: pry!
    11: puts 'hello'

(pry):0

binding.pry is not worked for me.

this seem like fix, it seem like cause by myself (public gems conflict with project gems)
But above is tested in rvm @global gemset, I thought it should reproduce simply.

Others clue:

 ☠  $ gem list

*** LOCAL GEMS ***

bigdecimal (1.2.6)
bundler (1.7.13)
bundler-unload (1.0.2)
executable-hooks (1.3.2)
gem-wrappers (1.2.7)
io-console (0.4.3)
json (1.8.1)
minitest (5.4.3)
power_assert (0.2.2)
psych (2.0.8)
rake (10.4.2)
rdoc (4.2.0)
rubygems-bundler (1.4.4)
rvm (1.11.3.9)
test-unit (3.0.8)

$RUBYOPT is not set.

$RUBYLIB is /home/zw963/Dropbox/common/ruby/lib:/home/zw963/Dropbox/common/ruby/gems

IN my /home/zw963/Dropbox/common/ruby/gems, exist bunch of my favorite gems, some binary dependency compile for difference ruby version, I only copy byebug 4.0.5 lib/* && newest pry-byebug lib/* into this directory. ($LOAD_PATH)

@zw963
Copy link
Author

zw963 commented May 19, 2015

The above possible bug not found at: pry-byebug 1.3.3, I use this until now.
Though it is not support pry-remote good.
So i have to use two combination for difference situation:

  • for local debug: (pry-byebug + byebug)
  • for remote/background debug: pry_nav + pr_remote

I address this with write a pry! wrapper method, although I really want to
wipe out pry_nav from my code.

@deivid-rodriguez
Copy link
Owner

@zw963 The "position location error" is not a bug, but a feature. The marker position was changed in 2.0 to be the first line after binding.pry and not binding.pry itself. All your pry evaluations stay the same (the actual position in the source code does not change, just the marker), but you don't need to type an extra next if you want to use pry-byebug features and navigate your source code.

Regarding the $LOAD_PATH, $RUBYLIB and so on. I did not really understand what you are saying. It is actually fixed, right?

And regarding your last message, I encourage you to work on pry-remote support!

@zw963
Copy link
Author

zw963 commented May 21, 2015

Thank you for clarify.

before change to 2.0, I use this wrapper method skip to upper frame.

def pry!
  require 'pry-byebug'
  upper_frame_binding = binding.of_caller(1);
  upper_frame_binding.pry
end

in version 2.x, marker stop at error position.

Frame number: 0/7

From: /home/zw963/Dropbox/common/code/ruby/test1.rb @ line 9 Object#pry!:

    5: def pry!
    6:   require 'pry-byebug'
    7:   upper_frame_binding = binding.of_caller(1);
    8:   upper_frame_binding.pry
 => 9: end

if it worked, I think it should stop at here ?

Frame number: 0/1
Frame type: main

From: /home/zw963/Dropbox/common/code/ruby/test1.rb @ line 11 :

     6:   require 'pry-byebug'
     7:   upper_frame_binding = binding.of_caller(1);
     8:   upper_frame_binding.pry
     9: end
    10: 
    11: pry!
=>12: puts 'hello'

(pry):0> 

How should I resolve this?
I thought this is a bigger change not compatible with pry, will maybe cause
some problems about pry relation gems. perhaps if use byebug command directly, should import this feature.

@deivid-rodriguez
Copy link
Owner

I agree that is unexpected behaviour and the previuos one was better. I'll have a look at it when I can.

But I wonder why you're using that in the first place. Your calling binding.pry inside a method and want pry to skip the method and land outside of it. Why not just dropping that method and just calling binding.pry outside? What's the use case?

@zw963
Copy link
Author

zw963 commented May 22, 2015

hehe, just more less typing, and can wrap more logic in wrapper method.

e.g.
I can detect ruby version, environment variable, to decide use byebug or debugger
or any others specify version gem, and any logic i want to add.

Thank you.

@zw963
Copy link
Author

zw963 commented Sep 15, 2015

I don't want to add a new issue for following.

If can, could you add a toggle to allow disable start at pry at next line.

it work not well with binding.of_caller, I use pry-byebug so long, but keep still use 1.3.3,
it work perfect for me. (it awesome, so old still work file), although byebug is update to 5.0.

@zw963
Copy link
Author

zw963 commented Sep 15, 2015

If need, I can add a new feature request for this. Thanks.

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

2 participants