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

"Scanning and caching *.c files..." for show-doc Kernel.is_a? #16

Closed
dgutov opened this issue Aug 14, 2013 · 21 comments · Fixed by #19
Closed

"Scanning and caching *.c files..." for show-doc Kernel.is_a? #16

dgutov opened this issue Aug 14, 2013 · 21 comments · Fixed by #19

Comments

@dgutov
Copy link
Contributor

dgutov commented Aug 14, 2013

I've modified the warning line a little, and it looks like this:

warn "Scanning and caching *.c files... (for #{meth}, in #{gem_dir})"

The output:

[7] pry(main)> Scanning and caching *.c files... (for #<UnboundMethod: Kernel#is_a?>, in /home/gutov/.rbenv/versions/1.9.3-p429)

Needless to say, it takes a while (>20 seconds on the first invocation), which is particularly annoying in my use case: providing automatic calltips for Ruby code in Emacs.

[12] pry(main)> PryDoc::VERSION
=> "0.4.6"
@dgutov
Copy link
Contributor Author

dgutov commented Oct 22, 2013

...and then it crashes during parsing:

[warn]: Cannot parse `/home/gutov/.rbenv/versions/1.9.3-p429/lib/ruby/gems/1.9.1/gems/nokogiri-1.6.0/ports/x86_64-linux-gnu/libxml2/2.8.0/share/doc/libxml2-2.8.0/html/testWriter.c': invalid byte sequence in UTF-8
[warn]: ArgumentError: invalid byte sequence in UTF-8
[warn]: Stack trace:
    /home/gutov/.rbenv/versions/1.9.3-p429/lib/ruby/gems/1.9.1/gems/yard-0.8.6.1/lib/yard/parser/c/c_parser.rb:104:in `=~'
    /home/gutov/.rbenv/versions/1.9.3-p429/lib/ruby/gems/1.9.1/gems/yard-0.8.6.1/lib/yard/parser/c/c_parser.rb:104:in `!~'
    /home/gutov/.rbenv/versions/1.9.3-p429/lib/ruby/gems/1.9.1/gems/yard-0.8.6.1/lib/yard/parser/c/c_parser.rb:104:in `consume_body_statements'
    /home/gutov/.rbenv/versions/1.9.3-p429/lib/ruby/gems/1.9.1/gems/yard-0.8.6.1/lib/yard/parser/c/c_parser.rb:82:in `consume_toplevel_statement'
    /home/gutov/.rbenv/versions/1.9.3-p429/lib/ruby/gems/1.9.1/gems/yard-0.8.6.1/lib/yard/parser/c/c_parser.rb:40:in `block in parse_toplevel'
    /home/gutov/.rbenv/versions/1.9.3-p429/lib/ruby/gems/1.9.1/gems/yard-0.8.6.1/lib/yard/parser/c/c_parser.rb:211:in `advance_loop'

Unfortunately, I still haven't managed to produce a self-contained example. show-doc Kernel#is_a? in a clean new session works fine.

@kyrylo
Copy link
Member

kyrylo commented Oct 24, 2013

Why is your YARD so old?

@dgutov
Copy link
Contributor Author

dgutov commented Oct 24, 2013

Why shouldn't it be? pry-doc depends on YARD >= 0.8. Is this likely to be a YARD bug?

YARD 0.8.6.2 was released at June 27, and I got the machine I'm currently using (and set up the environment there) about ~20 days before that.

@kyrylo
Copy link
Member

kyrylo commented Oct 24, 2013

Well, the newer YARD may fix one of the problems. It's just my uneducated guess.

@dgutov
Copy link
Contributor Author

dgutov commented Oct 26, 2013

Good point. That does nothing to address the root problem, though.

@dgutov
Copy link
Contributor Author

dgutov commented Nov 27, 2013

Actually, I'm effectively calling show-doc Kernel.is_a?, not show-doc Kernel#is_a? (I'll update the issue heading). This is something I'll need to fix in robe anyway. Here's the full scenario using only Pry:

irb(main):001:0> require 'pry'
=> true
irb(main):002:0> require 'active_support/core_ext/kernel'
=> true
irb(main):003:0> pry

Frame number: 0/13
[1] pry(main)> show-doc Kernel.is_a?
Scanning and caching *.c files... (for #<Method: Module(Kernel)#is_a?>, in /home/gutov/.rbenv/versions/1.9.3-p429)
...

ActiveSupport is required, because otherwise the method's source_location returns nil.
is_a? is not special in any way, the result is the same with any other Kernel method.

dgutov added a commit to dgutov/robe that referenced this issue Nov 28, 2013
dgutov added a commit to dgutov/robe that referenced this issue Nov 28, 2013
dgutov added a commit to dgutov/robe that referenced this issue Dec 28, 2013
@dgutov
Copy link
Contributor Author

dgutov commented Feb 11, 2014

And another example, without ActiveSupport now:

$ pry
[1] pry(main)> Pry::VERSION
=> "0.9.12.6"
[2] pry(main)> PryDoc::VERSION
=> "0.5.1"
[3] pry(main)> ? File.exists?
*pause*
Scanning and caching *.c files...

@Silex
Copy link

Silex commented Feb 12, 2014

I have a similar experience about File#exists:

philippe@philippe-desktop:~/foo$ pry
[1] pry(main)> Pry::VERSION
=> "0.9.12.6"
[2] pry(main)> PryDoc::VERSION
=> "0.4.6"
[3] pry(main)> ? File#exists?
Error: Couldn't locate a definition for File#exists?!

rvm docs generate ran happilly before that.

I just noticed my pry-doc is pretty old... maybe that's the culprit, it probably is there because of jazz-hands which probably requires an old version. I'll investigate.

@dgutov
Copy link
Contributor Author

dgutov commented Feb 12, 2014

The doc for File#exists? can't be found in 0.5.1 either, but that's a milder issue: at least it doesn't freeze the process for half a minute.

@Mon-Ouie
Copy link
Member

File#exists? doesn't exist in Ruby , you probably meant to look up File.exists?.

@dgutov
Copy link
Contributor Author

dgutov commented Feb 12, 2014

File#exists? doesn't exist in Ruby

You're right, sorry. To add something useful, then: in pry-doc 0.4.6 there's no "Scanning..." for File.exists?, it shows a different error (which apparently was "fixed" in 073844f):

$ pry
[1] pry(main)> Pry::VERSION
=> "0.9.12.6"
[2] pry(main)> PryDoc::VERSION
=> "0.4.6"
[3] pry(main)> ? File.exists?
NameError: undefined method `exists?' for class `Class'
from /home/gutov/.rbenv/versions/1.9.3-p429/lib/ruby/gems/1.9.1/gems/pry-doc-0.4.6/lib/pry-doc.rb:49:in `method'

@kyrylo
Copy link
Member

kyrylo commented Feb 12, 2014

I think @banister can see the future. He fixes issues before they are even posted!

@Silex
Copy link

Silex commented Feb 13, 2014

Ok, I did more checks:

philippe@philippe-desktop:~$ pry
[1] pry(main)> Pry::VERSION
=> "0.9.12.6"
[2] pry(main)> PryDoc::VERSION
=> "0.4.6"
[3] pry(main) »  ri File.exists?

File.exists?
(from ruby site)
------------------------------------------------------------------------------
  exists?(p1)

------------------------------------------------------------------------------

[4] pry(main) »  ? File.exists?
Error: Cannot locate this method: exists?. (source_location returns nil)
[5] pry(main) »  ? File

From: /home/philippe/.rvm/gems/ruby-2.1.0@gemset/gems/yard-0.8.7.3/lib/yard/core_ext/file.rb @ line 3:
Class name: File
Number of lines: 1

[6] pry(main) »  ? String

From: object.c (C Method):
Owner: Kernel
Visibility: private
Signature: String(arg1)
Number of lines: 6

Converts arg to a String by calling its
to_s method.

   String(self)        #=> "main"
   String(self.class   #=> "Object"
   String(123456)      #=> "123456"

[7] pry(main)> ? GC
Error: Couldn't locate a definition for GC!

[8] pry(main)> ri GC
GC

(from ruby site)
------------------------------------------------------------------------------
The GC module provides an interface to Ruby's mark and sweep garbage
collection mechanism.

Some of the underlying methods are also available via the ObjectSpace module.

You may obtain information about the operation of the GC through GC::Profiler.
------------------------------------------------------------------------------
Constants:

INTERNAL_CONSTANTS:
  [not documented]

OPTS:
  [not documented]


Class methods:

  count
  disable
  enable
  (... snip)

And almost same behavior with 0.5.1. Basically, seems it cannot find File or GC for some weird reason. From the command line ri GC or ri File.exists? works (as showed in the pry session).

In the ? File, we can also see it tries to read the wrong File class...

@kyrylo
Copy link
Member

kyrylo commented Feb 13, 2014

@Silex, the latest Pry Doc version is v0.5.1.

@kyrylo
Copy link
Member

kyrylo commented Feb 13, 2014

It cannot find the String class because it is a method. We should probably default it to class. Actually, as far as I remember, there's a way to get the String class. I forgot how to do that, though.

Also, could you please not mangle the original issue? Open a new one, if you want to report this.

@Silex
Copy link

Silex commented Feb 13, 2014

@kyrylo: I said I tested with 0.5.1 too, same results (see the end of my post).

Also it more or less found the String class, it didn't find GC or File.exists? while ri can find those.

[EDIT] how should I go about debugging why ri can see them but not show-doc ?

@kyrylo
Copy link
Member

kyrylo commented Feb 13, 2014

@dgutov
Copy link
Contributor Author

dgutov commented Feb 13, 2014

Actually, as far as I remember, there's a way to get the String class.

? ::String? I believe it was discussed in pry/pry#960.

@Silex
Copy link

Silex commented Feb 13, 2014

@kyrylo: you are unclear. Can you elaborate?

@kyrylo
Copy link
Member

kyrylo commented Feb 13, 2014

@dgutov, you're right! I thought it was already implemented.

@Silex, the issue you are writing in is about "Scanning and caching *.c files...". So, your problem has nothing to do with it and that's why I'm suggesting you to file a new issue. Although discussing ? File.exists? is important, it merely doesn't belong to this thread.

@Silex
Copy link

Silex commented Feb 13, 2014

Ok, I'll create a new issue. I believed it was the same underlying problem.

dgutov added a commit to dgutov/pry-doc that referenced this issue Mar 6, 2014
@kyrylo kyrylo closed this as completed in #19 Mar 8, 2014
dgutov referenced this issue in pd/dotfiles Apr 5, 2014
it mostly dies and whines at me and makes typing more than 3 characters
at a time a blocking shitshow

emacs: the partner that treats me like shit but i can't help but love.
AfsmNGhr pushed a commit to AfsmNGhr/robe-server that referenced this issue Sep 24, 2017
AfsmNGhr pushed a commit to AfsmNGhr/robe-server that referenced this issue Sep 24, 2017
AfsmNGhr pushed a commit to AfsmNGhr/robe-server that referenced this issue Sep 24, 2017
AfsmNGhr pushed a commit to AfsmNGhr/robe-server that referenced this issue Sep 24, 2017
AfsmNGhr pushed a commit to AfsmNGhr/robe-server that referenced this issue Sep 24, 2017
AfsmNGhr pushed a commit to AfsmNGhr/robe-server that referenced this issue Sep 24, 2017
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

Successfully merging a pull request may close this issue.

4 participants