pry-doc
pry-doc copied to clipboard
show-source ($) broken for many methods in Ruby 2.7.0 ("undefined method `skip_cruby_source'")
Migrated from https://github.com/pry/pry/issues/2124.
It does still work with some methods, but far fewer than 2.6.5 did. Errors and warnings appear on 2.7.0 (see below); this seems to be the line causing the problem:
https://github.com/pry/pry-doc/blob/3612812c30cf3a34987be7c411463c8b069f7ad3/lib/pry-doc/pry_ext/show_source_with_c_internals.rb#L34
The output below is from macOS Mojave; I've also reproduced the issue on Ubuntu 19.10.
2.6.5
[12:12:30] ~ ➜ rbenv local 2.6.5
[12:12:32] ~ ➜ ruby -v
ruby 2.6.5p114 (2019-10-01 revision 67812) [x86_64-darwin18]
[12:12:34] ~ ➜ pry
[1] pry(main)> $ "".chomp
From: string.c (C Method):
Owner: String
Visibility: public
Number of lines: 7
static VALUE
rb_str_chomp(int argc, VALUE *argv, VALUE str)
{
VALUE rs = chomp_rs(argc, argv);
if (NIL_P(rs)) return rb_str_dup(str);
return rb_str_subseq(str, 0, chompped_length(str, rs));
}
[2] pry(main)> $ "".length
From: string.c (C Method):
Owner: String
Visibility: public
Number of lines: 5
VALUE
rb_str_length(VALUE str)
{
return LONG2NUM(str_strlen(str, NULL));
}
[3] pry(main)> $ "".ord
From: string.c (C Method):
Owner: String
Visibility: public
Number of lines: 8
VALUE
rb_str_ord(VALUE s)
{
unsigned int c;
c = rb_enc_codepoint(RSTRING_PTR(s), RSTRING_END(s), STR_ENC_GET(s));
return UINT2NUM(c);
}
2.7.0
[12:09:23] ~ ➜ rbenv local 2.7.0
[12:09:23] ~ ➜ ruby -v
ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-darwin18]
[12:09:26] ~ ➜ pry
[1] pry(main)> $ "".chomp
/Users/pat/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/pry-doc-1.1.0/lib/pry-doc/pry_ext/show_source_with_c_internals.rb:34: warning: _pry_ is deprecated, use pry_instance instead
NoMethodError: undefined method `skip_cruby_source' for #<Pry::Config:0x00007fd56e04b640>
from /Users/pat/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/pry-0.13.0/lib/pry/config.rb:250:in `method_missing'
Caused by Pry::CommandError: Cannot locate this method: chomp. (source_location returns nil)
from /Users/pat/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/pry-0.13.0/lib/pry/method.rb:526:in `pry_doc_info'
[1] pry(main)> $ "".length
From: string.c (C Method):
Owner: String
Visibility: public
Signature: length()
Number of lines: 5
VALUE
rb_str_length(VALUE str)
{
return LONG2NUM(str_strlen(str, NULL));
}
[2] pry(main)> $ "".ord
/Users/pat/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/pry-doc-1.1.0/lib/pry-doc/pry_ext/show_source_with_c_internals.rb:34: warning: _pry_ is deprecated, use pry_instance instead
NoMethodError: undefined method `skip_cruby_source' for #<Pry::Config:0x00007fd56e04b640>
from /Users/pat/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/pry-0.13.0/lib/pry/config.rb:250:in `method_missing'
Caused by Pry::CommandError: Cannot locate this method: ord. (source_location returns nil)
from /Users/pat/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/pry-0.13.0/lib/pry/method.rb:526:in `pry_doc_info'