RyanScottLewis
RyanScottLewis

Reputation: 14016

Capistrano will not create releases

When I run cap deploy, Capistrano will attempt to create a folder such as $HOME/sites/MY_APP/releases/TIMESTAMP. I can see the command attempting to run, but it will not actually create the folder.

I can copy the command directly out of the Capistrano output and run the command over SSH and it works great with no problems.

The command looks something so:

cp -RPp /home/some_user/sites/my_cool_app/shared/cached-copy /home/some_user/sites/my_cool_app/releases/20111123164239 && (echo 59bf115868c2430cd0475ca1596998f1cfa3c084 > /home/some_user/sites/my_cool_app/releases/20111123164239/REVISION)

Why would the command fail through Capistrano, but succeed through an SSH terminal?

Upvotes: 11

Views: 5638

Answers (3)

Karol Kamiński
Karol Kamiński

Reputation: 75

In my case it was a matter of adding this line into deploy.rb file

set :scm, :git

Upvotes: 0

Aleks
Aleks

Reputation: 5320

Ignore part below the green lineline, but I will keep them, just for reference for others.

The mentioned issue was happening for me when I was using Capistrano 3.9.x version. When I downgraded to version 3.4.0 it was all working.


Second part of the answer:

Once this happened to me was when the github keys were not set up in ~/.ssh/.

You should generate a ssh key on the server. Once the .pub file is generated in ~/.ssh then you should go to github.com (or any other service) and add you newly generated ssh key on the web-site (it should be found under settings page or similar). Also, on the server add a proper record in ~/.ssh/config file which matches the identification in the capistrano deploy script:

set :repo_url, proc { "[email protected]:your_git_name/#{fetch(:application)}.git" }

So the config file should look like this:

Host github.com
  HostName github.com
    User git
      IdentityFile ~/.ssh/id_rsa_my_new_key_on_the_server

Upvotes: 0

Steve Smith
Steve Smith

Reputation: 5201

I'm still not sure where the problem spans from but removing the line:

set :deploy_via, :remote_cache

Solved things for me. It looks like a bug where the releases directory isn't being created and so removing that line skips that step. A better approach if you want to keep the remote_cache is probably to add another step to setup like so:

after "deploy:setup", "deploy:create_release_dir"
namespace :deploy do
  task :create_release_dir, :except => {:no_release => true} do
    run "mkdir -p #{fetch :releases_path}"
  end
end

Upvotes: 22

Related Questions