Search code examples
ruby-on-railsdeploymentcapistranoproduction

Rails deployment with Capistrano failing


I'm pretty new to RoR and deploying apps like these into production, so I've been doing quite a bit of reading.

There's one problem I can't seem to get past however. During my investigation, I came upon a thread on SO that indicates the behavior of Capistrano v3.x changed, which has confused some people.

One thing the thread detailed to do, was implement a remote file check, and if it doesn't exist during deployment, declare the local file to upload (which is my interpretation).

The following was added into my config/deploy.rb:

namespace :deploy do
  namespace :check do
    task :linked_files => 'config/database.yml'
  end
  remote_file 'config/database.yml' => '/home/ubuntu/workspace/config/database.yml'
...
end

I'm working within Cloud9 IDE. When I run the cap production deploy command, the following excerpt from the deployment log is returned:

INFO [5cccd59b] Running /usr/bin/env mkdir -pv /home/deploy/--------/shared/config as [email protected]
DEBUG [5cccd59b] Command: /usr/bin/env mkdir -pv /home/deploy/--------/shared/config
INFO [5cccd59b] Finished in 0.068 seconds with exit status 0 (successful).
DEBUG [bd9797ee] Running /usr/bin/env [ -f /home/deploy/--------/shared/deploy:config/database.yml ] as [email protected]
DEBUG [bd9797ee] Command: [ -f /home/deploy/--------/shared/deploy:config/database.yml ]
DEBUG [bd9797ee] Finished in 0.067 seconds with exit status 1 (failed).
INFO Uploading /home/ubuntu/workspace/config/database.yml to /home/deploy/--------/shared/deploy:config/database.yml
DEBUG Uploading /home/deploy/--------/shared/deploy:config/database.yml 0.0%
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as [email protected]: scp: /home/deploy/--------/shared/deploy:config/database.yml: No such file or directory

I don't know 100%, but it seems to me that the path that it's auto inserting with the : is throwing off the script.

Any guidance is appreciated!

Thanks in advance,

Gabrial


Solution

  • You should call remote_file without any namespaces.

    namespace :deploy do
      namespace :check do
        task :linked_files => 'config/database.yml'
      end
    ...
    end
    
    remote_file 'config/database.yml' => '/home/ubuntu/workspace/config/database.yml'