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

Already on GitHub? Sign in to your account

Show-source should error out on engines not MRI or Rubinius #890

Closed
berdario opened this Issue Mar 28, 2013 · 15 comments

Comments

Projects
None yet
5 participants

This is what I get from running pry under jruby:

before_session hook failed: Errno::ENOENT: No such file or directory - /home/dario/Projects/jruby
org/jruby/RubyFile.java:333:in `initialize'
(see _pry_.hooks.errors to debug)
[1] pry(main)> RUBY_ENGINE
=> "jruby"
[2] pry(main)> show-method caller

From: vm_eval.c (C Method):
Owner: Kernel
Visibility: private
Number of lines: 17

static VALUE
rb_f_caller(int argc, VALUE *argv)
{
    VALUE level;
    int lev;

    rb_scan_args(argc, argv, "01", &level);

    if (NIL_P(level))
    lev = 1;
    else
    lev = NUM2INT(level);
    if (lev < 0)
    rb_raise(rb_eArgError, "negative level (%d)", lev);

    return vm_backtrace(GET_THREAD(), lev);
}
[3] pry(main)> 

this is what's inside pry.hooks.errors if I run it from my $HOME

before_session hook failed: Errno::ENOENT: No such file or directory - /home/dario
org/jruby/RubyFile.java:333:in `initialize'
(see _pry_.hooks.errors to debug)
[1] pry(main)> _pry_.hooks.errors.inspect
=> "[#<Errno::ENOENT: No such file or directory - /home/dario>]"

SFEley commented Apr 20, 2013

I'm seeing this too when running Guard under JRuby. There's a Stack Overflow question with an answer encouraging people to file a bug with Pry for this.

Conditions:

  • JRuby 1.7.3
  • Guard 1.7.0
  • Pry 0.9.12

After any RSpec run using either guard-rspec-jruby or guard-jruby-rspec (yes they're two different gems), I get this:

16:58:39 - INFO - Guard is now watching at '/Users/Steve/cg/steward'
before_session hook failed: Errno::ENOENT: No such file or directory - /Users/Steve/cg/steward
/Users/Steve/.rbenv/versions/jruby-1.7.3/lib/ruby/gems/shared/gems/pry-0.9.12-java/lib/pry/method/weird_method_locator.rb:175:in `readlines'
(see _pry_.hooks.errors to debug)

Here's the exception:

[3] guard(main)> _pry_.hooks.errors.first
=> #<Errno::ENOENT: No such file or directory - /Users/Steve/cg/steward>

...and the backtrace:

[4] guard(main)> _pry_.hooks.errors.first.backtrace
=> ["/Users/Steve/.rbenv/versions/jruby-1.7.3/lib/ruby/gems/shared/gems/pry-0.9.12-java/lib/pry/method/weird_method_locator.rb:175:in `readlines'",
 "/Users/Steve/.rbenv/versions/jruby-1.7.3/lib/ruby/gems/shared/gems/pry-0.9.12-java/lib/pry/method/weird_method_locator.rb:175:in `lines_for_file'",
 "/Users/Steve/.rbenv/versions/jruby-1.7.3/lib/ruby/gems/shared/gems/pry-0.9.12-java/lib/pry/method/weird_method_locator.rb:153:in `renamed_method_source_location'",
 "/Users/Steve/.rbenv/versions/jruby-1.7.3/lib/ruby/gems/shared/gems/pry-0.9.12-java/lib/pry/method/weird_method_locator.rb:127:in `find_renamed_method'",
 "/Users/Steve/.rbenv/versions/jruby-1.7.3/lib/ruby/gems/shared/gems/pry-0.9.12-java/lib/pry/method/weird_method_locator.rb:126:in `find'",
 "/Users/Steve/.rbenv/versions/jruby-1.7.3/lib/ruby/gems/shared/gems/pry-0.9.12-java/lib/pry/method/weird_method_locator.rb:126:in `find_renamed_method'",
 "/Users/Steve/.rbenv/versions/jruby-1.7.3/lib/ruby/gems/shared/gems/pry-0.9.12-java/lib/pry/method/weird_method_locator.rb:52:in `get_method'",
 "/Users/Steve/.rbenv/versions/jruby-1.7.3/lib/ruby/gems/shared/gems/pry-0.9.12-java/lib/pry/method.rb:89:in `from_binding'",
 "/Users/Steve/.rbenv/versions/jruby-1.7.3/lib/ruby/gems/shared/gems/pry-0.9.12-java/lib/pry/commands/whereami.rb:37:in `setup'",
 "/Users/Steve/.rbenv/versions/jruby-1.7.3/lib/ruby/gems/shared/gems/pry-0.9.12-java/lib/pry/command.rb:570:in `call'",
 "/Users/Steve/.rbenv/versions/jruby-1.7.3/lib/ruby/gems/shared/gems/pry-0.9.12-java/lib/pry/command.rb:453:in `call_with_hooks'",
 "/Users/Steve/.rbenv/versions/jruby-1.7.3/lib/ruby/gems/shared/gems/pry-0.9.12-java/lib/pry/command.rb:426:in `call_safely'",
 "/Users/Steve/.rbenv/versions/jruby-1.7.3/lib/ruby/gems/shared/gems/pry-0.9.12-java/lib/pry/command.rb:368:in `process_line'",
 "/Users/Steve/.rbenv/versions/jruby-1.7.3/lib/ruby/gems/shared/gems/pry-0.9.12-java/lib/pry/command_set.rb:350:in `process_line'",
 "/Users/Steve/.rbenv/versions/jruby-1.7.3/lib/ruby/gems/shared/gems/pry-0.9.12-java/lib/pry/pry_instance.rb:477:in `run_command'",
 "/Users/Steve/.rbenv/versions/jruby-1.7.3/lib/ruby/gems/shared/gems/pry-0.9.12-java/lib/pry.rb:13:in `Pry'",
 "/Users/Steve/.rbenv/versions/jruby-1.7.3/lib/ruby/gems/shared/gems/pry-0.9.12-java/lib/pry/hooks.rb:154:in `call'",
 "/Users/Steve/.rbenv/versions/jruby-1.7.3/lib/ruby/gems/shared/gems/pry-0.9.12-java/lib/pry/hooks.rb:154:in `exec_hook'",
 "/Users/Steve/.rbenv/versions/jruby-1.7.3/lib/ruby/gems/shared/gems/pry-0.9.12-java/lib/pry/hooks.rb:152:in `map'",
 "/Users/Steve/.rbenv/versions/jruby-1.7.3/lib/ruby/gems/shared/gems/pry-0.9.12-java/lib/pry/hooks.rb:152:in `exec_hook'",
 "/Users/Steve/.rbenv/versions/jruby-1.7.3/lib/ruby/gems/shared/gems/pry-0.9.12-java/lib/pry/helpers/base_helpers.rb:12:in `silence_warnings'",
 "/Users/Steve/.rbenv/versions/jruby-1.7.3/lib/ruby/gems/shared/gems/pry-0.9.12-java/lib/pry/hooks.rb:151:in `exec_hook'",
 "/Users/Steve/.rbenv/versions/jruby-1.7.3/lib/ruby/gems/shared/gems/pry-0.9.12-java/lib/pry/pry_instance.rb:496:in `exec_hook'",
 "/Users/Steve/.rbenv/versions/jruby-1.7.3/lib/ruby/gems/shared/gems/pry-0.9.12-java/lib/pry/pry_instance.rb:199:in `repl_prologue'",
 "/Users/Steve/.rbenv/versions/jruby-1.7.3/lib/ruby/gems/shared/gems/pry-0.9.12-java/lib/pry/pry_instance.rb:227:in `repl'",
 "/Users/Steve/.rbenv/versions/jruby-1.7.3/lib/ruby/gems/shared/gems/pry-0.9.12-java/lib/pry/pry_class.rb:170:in `start'",
 "/Users/Steve/.rbenv/versions/jruby-1.7.3/lib/ruby/gems/shared/gems/guard-1.7.0/lib/guard/interactor.rb:241:in `start'"]

Disabling Pry (with interactor :off in my Guardfile) removes the error, but also cripples Guard. As far as I can tell this error isn't affecting the core purpose of Guard; test runs are still running on file changes. It's just annoying, and I thought I'd give details in case they were helpful.

Owner

banister commented Apr 20, 2013

ah, this is actually fixed on HEAD we just have yet to do a release. I can probably push a patch release tonight that just contains this fix. Sorry i wasn't aware it was such a common thing.

Owner

banister commented Apr 20, 2013

Please just confirm, this error is related to this pull request, #873

Owner

banister commented Apr 20, 2013

@SFEley hi, i've just pushed a 0.9.12.1pre1 gem, could you confirm this fixes the bug? If so, i can remove the pre and push it properly :)

I tested 0.9.12.1pre1: the hook failure disappeared, but the bug about show-method still stands

Owner

banister commented Apr 20, 2013

@berdario ya, the show-source bug is due to a deeper issue with pry-doc that we'll resolve later at some point. But out of interest, since we likely can't retrieve the java source, isn't it better to at least show the C source (so someone can see how it's implemented at least on MRI) than no source at all?

I'm very skeptical about that, also because the output inside jruby is different than the one gotten inside MRI, adding to the confusion

fyi, on the bug report the output is on jruby... this is the MRI output:

[1] pry(main)> show-method caller

From: vm_backtrace.c (C Method):
Owner: Kernel
Visibility: private
Number of lines: 5

static VALUE
rb_f_caller(int argc, VALUE *argv)
{
    return vm_backtrace_to_ary(GET_THREAD(), argc, argv, 1, 1, 1);
}
[2] pry(main)> 
Owner

banister commented Apr 20, 2013

@berdario what if we displayed a warning indicating it's not the right source, something lke "WARNING: this is the source for the MRI method", but continued to display the source after?

good enough for me

about the difference between jruby/mri... maybe it's because it defaults to the 1.9 version? if that's the case, the warning should mention it

Owner

banister commented Apr 21, 2013

@SFEley @berdario I've pushed the 0.9.12.1 gem. I'm closing this issue as i think it fixes the problem, but let me know if the issue still persists.

@banister banister closed this Apr 21, 2013

wouldn't it be better to keep it open until the warning will have been added to pry?

Owner

banister commented Apr 21, 2013

@berdario this issue is confusing as it actually reports two bugs, the one emphasized by @SFEley and also the one about the source retrieval not matching the interpreter.The first one is a significantly bigger bug & that was the one the new gem fixes...but i'll reopen it as i guess the source retrieval was the one you seemed to emphasize :)

@banister banister reopened this Apr 21, 2013

uh, yes... sorry for the confusion: I thought that the hook failure could've been related in some weird way to the source retrieval issue, and I didn't bother to open another separate issue

SFEley commented Apr 25, 2013

Thanks very much! This does appear to fix the problem I was commenting on. Sorry for the confusion I caused by adding to this issue -- I wanted to make sure I wasn't duplicating, so I posted in this only because it was the same exception.

lunks commented Jul 1, 2013

👍 for closing this issue.

@DanielleSucher DanielleSucher pushed a commit to DanielleSucher/pry that referenced this issue Sep 7, 2013

@banister banister hotfix for jruby issue #890 21aef07

@DanielleSucher DanielleSucher pushed a commit to DanielleSucher/pry that referenced this issue Sep 7, 2013

@banister banister hotfix for jruby, fixes #890 404d448

@rf- rf- closed this Apr 29, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment