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

Missing require statement -- Yard won't run on 1.8.6 or 7 #178

Closed
walterdavis opened this issue Sep 28, 2010 · 16 comments
Closed

Missing require statement -- Yard won't run on 1.8.6 or 7 #178

walterdavis opened this issue Sep 28, 2010 · 16 comments

Comments

@walterdavis
Copy link

Here's what I needed to do to make it work:

--- gems.rb (saved version)
+++ (current document)
@@ -44,6 +44,7 @@
end

   def add_gems(gems)
  •    require "enumerator"
     gems.each_slice(2) do |gem, ver_require|
       specs = Gem.source_index.find_name(gem, ver_require || ">= 0")
       @gems += specs unless specs.empty?
    
@lsegal
Copy link
Owner

lsegal commented Sep 28, 2010

Can you

a) show a backtrace
b) list your ruby version and environment (OS, anything important)
c) format a proper patch or submit a pull request

Thanks

@walterdavis
Copy link
Author

Sorry, sure.
I started out on Ruby 1.8.6, no idea what patch level. I installed yard 0.6.1, and first tried to run yard server --gems, and found nothing would ever display. It would just spin and spin in the browser and never get anywhere. So I dug around in the documentation for a while and found the sudo yard gems command, and tried that, and got this error:

marvin:ci waltd$ sudo yard gems
Password:
/Library/Ruby/Gems/1.8/gems/yard-0.6.1/lib/yard/cli/gems.rb:47:in add_gems': undefined methodeach_slice' for []:Array (NoMethodError)
from /Library/Ruby/Gems/1.8/gems/yard-0.6.1/lib/yard/cli/gems.rb:70:in optparse' from /Library/Ruby/Gems/1.8/gems/yard-0.6.1/lib/yard/cli/gems.rb:18:inrun'
from /Library/Ruby/Gems/1.8/gems/yard-0.6.1/lib/yard/cli/command.rb:13:in run' from /Library/Ruby/Gems/1.8/gems/yard-0.6.1/lib/yard/cli/command_parser.rb:66:inrun'
from /Library/Ruby/Gems/1.8/gems/yard-0.6.1/lib/yard/cli/command_parser.rb:48:in run' from /Library/Ruby/Gems/1.8/gems/yard-0.6.1/bin/yard:4 from /usr/bin/yard:19:inload'
from /usr/bin/yard:19

So I figured, my Ruby must be too old to know each_slice, I've been meaning to upgrade, so I installed 1.8.7 -p302 and tried again:

marvin:ruby-1.8.7-p302 waltd$ sudo yard gems
Password:
/Library/Ruby/Gems/1.8/gems/yard-0.6.1/lib/yard/cli/gems.rb:47:in add_gems': undefined methodeach_slice' for []:Array (NoMethodError)
from /Library/Ruby/Gems/1.8/gems/yard-0.6.1/lib/yard/cli/gems.rb:70:in optparse' from /Library/Ruby/Gems/1.8/gems/yard-0.6.1/lib/yard/cli/gems.rb:18:inrun'
from /Library/Ruby/Gems/1.8/gems/yard-0.6.1/lib/yard/cli/command.rb:13:in run' from /Library/Ruby/Gems/1.8/gems/yard-0.6.1/lib/yard/cli/command_parser.rb:66:inrun'
from /Library/Ruby/Gems/1.8/gems/yard-0.6.1/lib/yard/cli/command_parser.rb:48:in run' from /Library/Ruby/Gems/1.8/gems/yard-0.6.1/bin/yard:4 from /usr/bin/yard:19:inload'
from /usr/bin/yard:19

Same error. A quick google turned up the solution to include enumerable, which I did directly in my gems directory, without doing any of the things that would have made a proper diff or fork and pull request possible, and yard works fine now. I'll go through the steps, and send you a pull request. It does seem odd that you hadn't encountered this already from someone else.

Walter

@lsegal
Copy link
Owner

lsegal commented Sep 28, 2010

The second error is the same as the first (you're still running 1.8.6 there). You have to make sure your 1.8.7 install is before your OSX ruby in your path. It is a 1.8.6 error, since each_slice isn't in 1.8.6. I'd suggest upgrading, but this will get fixed, thanks.

@walterdavis
Copy link
Author

I beg to differ:

arvin:ruby-1.8.7-p302 waltd$ which ruby
/usr/local/bin/ruby
marvin:ruby-1.8.7-p302 waltd$ ruby -v
ruby 1.8.7 (2010-08-16 patchlevel 302) [i686-darwin9.8.0]
marvin:ruby-1.8.7-p302 waltd$

That's the version that threw the second error, which stunningly looked just like the first one. I'm confused too. I'd restart my Mac, but I have too many other things open right now to do that.

Thanks very much for looking at this.

Walter

@lsegal
Copy link
Owner

lsegal commented Sep 28, 2010

Except that when gem installs executables it hooks them up to a specific ruby install. The path /Library/Ruby/Gems/1.8/gems/yard-0.6.1 is definitely your OSX ruby, and nothing else. 1.8.7 should have its own gem path. You can test this with gem which yard.

@walterdavis
Copy link
Author

Here's a little docu on the requirement: http://apidock.com/ruby/Enumerable/each_slice

@lsegal
Copy link
Owner

lsegal commented Sep 28, 2010

Thanks, but that only works on 1.8.7-- 1.8.6 does not have Enumerable classes, and 1.9.1+ does not have "enumerable" (it's builtin).

@walterdavis
Copy link
Author

I uninstalled yard and re-installed it after I updated ruby, because I couldn't believe the error was exactly the same. And I updated gem in the process, too.

@walterdavis
Copy link
Author

marvin:ruby-1.8.7-p302 waltd$ gem which yard
/Library/Ruby/Gems/1.8/gems/yard-0.6.1/lib/yard.rb
marvin:ruby-1.8.7-p302 waltd$

@lsegal
Copy link
Owner

lsegal commented Sep 28, 2010

What does gem env get you?

@walterdavis
Copy link
Author

Here's the uninstall/reinstall (I just did it again)

marvin:ruby-1.8.7-p302 waltd$ sudo gem uninstall yard
Password:
Remove executables:
yard, yardoc, yri

in addition to the gem? [Yn] Y
Removing yard
Removing yardoc
Removing yri

You have requested to uninstall the gem:
yard-0.6.1
haml-2.2.20 depends on [yard (>= 0.5.3)]
If you remove this gems, one or more dependencies will not be met.
Continue with Uninstall? [Yn] Y
Successfully uninstalled yard-0.6.1
marvin:ruby-1.8.7-p302 waltd$ sudo gem install yard
Successfully installed yard-0.6.1
1 gem installed
Installing ri documentation for yard-0.6.1...

RDoc failure in lib/yard/core_ext/hash.rb at or around line 13 column 11

Before reporting this, could you check that the file
you're documenting compiles cleanly--RDoc is not a
full Ruby parser, and gets confused easily if fed
invalid programs.

The internal error was:

ERROR: While generating documentation for yard-0.6.1
... MESSAGE: Name or symbol expected (got #RubyToken::TkfLBRACK:0x1a7ef1c)
... RDOC args: --ri --op /Library/Ruby/Gems/1.8/doc/yard-0.6.1/ri --quiet lib --title yard-0.6.1 Documentation
(continuing with the rest of the installation)
Installing RDoc documentation for yard-0.6.1...

RDoc failure in lib/yard/core_ext/hash.rb at or around line 13 column 11

Before reporting this, could you check that the file
you're documenting compiles cleanly--RDoc is not a
full Ruby parser, and gets confused easily if fed
invalid programs.

The internal error was:

ERROR: While generating documentation for yard-0.6.1
... MESSAGE: Name or symbol expected (got #RubyToken::TkfLBRACK:0x170fee4)
... RDOC args: --op /Library/Ruby/Gems/1.8/doc/yard-0.6.1/rdoc --quiet lib --title yard-0.6.1 Documentation
(continuing with the rest of the installation)
marvin:ruby-1.8.7-p302 waltd$

And now that I have the unpatched version once more, let's see what happens if I run the yard gems again:

marvin:ruby-1.8.7-p302 waltd$ sudo yard gems
/Library/Ruby/Gems/1.8/gems/yard-0.6.1/lib/yard/cli/gems.rb:47:in add_gems': undefined methodeach_slice' for []:Array (NoMethodError)
from /Library/Ruby/Gems/1.8/gems/yard-0.6.1/lib/yard/cli/gems.rb:70:in optparse' from /Library/Ruby/Gems/1.8/gems/yard-0.6.1/lib/yard/cli/gems.rb:18:inrun'
from /Library/Ruby/Gems/1.8/gems/yard-0.6.1/lib/yard/cli/command.rb:13:in run' from /Library/Ruby/Gems/1.8/gems/yard-0.6.1/lib/yard/cli/command_parser.rb:66:inrun'
from /Library/Ruby/Gems/1.8/gems/yard-0.6.1/lib/yard/cli/command_parser.rb:48:in run' from /Library/Ruby/Gems/1.8/gems/yard-0.6.1/bin/yard:4 from /usr/bin/yard:19:inload'
from /usr/bin/yard:19
marvin:ruby-1.8.7-p302 waltd$

once more, into the breach...

@walterdavis
Copy link
Author

Well I'll be. Gem says it's using 1.8.6. WTF?

marvin:ruby-1.8.7-p302 waltd$ gem env
RubyGems Environment:

  • RUBYGEMS VERSION: 1.3.7
  • RUBY VERSION: 1.8.6 (2009-06-08 patchlevel 369) [universal-darwin9.0]
  • INSTALLATION DIRECTORY: /Library/Ruby/Gems/1.8
  • RUBY EXECUTABLE: /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
  • EXECUTABLE DIRECTORY: /usr/bin
  • RUBYGEMS PLATFORMS:
    • ruby
    • universal-darwin-9
  • GEM PATHS:
    • /Library/Ruby/Gems/1.8
    • /Users/waltd/.gem/ruby/1.8
    • /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8
  • GEM CONFIGURATION:
    • :update_sources => true
    • :verbose => true
    • :benchmark => false
    • :backtrace => false
    • :bulk_threshold => 1000
  • REMOTE SOURCES:

@lsegal
Copy link
Owner

lsegal commented Sep 28, 2010

:)

@walterdavis
Copy link
Author

I have tried three times now to re-install gem with the new ruby, being as explicit as I know how to be with the installer, and each time gem env says the same thing. I wonder what could be going on here?

@walterdavis
Copy link
Author

Restarting woke gem up to the new world order.

@lsegal
Copy link
Owner

lsegal commented Oct 3, 2010

Replace #each_slice with 1.8.6 compatible iteration.

Closed by d3f34f4

This issue was closed.
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