guillermo / rake-hooks

Rake hooks let you add callbacks to rake tasks.
MIT License
70 stars 21 forks source link

uninitialized constant Rake (NameError) in lib/rake/hooks.rb:1 #11

Open szymon-jez opened 12 years ago

szymon-jez commented 12 years ago
rake-hooks-1.2.3/lib/rake/hooks.rb:1:in `<top (required)>': uninitialized constant Rake (NameError)
        from ~/.rvm/gems/ruby-1.9.3-p125@global/gems/bundler-1.1.3/lib/bundler/runtime.rb:74:in `require'
szymon-jez commented 12 years ago

See this quick fix patch https://github.com/jeznet/rake-hooks/commit/7fc26383b3b37589cd55742f1da7cee63809d149

guillermo commented 12 years ago

Yes, you are right. But how you load a rake library without rake. Rake hooks is supposed to be loaded within rake. Not outside.

Can you explain a little bit more the use case, and also the rake version you are using? Is rake in your Gemfile?

szymon-jez commented 12 years ago

I'm using Rake 0.9.2.2. Rake is not directly declared in my Gemfile. It is thought in Gemfile.lock (because it's a dependency). I'm using it all in a Rails app.

brightbytes-dude commented 10 years ago

I'm getting this same error too from Rails:

/Users/aaron/.rvm/gems/ruby-1.9.3-p484@brightbytes/gems/rake-hooks-1.2.3/lib/rake/hooks.rb:1:in '<top (required)>': uninitialized constant Rake (NameError)

However, I don't have permission to see the patch.

cheef commented 10 years ago

To fix this issue it's enough to setup in Gemfile gem 'rake-hooks', require: false and require hooks manually inside rake files like require 'rake/hooks'

abuisman commented 9 years ago

@cheef +1

Another fix is to add require 'rake' just above Bundler.require(:default, Rails.env) in application.rb, but I like your fix better.