# Rake weirdness (production vs development)

**URL:** <https://www.ruby-forum.com/t/rake-weirdness-production-vs-development/113624>\
**Category:** Rails\
**Created:** [September 3, 2007, 12:53am UTC](https://www.ruby-forum.com/t/rake-weirdness-production-vs-development/113624 "2007-09-03T00:53:04Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jonlog](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/db5fbb/32.png) [@jonlog](https://www.ruby-forum.com/u/jonlog)\
**Post date:** [September 3, 2007, 12:53am UTC](https://www.ruby-forum.com/t/rake-weirdness-production-vs-development/113624/1 "2007-09-03T00:53:04Z")

</div>

I’ve got a few custom rake tasks and all work find in development. I  
recently wrote a rake task that I intend to run periodically in a cron  
on the server to perform certain maintenance tasks. The new rake task  
works fine on my development machine. Running ‘rake -tasks’ on the dev  
machine shows the task right there in the list. When I deploy the app  
to the server (using capistrano) I can see the .rake file right there  
in lib/tasks where it’s supposed to be. Permissions and ownership are  
all correct. So far so good.

However, when I actually try to run the task on the server (right from  
the command line, not in CRON yet), Rake just responds that it doesn’t  
know how to build the task. When I run ‘rake --tasks’ on the server,  
my new task doesn’t show in the list. In fact, the only one of my  
custom tasks that show in the --tasks list is one that capistrano runs  
directly after deploy… which works.

All the built-in rake tasks like db:migrate, etc show up in the –  
tasks list and work when run. The custom task that capistrano runs  
also runs fine from the command line.

So, anybody got any ideas? I’ve blown a perfectly good Sunday  
afternoon beating my head against the wall over this and getting  
mildly annoyed.

---

<div class="post-metadata">

**Author:** ![jonlog](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/db5fbb/32.png) [@jonlog](https://www.ruby-forum.com/u/jonlog)\
**Post date:** [September 3, 2007, 1:30am UTC](https://www.ruby-forum.com/t/rake-weirdness-production-vs-development/113624/2 "2007-09-03T01:30:06Z")

</div>

On Sep 2, 5:52 pm, Jon G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> However, when I actually try to run the task on the server (right from  
> the command line, not in CRON yet), Rake just responds that it doesn’t  
> know how to build the task. When I run ‘rake --tasks’ on the server,  
> my new task doesn’t show in the list. In fact, the only one of my  
> custom tasks that show in the --tasks list is one that capistrano runs  
> directly after deploy… which works.

Maybe the cron job is trying to run the rake task from a directory  
other than the RAILS\_ROOT of your app? In other words, make sure it  
first does a ‘cd’ to the whatever capistrano would consider the  
“current\_path” of your app.

Just a shot in the dark…

Jeff

> **[Hey Daddio!](http://softiesonrails.com)**
>
> Home of Hey Daddio Software

---

<div class="post-metadata">

**Author:** ![jonlog](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/db5fbb/32.png) [@jonlog](https://www.ruby-forum.com/u/jonlog)\
**Post date:** [September 3, 2007, 1:33am UTC](https://www.ruby-forum.com/t/rake-weirdness-production-vs-development/113624/3 "2007-09-03T01:33:06Z")

</div>

Thanks for the reply, but I’m not even trying to run it from the cron  
yet. I’m just on the command line in the RAILS\_ROOT directory typing  
‘rake my\_task’ and getting a “Don’t know how to build task ‘my\_task’”  
error.

---

<div class="post-metadata">

**Author:** ![jonlog](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/db5fbb/32.png) [@jonlog](https://www.ruby-forum.com/u/jonlog)\
**Post date:** [September 3, 2007, 1:57am UTC](https://www.ruby-forum.com/t/rake-weirdness-production-vs-development/113624/4 "2007-09-03T01:57:08Z")

</div>

Update:  
Contrary to my original post, some (not all) of my other custom rake  
tasks are available on the server. If I copy my new custom task into  
one of the files that defines some of the other working tasks and send  
that up to the sever… all of the sudden, it works too. This isn’t an  
adequate fix though, since I now have a task defined in a file that  
has a name indicating it’s for something completely different, which  
will make it had as hell for me to find 10 months from now when I need  
to make a change to it.
