Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a very simple task called update_feeds:

desc "Update feeds"
task :update_feeds do
  run "cd #{release_path}"
  run "script/console production"
  run "FeedEntry.update_all"
end

Whenever I try to run this task, I get the following message:

[out :: mysite.com] sh: script/console: No such file or directory

I figured it's because I am not in the right directory, but trying

run "cd ~/user/mysite.com/current"

instead of

run "cd #{release_path}"

Also fails. Running the exact same commands manually (through ssh) works perfectly. Why can't capistrano properly cd (change directory) into the site directory to run the command?

Thanks!

share|improve this question

2 Answers 2

up vote 5 down vote accepted

Each run command basically executes within its own shell environment. So you would need to do something like:

run "cd #{release_path} && script/console production"

However, you cannot run commands in script/console this way as script/console is for interactive usage.

What you want is script/runner like so:

run "cd #{release_path} && script/runner -e production 'FeedEntry.update_all'"

I hope that helps.

share|improve this answer

You should use:

execute "cd #{release_path} && script/console production"

With capistrano 3.x

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.