I'm using Windows 10 and Cygwin, and I am setting up Capistrano 3 for deployment to my production environment. I believe I have everything set up correctly, but I can't figure out how to push my local repo to my production server. I don't have my repo on GitHub or another such site and would like to keep it local. I receive the following error message when I run cap production deploy
.
SSHKit::Runner::ExecuteError: Exception while executing as myappuser@myappname.website.com: git exit status: 128 git stdout: Nothing written git stderr: fatal: No remote configured to list refs from.
SSHKit::Command::Failed: git exit status: 128 git stdout: Nothing written git stderr: fatal: No remote configured to list refs from.
Tasks: TOP => git:check (See full trace by running task with --trace) The deploy has failed with an error: Exception while executing as myappuser@myappname.website.com: git exit status : 128 git stdout: Nothing written git stderr: fatal: No remote configured to list refs from.
Here's my config\deploy.rb
file:
# config valid only for current version of Capistrano
lock '3.4.0'
set :application, 'myappname
set :deploy_user, 'myappuser'
set :repo_url, "file:///C:/Users/me/Documents/repo/myappname.git"
# setup rvm.
set :rbenv_type, :user
set :rbenv_ruby, '2.1.5-p273'
set :rbenv_prefix, "RBENV_ROOT=#{fetch(:rbenv_path)} RBENV_VERSION=#{fetch(:rbenv_ruby)} #{fetch(:rbenv_path)}/bin/rbenv exec"
set :rbenv_map_bins, %w{rake gem bundle ruby rails}
set :assets_roles, [:app]
# Default value for :scm is :git
set :scm, :git
# Default value for :linked_files is []
set :linked_files, %w{config/database.yml config/application.yml}
# Default value for linked_dirs is []
set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}
# Default value for keep_releases is 5
set :keep_releases, 5
# which config files should be copied by deploy:setup_config
# see documentation in lib/capistrano/tasks/setup_config.cap
# for details of operations
set(:config_files, %w(
nginx.conf
application.yml
database.yml
unicorn.rb
unicorn_init.sh
))
# which config files should be made executable after copying
# by deploy:setup_config
set(:executable_config_files, %w(
unicorn_init.sh
))
# files which need to be symlinked to other parts of the
# filesystem. For example nginx virtualhosts, log rotation
# init scripts etc. The full_app_name variable isn't
# available at this point so we use a custom template {{}}
# tag and then add it at run time.
set(:symlinks, [
{
source: "nginx.conf",
link: "/etc/nginx/sites-enabled/{{full_app_name}}"
},
{
source: "unicorn_init.sh",
link: "/etc/init.d/unicorn_{{full_app_name}}"
},
{
source: "log_rotation",
link: "/etc/logrotate.d/{{full_app_name}}"
}
])
namespace :deploy do
# compile assets locally then rsync
after :finishing, 'deploy:cleanup'
end
All of the answers I found didn't have a solution or were for Capistrano 2, so I am wondering if the options have changed. Any help would be greatly appreciated!
EDIT
I've made some progress, but it's still not reading my local repo. Here's the error message:
SSHKit::Command::Failed: git exit status: 128 git stdout: Nothing written git stderr: fatal: '/C:/Users/me/Documents/repo/myappname.git' does not appear to be a git repository fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists.
I've tried all different path combinations for my repo. My git repo is at the following path: C:/Users/me/Documents/repo/myappname
. Is there a specific way to reference my local repo?
Unfortunately, this is not how Capistrano is designed to work. The basic assumption Capistrano makes is that your project resides in a repository that the server can access (almost always this is a Git repo hosted at e.g. Bitbucket or GitHub).
Capistrano pulls your source code by running git commands on the server. The server has no way to see your local repository, which is why it doesn't work.
There are some plugins that try to change Capistrano's behavior to allow for the push style deployment you are looking for. Search GitHub for "capistrano copy" and try them out. This one could be what you're looking for: