Forum: Ruby on Rails rake error: uninitialized constant ActiveRecord

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
doug livesey (Guest)
on 2007-06-20 19:25
Hallo -- I can't run any rake tasks all of a sudden in my project.
It was fine when I put it down the other day!
The output I get when I try to run a rake task is:

<output>
W:\holly> rake
in W:/holly)
rake aborted!
uninitialized constant ActiveRecord
W:/holly/rakefile:10
(See full trace by running task with --trace)
</output>

Can anyone shed any light on this?
I'm hamstrung w/out rake!
Cheers,
   Doug.
Hugh S. (Guest)
on 2007-06-20 19:42
(Received via mailing list)
On Wed, 20 Jun 2007, doug livesey wrote:

>
> Hallo -- I can't run any rake tasks all of a sudden in my project.
> It was fine when I put it down the other day!
> The output I get when I try to run a rake task is:
        [...]
> rake aborted!
> uninitialized constant ActiveRecord
> W:/holly/rakefile:10
> (See full trace by running task with --trace)
> </output>

Well, you could show the first 10 lines of your Rakefile.  But there
should be a
require 'activerecord'
in there somewhere, or a require that calls a require to pull in
ActiveRecord.
>
> Can anyone shed any light on this?
> I'm hamstrung w/out rake!
> Cheers,
>    Doug.

        Hugh
Doug L. (Guest)
on 2007-06-20 19:59
Hi -- sorry, should have said -- it's a standard RoR rakefile.
The contents are:

<code>
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be
available to Rake.

require(File.join(File.dirname(__FILE__), 'config', 'boot'))

require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'

require 'tasks/rails'
</code>

Line 10 is the last line, & it calls all Rails framework stuff, so I
don't think it's anything I've done.

Cheers,
   Doug.
Doug L. (Guest)
on 2007-06-21 11:10
Got it!
It was one of my custom rake tasks!
The damn' thing had never worked properly, & I'd clean forgotten about
it -- it was requiring a non-existant file & silently exiting, so I just
zapped it, & all's well w/ the world.
The amount of time I could've saved by remembering to run "rake --trace"
in the first place...
Cheers for your input.
   Doug.
This topic is locked and can not be replied to.