Rake weirdness (production vs development)

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.

On Sep 2, 5:52 pm, Jon G. [email protected] 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
softiesonrails.com

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.

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.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs