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

uninitialized constant when running rake #1598

Closed
chopmo opened this issue Jun 9, 2011 · 12 comments
Closed

uninitialized constant when running rake #1598

chopmo opened this issue Jun 9, 2011 · 12 comments
Assignees
Labels
Milestone

Comments

@chopmo
Copy link
Contributor

chopmo commented Jun 9, 2011

In my project, any rake invocation (eg. "rake -T --trace") yields the error below.

This does not happen in a fresh app. Here is my Gemfile.lock: https://gist.github.com/1016634
I'm not sure what other info to provide?

rake aborted!
uninitialized constant RubyToken::AlreadyDefinedToken
/Users/jtj/.rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/rdoc/parsers/parse_rb.rb:273:in `def_token'
/Users/jtj/.rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/rdoc/parsers/parse_rb.rb:300
/Users/jtj/.rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/rdoc/parsers/parse_rb.rb:299:in `each'
/Users/jtj/.rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/rdoc/parsers/parse_rb.rb:299
/Users/jtj/.rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/rdoc/rdoc.rb:8
/Users/jtj/.rvm/gems/ree-1.8.7-2011.03@foobar/gems/railties-3.0.9.rc1/lib/rails/tasks/documentation.rake:4
/Users/jtj/.rvm/gems/ree-1.8.7-2011.03@foobar/gems/railties-3.0.9.rc1/lib/rails/tasks.rb:15
/Users/jtj/.rvm/gems/ree-1.8.7-2011.03@foobar/gems/railties-3.0.9.rc1/lib/rails/tasks.rb:6:in `each'
/Users/jtj/.rvm/gems/ree-1.8.7-2011.03@foobar/gems/railties-3.0.9.rc1/lib/rails/tasks.rb:6
/Users/jtj/.rvm/gems/ree-1.8.7-2011.03@foobar/gems/railties-3.0.9.rc1/lib/rails/application.rb:215:in `initialize_tasks'
/Users/jtj/.rvm/gems/ree-1.8.7-2011.03@foobar/gems/railties-3.0.9.rc1/lib/rails/application.rb:139:in `load_tasks'
/Users/jtj/.rvm/gems/ree-1.8.7-2011.03@foobar/gems/railties-3.0.9.rc1/lib/rails/application.rb:77:in `send'
/Users/jtj/.rvm/gems/ree-1.8.7-2011.03@foobar/gems/railties-3.0.9.rc1/lib/rails/application.rb:77:in `method_missing'
/Users/jtj/wb/foobar/Rakefile:7
/Users/jtj/.rvm/gems/ree-1.8.7-2011.03@foobar/gems/rake-0.9.2/lib/rake/rake_module.rb:25:in `load'
/Users/jtj/.rvm/gems/ree-1.8.7-2011.03@foobar/gems/rake-0.9.2/lib/rake/rake_module.rb:25:in `load_rakefile'
/Users/jtj/.rvm/gems/ree-1.8.7-2011.03@foobar/gems/rake-0.9.2/lib/rake/application.rb:495:in `raw_load_rakefile'
/Users/jtj/.rvm/gems/ree-1.8.7-2011.03@foobar/gems/rake-0.9.2/lib/rake/application.rb:78:in `load_rakefile'
/Users/jtj/.rvm/gems/ree-1.8.7-2011.03@foobar/gems/rake-0.9.2/lib/rake/application.rb:129:in `standard_exception_handling'
/Users/jtj/.rvm/gems/ree-1.8.7-2011.03@foobar/gems/rake-0.9.2/lib/rake/application.rb:77:in `load_rakefile'
/Users/jtj/.rvm/gems/ree-1.8.7-2011.03@foobar/gems/rake-0.9.2/lib/rake/application.rb:61:in `run'
/Users/jtj/.rvm/gems/ree-1.8.7-2011.03@foobar/gems/rake-0.9.2/lib/rake/application.rb:129:in `standard_exception_handling'
/Users/jtj/.rvm/gems/ree-1.8.7-2011.03@foobar/gems/rake-0.9.2/lib/rake/application.rb:59:in `run'
/Users/jtj/.rvm/gems/ree-1.8.7-2011.03@foobar/gems/rake-0.9.2/bin/rake:32
/Users/jtj/.rvm/gems/ree-1.8.7-2011.03@foobar/bin/rake:19:in `load'
/Users/jtj/.rvm/gems/ree-1.8.7-2011.03@foobar/bin/rake:19
@sikachu
Copy link
Member

sikachu commented Jun 9, 2011

@tenderlove do you mind have a look?

@ghost ghost assigned tenderlove Jun 9, 2011
@vijaydev
Copy link
Member

vijaydev commented Jun 9, 2011

@chopmo
Copy link
Contributor Author

chopmo commented Jun 9, 2011

@vijaydev Thanks, but not really :)

I was just looking into this a bit more. It turns out that require 'rdoc/rdoc' fails on 1.8.7. And this is exactly what happens in railties-3.0.9.rc1/lib/rails/tasks/documentation.rake:4 (changed since 3.0.8).

It's very easy to reproduce:

[ ruby-1.9.2-p0 -  ~ ] $ rvm ruby-1.8.7-p302
[ ruby-1.8.7-p302 -  ~ ] $ irb
ruby-1.8.7-p302 :001 > require 'rdoc/rdoc'
(snip)
NameError: uninitialized constant RubyToken::AlreadyDefinedToken
    from /Users/jtj/.rvm/rubies/ruby-1.8.7-p302/lib/ruby/1.8/rdoc/parsers/parse_rb.rb:273:in `def_token'
    (snip)
    from (irb):1:in `require'
    from (irb):1

@chopmo
Copy link
Contributor Author

chopmo commented Jun 9, 2011

In 3.0.9, the top of documentation.rake has changed from this:

require 'rake/rdoctask'

# Monkey-patch to remove redoc'ing and clobber descriptions to cut down on rake -T noise
class RDocTaskWithoutDescriptions < Rake::RDocTask

to this:

begin
  require 'rdoc/task'
rescue LoadError
  require 'rdoc/rdoc'
  require 'rake/rdoctask'
  RDoc::Task = Rake::RDocTask
end

# Monkey-patch to remove redoc'ing and clobber descriptions to cut down on rake -T noise
class RDocTaskWithoutDescriptions < RDoc::Task

And as I said in my previous comment, require 'rdoc/rdoc' fails on MRI/REE 1.8.7.

I'm sure there's reason for this change, but simply reverting it allows me to run rake again. I wonder what breaks?

@vijaydev
Copy link
Member

vijaydev commented Jun 9, 2011

Rake 0.9 deprecated rake/rdoctask and replaced with rdoc/task. What's your rake version? Does it work in 1.9.2 with the same rake version as you used in 1.8.7 ?

@chopmo
Copy link
Contributor Author

chopmo commented Jun 9, 2011

My rake version is 0.9.2. And yes, it does work in 1.9.2, maybe because require 'rdoc/rdoc' works on that ruby version.

Thanks for helping!

@vijaydev
Copy link
Member

vijaydev commented Jun 9, 2011

History of commits (in that order) that did these changes: b921679 24b28a2 and 05adf52

Also, check your rdoc version (see commit message of 2nd commit in the list).

@chopmo
Copy link
Contributor Author

chopmo commented Jun 9, 2011 via email

@amatsuda
Copy link
Member

amatsuda commented Jun 9, 2011

I found out that adding ruby-debug to the Gemfile reproduces this error.
As @vijaydev showed in his first comment, the root cause is that both irb (which is required by ruby-debug) and rdoc defines RubyToken module.

This is why updating rdoc via RubyGems actually solved @chopmo's problem.

So, what should we do next? Here are some solutions:

  1. let ruby-debug gem depend on newer rdoc gem
    => but Rails users may encounter this error unless using the fixed version of ruby-debug
  2. rollback these Rake tasks to use 'rake/rdoctask' instead of 'rdoc/task'
    => but this may show warnings when Rake > 0.9
  3. let rails depend on rdoc gem
    => probably the best?

Thoughts?

@chopmo
Copy link
Contributor Author

chopmo commented Jun 9, 2011

@amatsuda For some reason I had completely missed the connection to ruby-debug, my bad :( Anyway, if 3. is acceptable, I definitely agree that this is the cleanest solution. BTW I'm surprised that this hasn't turned up before somewhere in Rails...

@vijaydev Sorry, your links would have been very helpful if I had checked them more thoroughly!

@tenderlove
Copy link
Member

It seems that if we're going to ship a task to build documentation using RDoc, we should add the proper dependency.

@spastorino
Copy link
Contributor

This issue should be fixed now, if not please add a comment and I will take another look

tenderlove added a commit that referenced this issue Jun 12, 2011
* 3-0-stable:
  Add support for using an ARCONFIG environment variable to specify the location of the config.yml file for running the tests
  Define ActiveSupport#to_param as to_str - closes #1663
  Revert "Make sure that we don't perform in-place mutation on SafeBuffer string"
  Make sure that we don't perform in-place mutation on SafeBuffer string
  Update CHANGELOG to mention the json_escape change
  Ensure number helpers can handle HTML safe strings - closes #1597.
  ensuring that json_escape returns html safe strings when passed an html safe string
  Fix issue #1598 by adding a dependency to the RDoc gem.
  Make sure `escape_javascript` return `SafeBuffer` if the incoming argument is already html_safe

Conflicts:
	actionpack/CHANGELOG
tenderlove added a commit that referenced this issue Jun 16, 2011
* 3-0-9:
  Preparing for 3.0.9 release
  avoid false positives caused by release candidates
  Preparing for 3.0.9.rc5 release
  bumping to rc4
  Make sure that we don't perform in-place mutation on SafeBuffer string
  Update CHANGELOG to mention the json_escape change
  Ensure number helpers can handle HTML safe strings - closes #1597.
  bumping to rc3 since syck is not playing nicely
  bumping to 3.0.9.rc2
  ensuring that json_escape returns html safe strings when passed an html safe string
  Make sure `escape_javascript` return `SafeBuffer` if the incoming argument is already html_safe
  Fix issue #1598 by adding a dependency to the RDoc gem.
  bumping to 3.0.9.rc1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants