Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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"

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

[out ::] 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/"

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?


share|improve this question
up vote 6 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

The proper way of doing this is using within like that:

within variable_with_the_folder_path do
    execute :command, parameter

for example:

    # Bower Cache Clean:
    bower_path = fetch(:bower_path)
    within bower_path do
      execute :node, "#{bower_path_to_bin}", 'cache clean'
share|improve this answer
How can I take the output of an execute command in a variable ? – Arihant Godha Jan 7 '15 at 13:46

Your Answer


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.