Capistrano doesn't abort deployment when task fails - capistrano

Capistrano doesn't abort when the executed commands exit status is different than 0. And continues to deployment. How can I abort the deployment when the executed command fails, returns an exit status different than 0?
I tried test, execute, capture commands but couldn't make it happened. Here is the recent code that I am testing failure, I actually running real jobs. When I try to execute in on the remote server, the exit status is 1.
desc "Command to abort"
task :aborting_command do
on roles(:all) do |host|
within release_path do
execute("false")
end
end
end
end
Output of it:
INFO [0ea66341] Running /usr/bin/env false on remote-server.xxx
DEBUG [0ea66341] Command: cd /projectdir/releases/20160315140516 && /usr/bin/env false
INFO [0ea66341] Finished in 0.044 seconds with exit status 0 (successful).
With --trace:
** Invoke deploy:aborting_command (first_time)
** Execute deploy:aborting_command
DEBUG [d5f30008] Running /usr/bin/env if test ! -d /projectdir/releases/20160315140254; then echo "Directory does not exist '/projectdir/releases/20160315140254'" 1>&2; false; fi on remote-server.xxx
DEBUG [d5f30008] Command: if test ! -d /projectdir/releases/20160315140254; then echo "Directory does not exist '/projectdir/releases/20160315140254'" 1>&2; false; fi
DEBUG [d5f30008] Finished in 0.042 seconds with exit status 0 (successful).
INFO [50a2e035] Running /usr/bin/env false on remote-server.xxx
DEBUG [50a2e035] Command: cd /projectdir
INFO [50a2e035] Finished in 0.043 seconds with exit status 0 (successful).
Working on with Capistrano Version: 3.4.0 (Rake Version: 10.4.2)

Related

current-symlink isn't created with Capistrano [duplicate]

This question already has answers here:
Missing current folder Capistrano Rails 3.2
(2 answers)
Closed 7 years ago.
I'm testing out Capistrano on our new server (Debian 8.2). The process doesn't throw any errors, but still it fails to create the current-symlink.
Here's the last part of the stdout during deployment:
INFO[f2ae0d8c] Running /usr/bin/env ln -s /var/www/XYZ/releases/20151012102406 /var/www/XYZ/releases/current on YXZ
DEBUG[f2ae0d8c] Command: /usr/bin/env ln -s /var/www/XYZ/releases/20151012102406 /var/www/XYZ/releases/current
INFO[f2ae0d8c] Finished in 0.453 seconds with exit status 0 (successful).
INFO[3e8fb9d3] Running /usr/bin/env mv /var/www/XYZ/releases/current /var/www/XYZ on YXZ
DEBUG[3e8fb9d3] Command: /usr/bin/env mv /var/www/XYZ/releases/current /var/www/XYZ
INFO[3e8fb9d3] Finished in 0.163 seconds with exit status 0 (successful).
DEBUG[9908c456] Running /usr/bin/env ls -xtr /var/www/XYZ/releases on YXZ
DEBUG[9908c456] Command: /usr/bin/env ls -xtr /var/www/XYZ/releases
DEBUG[9908c456] 20151012092018 20151012091607 20151012101321 20151012101911 20151012101707
DEBUG[9908c456] 20151012102406
DEBUG[9908c456] Finished in 0.204 seconds with exit status 0 (successful).
INFOKeeping 5 of 6 deployed releases on YXZ
INFO[a38ee3db] Running /usr/bin/env rm -rf /var/www/XYZ/releases/20151012092018 on YXZ
DEBUG[a38ee3db] Command: /usr/bin/env rm -rf /var/www/XYZ/releases/20151012092018
INFO[a38ee3db] Finished in 0.143 seconds with exit status 0 (successful).
DEBUG[412fe858] Running /usr/bin/env if test ! -d /var/www/XYZ/releases; then echo "Directory does not exist '/var/www/XYZ/releases'" 1>&2; false; fi on YXZ
DEBUG[412fe858] Command: if test ! -d /var/www/XYZ/releases; then echo "Directory does not exist '/var/www/XYZ/releases'" 1>&2; false; fi
DEBUG[412fe858] Finished in 0.192 seconds with exit status 0 (successful).
INFO[3218ed31] Running /usr/bin/env echo "Branch master (at 7f394ab) deployed as release 20151012102406 by Aapo" >> /var/www/XYZ/revisions.log on YXZ
DEBUG[3218ed31] Command: echo "Branch master (at 7f394ab) deployed as release 20151012102406 by Aapo" >> /var/www/XYZ/revisions.log
INFO[3218ed31] Finished in 0.159 seconds with exit status 0 (successful).
If I login to YXZ via SSH with the same credentials as Capistrano and run
$ /usr/bin/env ln -s /var/www/XYZ/releases/20151012102406 /var/www/XYZ/releases/current
$ /usr/bin/env mv /var/www/XYZ/releases/current /var/www/XYZ
the symlinks are created just as they should.
What can be the issue?
Found the answer from Missing current folder Capistrano Rails 3.2
The option
set :use_sudo, false
had to be set in deploy.rb.

Capistrano 3.4.0, repo folder not deployed

I am currently setting up another staging server for my PHP project. I have a working, very simple cap 3 deployment running that does nothing but use the default deployment and some tidying at the end.
For some reason, deployment to the new server does not work. It just leaves out creating a repository mirror, so everything works, except fetching the releases, because there just is no repo folder to fetch from. It just prints the folder "repo" could not be found, but continues.
Do you have an idea how to troubleshoot it or am
I missing something? I just copied the working stage file and adjusted the credentials and server data. And when setting logging to debug, I can see that it reads from remote which is the newest revision, but never even tries to set up a local mirror.
I feel like I'm missing something, but there is no deploy:setup or something that I could execute beforehand.
Cheers and thanks for your help :)
** Invoke mystage (first_time)
** Execute mystage
** Invoke load:defaults (first_time)
** Execute load:defaults
** Invoke deploy (first_time)
** Execute deploy
** Invoke deploy:starting (first_time)
** Execute deploy:starting
** Invoke deploy:check (first_time)
** Execute deploy:check
** Invoke git:check (first_time)
** Invoke git:wrapper (first_time)
** Execute git:wrapper
INFO [bceb88e7] Running /usr/bin/env mkdir -p /tmp/appname/ as username#ipaddress
DEBUG [bceb88e7] Command: /usr/bin/env mkdir -p /tmp/appname/
INFO [bceb88e7] Finished in 1.370 seconds with exit status 0 (successful).
DEBUG Uploading /tmp/appname/git-ssh.sh 0.0%
INFO Uploading /tmp/appname/git-ssh.sh 100.0%
INFO [136ce820] Running /usr/bin/env chmod +x /tmp/appname/git-ssh.sh as username#ipaddress
DEBUG [136ce820] Command: /usr/bin/env chmod +x /tmp/appname/git-ssh.sh
INFO [136ce820] Finished in 1.229 seconds with exit status 0 (successful).
** Execute git:check
INFO [108b4d67] Running /usr/bin/env git ls-remote --heads git#gitlab.domain.com:arnekolja/appname.git as username#ipaddress
DEBUG [108b4d67] Command: ( GIT_ASKPASS=/bin/echo GIT_SSH=/tmp/appname/git-ssh.sh /usr/bin/env git ls-remote --heads git#gitlab.domain.com:arnekolja/appname.git )
DEBUG [108b4d67] 24bd500d547c80fc6e3af59a1d3f9cd8579a07b2 refs/heads/master
INFO [108b4d67] Finished in 2.120 seconds with exit status 0 (successful).
** Invoke deploy:check:directories (first_time)
** Execute deploy:check:directories
INFO [f513d3e7] Running /usr/bin/env mkdir -p /username/www.domain.com/shared /username/www.domain.com/releases as username#ipaddress
DEBUG [f513d3e7] Command: /usr/bin/env mkdir -p /username/www.domain.com/shared /username/www.domain.com/releases
INFO [f513d3e7] Finished in 1.222 seconds with exit status 0 (successful).
** Invoke deploy:check:linked_dirs (first_time)
** Execute deploy:check:linked_dirs
INFO [cbae6cba] Running /usr/bin/env mkdir -p /username/www.domain.com/shared/fileadmin /username/www.domain.com/shared/typo3temp /username/www.domain.com/shared/uploads as username#ipaddress
DEBUG [cbae6cba] Command: /usr/bin/env mkdir -p /username/www.domain.com/shared/fileadmin /username/www.domain.com/shared/typo3temp /username/www.domain.com/shared/uploads
INFO [cbae6cba] Finished in 1.226 seconds with exit status 0 (successful).
** Invoke deploy:check:make_linked_dirs (first_time)
** Execute deploy:check:make_linked_dirs
** Invoke deploy:check:linked_files (first_time)
** Execute deploy:check:linked_files
** Invoke deploy:set_previous_revision (first_time)
** Execute deploy:set_previous_revision
DEBUG [2ea98912] Running /usr/bin/env [ -f /username/www.domain.com/current/REVISION ] as username#ipaddress
DEBUG [2ea98912] Command: [ -f /username/www.domain.com/current/REVISION ]
DEBUG [2ea98912] Finished in 1.229 seconds with exit status 0 (successful).
DEBUG [5ccb8dbf] Running /usr/bin/env cat /username/www.domain.com/current/REVISION 2>/dev/null as username#ipaddress
DEBUG [5ccb8dbf] Command: /usr/bin/env cat /username/www.domain.com/current/REVISION 2>/dev/null
DEBUG [5ccb8dbf] Finished in 1.229 seconds with exit status 0 (successful).
** Invoke deploy:started (first_time)
** Execute deploy:started
** Invoke deploy:updating (first_time)
** Invoke deploy:new_release_path (first_time)
** Execute deploy:new_release_path
** Execute deploy:updating
** Invoke git:create_release (first_time)
** Invoke git:update (first_time)
** Invoke git:clone (first_time)
** Invoke git:wrapper
** Execute git:clone
DEBUG [ed6bb904] Running /usr/bin/env [ -f /username/www.domain.com/repo/HEAD ] as username#ipaddress
DEBUG [ed6bb904] Command: [ -f /username/www.domain.com/repo/HEAD ]
DEBUG [ed6bb904] Finished in 1.219 seconds with exit status 0 (successful).
INFO The repository mirror is at /username/www.domain.com/repo
** Execute git:update
DEBUG [a62aadce] Running /usr/bin/env if test ! -d /username/www.domain.com/repo; then echo "Directory does not exist '/username/www.domain.com/repo'" 1>&2; false; fi as username#ipaddress
DEBUG [a62aadce] Command: if test ! -d /username/www.domain.com/repo; then echo "Directory does not exist '/username/www.domain.com/repo'" 1>&2; false; fi
DEBUG [a62aadce] Directory does not exist '/username/www.domain.com/repo'
DEBUG [a62aadce] Finished in 1.225 seconds with exit status 0 (successful).
INFO [24f065b3] Running /usr/bin/env git remote update as username#ipaddress
DEBUG [24f065b3] Command: cd /username/www.domain.com/repo && ( GIT_ASKPASS=/bin/echo GIT_SSH=/tmp/appname/git-ssh.sh /usr/bin/env git remote update )
DEBUG [24f065b3] shell: line 0: cd: /username/www.domain.com/repo: No such file or directory
INFO [24f065b3] Finished in 1.288 seconds with exit status 0 (successful).
** Execute git:create_release
DEBUG [bbc9e0f5] Running /usr/bin/env if test ! -d /username/www.domain.com/repo; then echo "Directory does not exist '/username/www.domain.com/repo'" 1>&2; false; fi as username#ipaddress
DEBUG [bbc9e0f5] Command: if test ! -d /username/www.domain.com/repo; then echo "Directory does not exist '/username/www.domain.com/repo'" 1>&2; false; fi
DEBUG [bbc9e0f5] Directory does not exist '/username/www.domain.com/repo'
DEBUG [bbc9e0f5] Finished in 1.471 seconds with exit status 0 (successful).
INFO [c79a9ebf] Running /usr/bin/env mkdir -p /username/www.domain.com/releases/20150824184523 as username#ipaddress
DEBUG [c79a9ebf] Command: cd /username/www.domain.com/repo && ( GIT_ASKPASS=/bin/echo GIT_SSH=/tmp/appname/git-ssh.sh /usr/bin/env mkdir -p /username/www.domain.com/releases/20150824184523 )
DEBUG [c79a9ebf] shell: line 0: cd: /username/www.domain.com/repo: No such file or directory
INFO [c79a9ebf] Finished in 1.226 seconds with exit status 0 (successful).
INFO [1761463a] Running /usr/bin/env git archive master | tar -x -f - -C /username/www.domain.com/releases/20150824184523 as username#ipaddress
DEBUG [1761463a] Command: cd /username/www.domain.com/repo && ( GIT_ASKPASS=/bin/echo GIT_SSH=/tmp/appname/git-ssh.sh /usr/bin/env git archive master | tar -x -f - -C /username/www.domain.com/releases/20150824184523 )
DEBUG [1761463a] shell: line 0: cd: /username/www.domain.com/repo: No such file or directory
INFO [1761463a] Finished in 1.111 seconds with exit status 0 (successful).
** Invoke deploy:set_current_revision (first_time)
** Execute deploy:set_current_revision
** Invoke git:set_current_revision (first_time)
** Execute git:set_current_revision
DEBUG [75e5e6d4] Running /usr/bin/env if test ! -d /username/www.domain.com/repo; then echo "Directory does not exist '/username/www.domain.com/repo'" 1>&2; false; fi as username#ipaddress
DEBUG [75e5e6d4] Command: if test ! -d /username/www.domain.com/repo; then echo "Directory does not exist '/username/www.domain.com/repo'" 1>&2; false; fi
DEBUG [75e5e6d4] Directory does not exist '/username/www.domain.com/repo'
DEBUG [75e5e6d4] Finished in 1.342 seconds with exit status 0 (successful).
DEBUG [591e17b8] Running /usr/bin/env git rev-list --max-count=1 --abbrev-commit master as username#ipaddress
DEBUG [591e17b8] Command: cd /username/www.domain.com/repo && ( GIT_ASKPASS=/bin/echo GIT_SSH=/tmp/appname/git-ssh.sh /usr/bin/env git rev-list --max-count=1 --abbrev-commit master )
DEBUG [591e17b8] shell: line 0: cd: /username/www.domain.com/repo: No such file or directory
DEBUG [591e17b8] Finished in 1.227 seconds with exit status 0 (successful).
DEBUG [af0b741e] Running /usr/bin/env if test ! -d /username/www.domain.com/releases/20150824184523; then echo "Directory does not exist '/username/www.domain.com/releases/20150824184523'" 1>&2; false; fi as username#ipaddress
DEBUG [af0b741e] Command: if test ! -d /username/www.domain.com/releases/20150824184523; then echo "Directory does not exist '/username/www.domain.com/releases/20150824184523'" 1>&2; false; fi
DEBUG [af0b741e] Directory does not exist '/username/www.domain.com/releases/20150824184523'
DEBUG [af0b741e] Finished in 1.226 seconds with exit status 0 (successful).
INFO [1a7a9f89] Running /usr/bin/env echo "" >> REVISION as username#ipaddress
DEBUG [1a7a9f89] Command: cd /username/www.domain.com/releases/20150824184523 && /usr/bin/env echo "" >> REVISION
DEBUG [1a7a9f89] shell: line 0: cd: /username/www.domain.com/releases/20150824184523: No such file or directory
INFO [1a7a9f89] Finished in 1.275 seconds with exit status 0 (successful).
** Invoke deploy:symlink:shared (first_time)
** Execute deploy:symlink:shared
** Invoke deploy:symlink:linked_files (first_time)
** Execute deploy:symlink:linked_files
** Invoke deploy:symlink:linked_dirs (first_time)
** Execute deploy:symlink:linked_dirs
INFO [9631b1e2] Running /usr/bin/env mkdir -p /username/www.domain.com/releases/20150824184523 /username/www.domain.com/releases/20150824184523 /username/www.domain.com/releases/20150824184523 as username#ipaddress
DEBUG [9631b1e2] Command: /usr/bin/env mkdir -p /username/www.domain.com/releases/20150824184523 /username/www.domain.com/releases/20150824184523 /username/www.domain.com/releases/20150824184523
INFO [9631b1e2] Finished in 1.183 seconds with exit status 0 (successful).
DEBUG [128c1b78] Running /usr/bin/env [ -L /username/www.domain.com/releases/20150824184523/fileadmin ] as username#ipaddress
DEBUG [128c1b78] Command: [ -L /username/www.domain.com/releases/20150824184523/fileadmin ]
DEBUG [128c1b78] Finished in 1.221 seconds with exit status 0 (successful).
DEBUG [647f61de] Running /usr/bin/env [ -L /username/www.domain.com/releases/20150824184523/typo3temp ] as username#ipaddress
DEBUG [647f61de] Command: [ -L /username/www.domain.com/releases/20150824184523/typo3temp ]
DEBUG [647f61de] Finished in 1.226 seconds with exit status 0 (successful).
DEBUG [eda585b8] Running /usr/bin/env [ -L /username/www.domain.com/releases/20150824184523/uploads ] as username#ipaddress
DEBUG [eda585b8] Command: [ -L /username/www.domain.com/releases/20150824184523/uploads ]
DEBUG [eda585b8] Finished in 1.226 seconds with exit status 0 (successful).
** Invoke deploy:updated (first_time)
** Execute deploy:updated
** Invoke deploy:publishing (first_time)
** Execute deploy:publishing
** Invoke deploy:symlink:release (first_time)
** Execute deploy:symlink:release
INFO [3216ea2a] Running /usr/bin/env ln -s /username/www.domain.com/releases/20150824184523 /username/www.domain.com/releases/current as username#ipaddress
DEBUG [3216ea2a] Command: /usr/bin/env ln -s /username/www.domain.com/releases/20150824184523 /username/www.domain.com/releases/current
INFO [3216ea2a] Finished in 1.224 seconds with exit status 0 (successful).
INFO [4dffab11] Running /usr/bin/env mv /username/www.domain.com/releases/current /username/www.domain.com as username#ipaddress
DEBUG [4dffab11] Command: /usr/bin/env mv /username/www.domain.com/releases/current /username/www.domain.com
INFO [4dffab11] Finished in 1.105 seconds with exit status 0 (successful).
** Invoke deploy:published (first_time)
** Execute deploy:published
** Invoke deploy:finishing (first_time)
** Execute deploy:finishing
** Invoke deploy:cleanup (first_time)
** Execute deploy:cleanup
DEBUG [cff18115] Running /usr/bin/env ls -xtr /username/www.domain.com/releases as username#ipaddress
DEBUG [cff18115] Command: /usr/bin/env ls -xtr /username/www.domain.com/releases
DEBUG [cff18115] 20150824180444 20150824182922 20150824183624 20150824184523
DEBUG [cff18115] Finished in 1.347 seconds with exit status 0 (successful).
INFO Keeping 3 of 4 deployed releases on ipaddress
INFO [efc5b837] Running /usr/bin/env rm -rf /username/www.domain.com/releases/20150824180444 as username#ipaddress
DEBUG [efc5b837] Command: /usr/bin/env rm -rf /username/www.domain.com/releases/20150824180444
INFO [efc5b837] Finished in 1.123 seconds with exit status 0 (successful).
** Invoke deploy:notify (first_time)
** Execute deploy:notify
** Invoke deploy:finished (first_time)
** Execute deploy:finished
** Invoke deploy:log_revision (first_time)
** Execute deploy:log_revision
DEBUG [c571276a] Running /usr/bin/env if test ! -d /username/www.domain.com/releases; then echo "Directory does not exist '/username/www.domain.com/releases'" 1>&2; false; fi as username#ipaddress
DEBUG [c571276a] Command: if test ! -d /username/www.domain.com/releases; then echo "Directory does not exist '/username/www.domain.com/releases'" 1>&2; false; fi
DEBUG [c571276a] Finished in 1.372 seconds with exit status 0 (successful).
INFO [964a1750] Running /usr/bin/env echo "Branch master (at ) deployed as release 20150824184523 by arne" >> /username/www.domain.com/revisions.log as username#ipaddress
DEBUG [964a1750] Command: echo "Branch master (at ) deployed as release 20150824184523 by arne" >> /username/www.domain.com/revisions.log
INFO [964a1750] Finished in 1.096 seconds with exit status 0 (successful).
Arne-Koljas-MacBook-Air:appname.local arne$
deploy.rb (sanitized my custom hooks out of the debug output above)
lock '3.4.0'
set :application, 'appname'
set :repo_url, 'git#gitlab.domain.com:arnekolja/appname.git'
set :scm, :git
set :log_level, :debug
set :linked_dirs, fetch(:linked_dirs, []).push('fileadmin', 'typo3temp', 'uploads')
set :keep_releases, 3
namespace :deploy do
after :restart, :clear_cache do
on roles(:web), in: :groups, limit: 3, wait: 10 do
# nothing here yet
end
end
after :finishing, :notify do
on roles(:web) do
if test("[ -d #{shared_path}/typo3temp/DynCss ]")
info "Clearning cached (S)CSS file at #{shared_path}/typo3temp/DynCss/* …"
execute "rm -rf #{shared_path}/typo3temp/DynCss/*"
else
info "No (S)CSS file to remove at #{shared_path}/typo3temp/DynCss/*."
end
if test("[ -d #{shared_path}/typo3temp/Cache ]")
info "Clearning TYPO3 cache at #{shared_path}/typo3temp/Cache/* …"
execute "rm -rf #{shared_path}/typo3temp/Cache/*"
else
info "No TYPO3 cache folder at #{shared_path}/typo3temp/Cache/* (yet?), not clearing it."
end
end
end
before :starting, :mysqlbackup
desc "Backup MySQL Database"
task :mysqlbackup do
on roles(:web) do
execute "mysqldump --socket=/tmp/mysql5.sock -u#{fetch(:db_username)} -p#{fetch(:db_password)} #{fetch(:db_database)} > #{shared_path}/backups/#{release_timestamp}.sql"
execute "gzip #{shared_path}/backups/#{release_timestamp}.sql"
end
end
end
mystage.rb:
server 'ipaddress', user: 'user', roles: %w{db web}, password: 'password'
set :deploy_to, '/user/www.domain.com'
# set :pty, true
set :db_database, "db"
set :db_username, "user"
set :db_password, "pass"

'cap production setup' & 'cap production deploy' doesn't execute

I've set up all of things for deploy ruby on rails by capistrano on ubuntu server 14.10
but when i execute command by cap production setup or deploy
i've got this error message so i found out path by .rbenv/bin/rbenv but there wasn't
how can i solve this problem
following is what i got error message
thank you
**DEBUG [2814493d] Finished in 3.501 seconds with exit status 0 (successful).
DEBUG [3f8ba0c4] Running /usr/bin/env [ -d ~/.rbenv/plugins/ruby-build ] as
deployer#railserver.cloudapp.net
DEBUG [3f8ba0c4] Command: [ -d ~/.rbenv/plugins/ruby-build ]
DEBUG [3f8ba0c4] Finished in 0.012 seconds with exit status 0 (successful).
DEBUG [243e2a34] Running /usr/bin/env [ -d ~/.rbenv/versions/2.1.2 ] as
deployer#railserver.cloudapp.net
DEBUG [243e2a34] Command: [ -d ~/.rbenv/versions/2.1.2 ]
DEBUG [243e2a34] Finished in 0.009 seconds with exit status 0 (successful).
DEBUG [7a6e00da] Running RBENV_ROOT=~/.rbenv RBENV_VERSION=2.1.2 ~/.rbenv/bin/rbenv exec gem query
--quiet --installed --name-matches ^bundler$ as deployer#railserver.cloudapp.net
DEBUG [7a6e00da] Command: ( PATH=~/.rbenv/shims:~/.rbenv/bin:$PATH RBENV_ROOT=~/.rbenv
RBENV_VERSION=2.1.2 RBENV_ROOT=~/.rbenv RBENV_VERSION=2.1.2 ~/.rbenv/bin/rbenv exec gem query
--quiet --installed --name-matches ^bundler$ )
DEBUG [7a6e00da] bash: /home/deployer/.rbenv/bin/rbenv: No such file or directory
DEBUG [7a6e00da] Finished in 0.009 seconds with exit status 127 (failed).
INFO [d6c3086f] Running RBENV_ROOT=~/.rbenv RBENV_VERSION=2.1.2 ~/.rbenv/bin/rbenv exec gem install
bundler --quiet --no-rdoc --no-ri as deployer#railserver.cloudapp.net
DEBUG [d6c3086f] Command: ( PATH=~/.rbenv/shims:~/.rbenv/bin:$PATH RBENV_ROOT=~/.rbenv
RBENV_VERSION=2.1.2 RBENV_ROOT=~/.rbenv RBENV_VERSION=2.1.2 ~/.rbenv/bin/rbenv exec gem install
bundler --quiet --no-rdoc --no-ri )
DEBUG [d6c3086f] bash: /home/deployer/.rbenv/bin/rbenv: No such file or directory
(Backtrace restricted to imported tasks)
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as deployer#railserver.cloudapp.net: gem
exit status: 127
gem stdout: Nothing written
gem stderr: bash: /home/deployer/.rbenv/bin/rbenv: No such file or directory
SSHKit::Command::Failed: gem exit status: 127
gem stdout: Nothing written
gem stderr: bash: /home/deployer/.rbenv/bin/rbenv: No such file or directory
Tasks: TOP => rbenv:install_bundler
(See full trace by running task with --trace)
deployer#railserver:~/rubyonrailstest$ cap aborted!
Stage not set, please call something such as `cap production deploy`, where production is a stage
you have defined.**
I'd recommend capistrano-rbenv-install plugin. It makes problems like the one you have disappear.

Capistrano doesn't obey "within release_path"

I have this task:
namespace :custom do
desc "create a symlink to db config already on the server"
task :symlink_db_config do
on roles(:web) do
within release_path do
execute "pwd"
end
within release_path do
execute "ln -nfs /home/blog/config/database.yml ./database.yml"
end
end
end
end
For some infuriating reason, the pwd command is preceded by a cd to the release path, but the ln command is not. Why is that?
Here's the output, showing the above:
** Invoke custom:symlink_db_config (first_time)
** Execute custom:symlink_db_config
DEBUG[352cc4bb] Running /usr/bin/env if test ! -d /home/blog/staging/releases/20141010050707; then echo "Directory does not exist '/home/blog/staging/releases/20141010050707'" 1>&2; false; fi on 172.245.32.193
DEBUG[352cc4bb] Command: if test ! -d /home/blog/staging/releases/20141010050707; then echo "Directory does not exist '/home/blog/staging/releases/20141010050707'" 1>&2; false; fi
DEBUG[352cc4bb] Finished in 0.199 seconds with exit status 0 (successful).
// Here's the `pwd`; note the proper `cd` that occurs first:
INFO[67a83a04] Running /usr/bin/env pwd on 172.245.32.193
DEBUG[67a83a04] Command: cd /home/blog/staging/releases/20141010050707 && /usr/bin/env pwd
DEBUG[67a83a04] /home/blog/staging/releases/20141010050707
INFO[67a83a04] Finished in 0.268 seconds with exit status 0 (successful).
DEBUG[f46f64b3] Running /usr/bin/env if test ! -d /home/blog/staging/releases/20141010050707; then echo "Directory does not exist '/home/blog/staging/releases/20141010050707'" 1>&2; false; fi on 172.245.32.193
DEBUG[f46f64b3] Command: if test ! -d /home/blog/staging/releases/20141010050707; then echo "Directory does not exist '/home/blog/staging/releases/20141010050707'" 1>&2; false; fi
DEBUG[f46f64b3] Finished in 0.243 seconds with exit status 0 (successful).
//And now here's the `ln`... but where is the `cd`? I said `within release_path`, didn't I?
INFO[afdbd89c] Running /usr/bin/env ln -nfs /home/blog/config/database.yml ./database.yml on 172.245.32.193
DEBUG[afdbd89c] Command: ln -nfs /home/blog/config/database.yml ./database.yml
INFO[afdbd89c] Finished in 0.219 seconds with exit status 0 (successful).
So my ln fails because it's not in the right directory. Why didn't capistrano cd into the release directory like I told it to?
(Capistrano 3.2.1, by the way)
There's useful information in another answer here but briefly it seems the problem arises when there are spaces in the command you want to run.
I followed bricker's suggestion, e.g.
within release_path do
execute *%w[ ln -nfs /home/blog/config/database.yml ./database.yml ]
end

Capistrano tmp:dir error:cannot run git-ssh.sh: No such file or directory

on my server I´m not allowed to create an tmp folder that executes any content.
So with capistrano 3 I have the option to set a path for a kind of custom tmp folder.
Is there any syntax I have to consider, cause my settings execute an error with cap staging deploy:
INFO[f99c486e] Running /usr/bin/env mkdir -p custom_tmp/myproject/ on xxxx.de
DEBUG[f99c486e] Command: /usr/bin/env mkdir -p custom_tmp/myproject/
INFO[f99c486e] Finished in 1.140 seconds with exit status 0 (successful).
DEBUGUploading custom_tmp/myproject/git-ssh.sh 0.0%
INFOUploading custom_tmp/myproject/git-ssh.sh 100.0%
INFO[91b7d9b8] Running /usr/bin/env chmod +x custom_tmp/myproject/git-ssh.sh on xxxx.de
DEBUG[91b7d9b8] Command: /usr/bin/env chmod +x custom_tmp/myproject/git-ssh.sh
INFO[91b7d9b8] Finished in 0.080 seconds with exit status 0 (successful).
DEBUG[f4db290c] Running /usr/bin/env git ls-remote -h git#bitbucket.org:hallo/www.myproject.de.git on xxxx.de
DEBUG[f4db290c] Command: ( GIT_ASKPASS=/bin/echo GIT_SSH=custom_tmp/myproject/git-ssh.sh /usr/bin/env git ls-remote -h git#bitbucket.org:hallo/www.myproject.de.git )
DEBUG[f4db290c] 66791b22a61cd1af57d117a817129e491e83d88c refs/heads/master
DEBUG[f4db290c] Finished in 3.235 seconds with exit status 0 (successful).
INFO[74118c8e] Running /usr/bin/env mkdir -pv development/myproject/shared development/myproject/releases on xxxx.de
DEBUG[74118c8e] Command: /usr/bin/env mkdir -pv development/myproject/shared development/myproject/releases
INFO[74118c8e] Finished in 0.079 seconds with exit status 0 (successful).
INFO[10e40636] Running /usr/bin/env mkdir -pv development/myproject/shared/media on xxxx.de
DEBUG[10e40636] Command: /usr/bin/env mkdir -pv development/myproject/shared/media
INFO[10e40636] Finished in 0.086 seconds with exit status 0 (successful).
DEBUG[38889a64] Running /usr/bin/env [ -f development/myproject/current/REVISION ] on xxxx.de
DEBUG[38889a64] Command: [ -f development/myproject/current/REVISION ]
DEBUG[38889a64] Finished in 0.079 seconds with exit status 1 (failed).
DEBUG[5dfc387f] Running /usr/bin/env [ -f development/myproject/repo/HEAD ] on xxxx.de
DEBUG[5dfc387f] Command: [ -f development/myproject/repo/HEAD ]
DEBUG[5dfc387f] Finished in 0.095 seconds with exit status 1 (failed).
DEBUG[44d0214c] Running /usr/bin/env if test ! -d development/myproject/; then echo "Directory does not exist 'development/myproject/'" 1>&2; false; fi on xxxx.de
DEBUG[44d0214c] Command: if test ! -d development/myproject/; then echo "Directory does not exist 'development/myproject/'" 1>&2; false; fi
DEBUG[44d0214c] Finished in 0.079 seconds with exit status 0 (successful).
INFO[dac1f8fd] Running /usr/bin/env git clone --mirror git#bitbucket.org:hallo/www.myproject.de.git development/myproject/repo on xxxx.de
DEBUG[dac1f8fd] Command: cd development/myproject/ && ( GIT_ASKPASS=/bin/echo GIT_SSH=custom_tmp/myproject/git-ssh.sh /usr/bin/env git clone --mirror git#bitbucket.org:hallo/www.myproject.de.git development/myproject/repo )
DEBUG[dac1f8fd] Cloning into bare repository development/myproject/repo...
DEBUG[dac1f8fd] error: cannot run custom_tmp/myproject/git-ssh.sh: No such file or directory
DEBUG[dac1f8fd] fatal: unable to fork
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing on host xxxx.de: git exit status: 128
git stdout: Nothing written
git stderr: Nothing written
On my server the folder "custom_tmp/myproject/" ist still there with there with the git-ssh.sh. So I wonder about the error.
Here my deploy.rb
#config valid only for Capistrano 3.1
lock '3.2.1'
set :application, 'myproject'
set :repo_url, 'git#bitbucket.org:hallo/www.myproject.de.git'
# Default deploy_to directory is /var/www/my_app
set :deploy_to, 'development/myproject/'
#Default value for :scm is :git
#set :scm, :git
#Default value for :format is :pretty
#set :format, :pretty
# Default value for :log_level is :debug
set :log_level, :debug
#Default value for :pty is false
set :pty, true
# Default value for :linked_files is []
# set :linked_files, %w{config/database.yml}
# Default value for linked_dirs is []
set :linked_dirs, %w{media}
#tmp dir
set :tmp_dir,"custom_tmp"
namespace :deploy do
desc 'Restart application'
task :restart do
on roles(:app) do
# Your restart mechanism here, for example:
# execute :touch, release_path.join('tmp/restart.txt')
end
end
end
Okay, I´m one step closer.
The path to my tmp dir wasn´t correct.
I did an pwd on my server and put the shown path in front of my "custom_tmp" like:
set :tmp_dir,"/cutomer/homeages/13/233232/custom_tmp"
But the cap staging deploy interrupt by an new error depending on the repo folder:
fatal: destination path 'development/www.myproject.com/repo' already exists and is not an empty directory.
okay,
I got it.
Have to do the same with the:
set :deploy_to