kenji
kenji

Reputation: 23

cap production deploy fail with bundle

sudo cap production deploy

(Backtrace restricted to imported tasks) cap aborted! SSHKit::Runner::ExecuteError: Exception while executing as [email protected]: bundle exit status: 127 bundle stdout: Nothing written bundle stderr: /usr/bin/env: 'bundle': No such file or directory

SSHKit::Command::Failed: bundle exit status: 127 bundle stdout: Nothing written bundle stderr: /usr/bin/env: 'bundle': No such file or directory

Tasks: TOP => deploy:updated => bundler:install (See full trace by running task with --trace) The deploy has failed with an error: Exception while executing as [email protected]: bundle exit status: 127 bundle stdout: Nothing written bundle stderr: /usr/bin/env: 'bundle': No such file or directory

** DEPLOY FAILED ** Refer to log/capistrano.log for details. Here are the last 20 lines:

DEBUG [fee00417] Finished in 0.208 seconds with exit status 1 (failed).

INFO [833f8be9] Running /usr/bin/env ln -s /home/deploy/qastflood/shared/public/assets /home/deploy/qastflood/releases/20170504134248/public/assets as [email protected]

DEBUG [833f8be9] Command: /usr/bin/env ln -s /home/deploy/qastflood/shared/public/assets /home/deploy/qastflood/releases/20170504134248/public/assets

INFO [833f8be9] Finished in 0.122 seconds with exit status 0 (successful).

DEBUG [a48a6eba] Running if test ! -d /home/deploy/qastflood/releases/20170504134248; then echo "Directory does not exist '/home/deploy/qastflood/releases/20170504134248'" 1>&2; false; fi as [email protected]

DEBUG [a48a6eba] Command: if test ! -d /home/deploy/qastflood/releases/20170504134248; then echo "Directory does not exist '/home/deploy/qastflood/releases/20170504134248'" 1>&2; false; fi

DEBUG [a48a6eba] Finished in 0.194 seconds with exit status 0 (successful).

DEBUG [83174667] Running /usr/bin/env bundle check --path /home/deploy/qastflood/shared/bundle as [email protected]

DEBUG [83174667] Command: cd /home/deploy/qastflood/releases/20170504134248 && /usr/bin/env bundle check --path /home/deploy/qastflood/shared/bundle

DEBUG [83174667] /usr/bin/env:

DEBUG [83174667] 'bundle'

DEBUG [83174667] : No such file or directory

DEBUG [83174667]

DEBUG [83174667] Finished in 0.119 seconds with exit status 127 (failed).

INFO [c0e5b256] Running /usr/bin/env bundle install --path /home/deploy/qastflood/shared/bundle --without development test --deployment --quiet as [email protected]

DEBUG [c0e5b256] Command: cd /home/deploy/qastflood/releases/20170504134248 && /usr/bin/env bundle install --path /home/deploy/qastflood/shared/bundle --without development test --deployment --quiet

DEBUG [c0e5b256] /usr/bin/env:

DEBUG [c0e5b256] 'bundle'

DEBUG [c0e5b256] : No such file or directory

DEBUG [c0e5b256]

I can't deploy Ruby on Rails in Digitalocean

I try with https://gorails.com/deploy/ubuntu/16.04

In the last step >> cap production deploy I have bug that you see on top

Upvotes: 1

Views: 909

Answers (1)

James H
James H

Reputation: 1832

This is an issue with how Capsitrano uses a non-interactive, non-login shell by default. In other words, bundle is not in the $PATH because of the way Capistrano logs in.

There is a very long discussion of this topic in the online Capistrano docs: https://capistranorb.com/documentation/faq/why-does-something-work-in-my-ssh-session-but-not-in-capistrano/

The fix is to figure out where bundle is installed and then add it to your path in ~/.bashrc (which should be loaded for non-login, non-interactive shells).

To avoid adding it twice, you can either carefully reconfigure all the insane layering of bash config files so it works correctly, or you can do some $PATH sniffing and conditionally add the path with something like:

path_to_bundle="/some/path"
if [ -n "${PATH##*${path_to_bundle}}" -a -n "${PATH##*${path_to_bundle}:*}" ]; then
    export PATH=$PATH:${path_to_bundle}
fi

Upvotes: 1

Related Questions