1

I have ruby 1.9.2 and rails 3.1. I am trying to get annotate 2.4.0 to work, but I get nomethod errors. I have tried uninstall and reinstall but it did not help. Please see the spool after the jump. Any suggestions on how to proceed will help.

~/myapps/testapp/app>sudo gem install annotate
Fetching: annotate-2.4.0.gem (100%)
Successfully installed annotate-2.4.0
1 gem installed
~/myapps/testapp/app>bundle exec annotate -e -p before
/Users/mymachine/.rvm/gems/ruby-1.9.2-p290/gems/annotate-2.4.0/bin/annotate:61:in block (2 levels) in <top (required)>': undefined methodeach' for nil:NilClass (NoMethodError)
from /Users/mymachine/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/optparse.rb:1308:in call'
from /Users/mymachine/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/optparse.rb:1308:inblock in parse_in_order'
from /Users/mymachine/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/optparse.rb:1264:in catch'
from /Users/mymachine/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/optparse.rb:1264:inparse_in_order'
from /Users/mymachine/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/optparse.rb:1258:in order!'
from /Users/mymachine/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/optparse.rb:1349:inpermute!'
from /Users/mymachine/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/optparse.rb:1370:in parse!'
from /Users/mymachine/.rvm/gems/ruby-1.9.2-p290/gems/annotate-2.4.0/bin/annotate:8:in'
from /Users/mymachine/.rvm/gems/ruby-1.9.2-p290/bin/annotate:19:in load'
from /Users/mymachine/.rvm/gems/ruby-1.9.2-p290/bin/annotate:19:in'
lucapette
  • 20,564
  • 6
  • 65
  • 59
Tabrez
  • 3,424
  • 3
  • 27
  • 33

1 Answers1

0

The -e flag expects arguments, which you have not given.

You can tell this by looking at the stack trace, the error is that nil has no method each. Since the error is being raised in the optparse file, you can deduce that optparse tried to iterate over some option that did not exist. That, of course, leads to an annotate -h which says "-e, --exclude [tests,fixtures] Do not annotate fixtures, test files, or both"

Joshua Cheek
  • 30,436
  • 16
  • 74
  • 83
  • Joshua - thanks for the reply. While that may be an issue in itself, the command does not run even after I supply those arguments. It does help get probably the right error message. The only command that works is "annotate -h". If I give annotate -v, here is what I see: `/Users/mymachine/.rvm/gems/ruby-1.9.2-p290/gems/annotate-2.4.0/lib/annotate.rb:8:in `version': private method `load' called for YAML:Module (NoMethodError) from /Users/mymachine/.rvm/gems/ruby-1.9.2-p290/gems/annotate-2.4.0/bin/annotate:28:in `block (2 levels) in '` ... Thoughts?? – Tabrez Dec 17 '11 at 20:11
  • Did a bit of looking around, and the authors of this gem didn't understand the ruby ecosystem when they wrote it. You can get the version to work by opening the gem up and sticking a `require 'yaml'` in lib/annotate/annotate.rb. It is pre bundler, so it doesn't manage it's dependencies, causing me to have to try out different rspecs before I could get it to even run the tests (it's tested with RSpec 1). The version of ActiveSupport it expects is also old, I was able to get the tests to pass with version 2.3.14 I also got it to annotate a Rails 2.3.5 project. Didn't try against anything newer. – Joshua Cheek Dec 17 '11 at 20:45
  • Thanks Joshua. I think that might work but I went with the another solution. mask8 posted a link (see above) to another thread about the same issue. The answer there was to use 2.4.1.beta instead of the 2.4.0 version of the gem. I tried that and it resolved it too. But thanks for sharing this solution too. In case there are issues with the beta version, now I know what to do! – Tabrez Dec 17 '11 at 21:12