K
K
Kiiin2021-01-11 00:02:53
ruby
Kiiin, 2021-01-11 00:02:53

How to fix "cap aborted! rbenv: bundle: command not found"?

When deploying, I get this error:

> cap production deploy

{...}
DEBUG[d1dd96ac]     rbenv: bundle: command not found
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing on host 185.162.92.85: bundle exit status: 127
bundle stdout: Nothing written
bundle stderr: rbenv: bundle: command not found
/home/deployer/.rvm/gems/ruby-2.2.10/gems/sshkit-1.5.1/lib/sshkit/command.rb:97:in `exit_status='
/home/deployer/.rvm/gems/ruby-2.2.10/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:148:in `block (5 levels) in _execute'
/home/deployer/.rvm/gems/ruby-2.2.10/gems/net-ssh-2.9.1/lib/net/ssh/connection/channel.rb:551:in `call'
/home/deployer/.rvm/gems/ruby-2.2.10/gems/net-ssh-2.9.1/lib/net/ssh/connection/channel.rb:551:in `do_request'
/home/deployer/.rvm/gems/ruby-2.2.10/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:561:in `channel_request'
/home/deployer/.rvm/gems/ruby-2.2.10/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:465:in `dispatch_incoming_packets'
/home/deployer/.rvm/gems/ruby-2.2.10/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:221:in `preprocess'
/home/deployer/.rvm/gems/ruby-2.2.10/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:205:in `process'
/home/deployer/.rvm/gems/ruby-2.2.10/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:169:in `block in loop'
/home/deployer/.rvm/gems/ruby-2.2.10/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:169:in `loop'
/home/deployer/.rvm/gems/ruby-2.2.10/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:169:in `loop'
/home/deployer/.rvm/gems/ruby-2.2.10/gems/net-ssh-2.9.1/lib/net/ssh/connection/channel.rb:269:in `wait'
/home/deployer/.rvm/gems/ruby-2.2.10/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:170:in `block (3 levels) in _execute'
/home/deployer/.rvm/gems/ruby-2.2.10/gems/net-ssh-2.9.1/lib/net/ssh/connection/channel.rb:514:in `call'
/home/deployer/.rvm/gems/ruby-2.2.10/gems/net-ssh-2.9.1/lib/net/ssh/connection/channel.rb:514:in `do_open_confirmation'
/home/deployer/.rvm/gems/ruby-2.2.10/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:545:in `channel_open_confirmation'
/home/deployer/.rvm/gems/ruby-2.2.10/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:465:in `dispatch_incoming_packets'
/home/deployer/.rvm/gems/ruby-2.2.10/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:221:in `preprocess'
/home/deployer/.rvm/gems/ruby-2.2.10/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:205:in `process'
/home/deployer/.rvm/gems/ruby-2.2.10/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:169:in `block in loop'
/home/deployer/.rvm/gems/ruby-2.2.10/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:169:in `loop'
/home/deployer/.rvm/gems/ruby-2.2.10/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:169:in `loop'
/home/deployer/.rvm/gems/ruby-2.2.10/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:172:in `block (2 levels) in _execute'
/home/deployer/.rvm/gems/ruby-2.2.10/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:186:in `with_ssh'
/home/deployer/.rvm/gems/ruby-2.2.10/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:131:in `block in _execute'
/home/deployer/.rvm/gems/ruby-2.2.10/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:128:in `tap'
/home/deployer/.rvm/gems/ruby-2.2.10/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:128:in `_execute'
/home/deployer/.rvm/gems/ruby-2.2.10/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:66:in `execute'
/home/deployer/.rvm/gems/ruby-2.2.10/gems/capistrano-bundler-1.1.3/lib/capistrano/tasks/bundler.cap:35:in `block (5 levels) in <top (required)>'
/home/deployer/.rvm/gems/ruby-2.2.10/gems/sshkit-1.5.1/lib/sshkit/backends/abstract.rb:85:in `with'
/home/deployer/.rvm/gems/ruby-2.2.10/gems/capistrano-bundler-1.1.3/lib/capistrano/tasks/bundler.cap:26:in `block (4 levels) in <top (required)>'
/home/deployer/.rvm/gems/ruby-2.2.10/gems/sshkit-1.5.1/lib/sshkit/backends/abstract.rb:77:in `within'
/home/deployer/.rvm/gems/ruby-2.2.10/gems/capistrano-bundler-1.1.3/lib/capistrano/tasks/bundler.cap:25:in `block (3 levels) in <top (required)>'
/home/deployer/.rvm/gems/ruby-2.2.10/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:54:in `instance_exec'
/home/deployer/.rvm/gems/ruby-2.2.10/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:54:in `run'
/home/deployer/.rvm/gems/ruby-2.2.10/gems/sshkit-1.5.1/lib/sshkit/runners/parallel.rb:13:in `block (2 levels) in execute'
SSHKit::Command::Failed: bundle exit status: 127
bundle stdout: Nothing written
bundle stderr: rbenv: bundle: command not found
/home/deployer/.rvm/gems/ruby-2.2.10/gems/sshkit-1.5.1/lib/sshkit/command.rb:97:in `exit_status='
/home/deployer/.rvm/gems/ruby-2.2.10/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:148:in `block (5 levels) in _execute'
/home/deployer/.rvm/gems/ruby-2.2.10/gems/net-ssh-2.9.1/lib/net/ssh/connection/channel.rb:551:in `call'
/home/deployer/.rvm/gems/ruby-2.2.10/gems/net-ssh-2.9.1/lib/net/ssh/connection/channel.rb:551:in `do_request'
/home/deployer/.rvm/gems/ruby-2.2.10/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:561:in `channel_request'
/home/deployer/.rvm/gems/ruby-2.2.10/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:465:in `dispatch_incoming_packets'
/home/deployer/.rvm/gems/ruby-2.2.10/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:221:in `preprocess'
/home/deployer/.rvm/gems/ruby-2.2.10/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:205:in `process'
/home/deployer/.rvm/gems/ruby-2.2.10/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:169:in `block in loop'
/home/deployer/.rvm/gems/ruby-2.2.10/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:169:in `loop'
/home/deployer/.rvm/gems/ruby-2.2.10/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:169:in `loop'
/home/deployer/.rvm/gems/ruby-2.2.10/gems/net-ssh-2.9.1/lib/net/ssh/connection/channel.rb:269:in `wait'
/home/deployer/.rvm/gems/ruby-2.2.10/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:170:in `block (3 levels) in _execute'
/home/deployer/.rvm/gems/ruby-2.2.10/gems/net-ssh-2.9.1/lib/net/ssh/connection/channel.rb:514:in `call'
/home/deployer/.rvm/gems/ruby-2.2.10/gems/net-ssh-2.9.1/lib/net/ssh/connection/channel.rb:514:in `do_open_confirmation'
/home/deployer/.rvm/gems/ruby-2.2.10/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:545:in `channel_open_confirmation'
/home/deployer/.rvm/gems/ruby-2.2.10/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:465:in `dispatch_incoming_packets'
/home/deployer/.rvm/gems/ruby-2.2.10/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:221:in `preprocess'
/home/deployer/.rvm/gems/ruby-2.2.10/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:205:in `process'
/home/deployer/.rvm/gems/ruby-2.2.10/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:169:in `block in loop'
/home/deployer/.rvm/gems/ruby-2.2.10/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:169:in `loop'
/home/deployer/.rvm/gems/ruby-2.2.10/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:169:in `loop'
/home/deployer/.rvm/gems/ruby-2.2.10/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:172:in `block (2 levels) in _execute'
/home/deployer/.rvm/gems/ruby-2.2.10/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:186:in `with_ssh'
/home/deployer/.rvm/gems/ruby-2.2.10/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:131:in `block in _execute'
/home/deployer/.rvm/gems/ruby-2.2.10/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:128:in `tap'
/home/deployer/.rvm/gems/ruby-2.2.10/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:128:in `_execute'
/home/deployer/.rvm/gems/ruby-2.2.10/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:66:in `execute'
/home/deployer/.rvm/gems/ruby-2.2.10/gems/capistrano-bundler-1.1.3/lib/capistrano/tasks/bundler.cap:35:in `block (5 levels) in <top (required)>'
/home/deployer/.rvm/gems/ruby-2.2.10/gems/sshkit-1.5.1/lib/sshkit/backends/abstract.rb:85:in `with'
/home/deployer/.rvm/gems/ruby-2.2.10/gems/capistrano-bundler-1.1.3/lib/capistrano/tasks/bundler.cap:26:in `block (4 levels) in <top (required)>'
/home/deployer/.rvm/gems/ruby-2.2.10/gems/sshkit-1.5.1/lib/sshkit/backends/abstract.rb:77:in `within'
/home/deployer/.rvm/gems/ruby-2.2.10/gems/capistrano-bundler-1.1.3/lib/capistrano/tasks/bundler.cap:25:in `block (3 levels) in <top (required)>'
/home/deployer/.rvm/gems/ruby-2.2.10/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:54:in `instance_exec'
/home/deployer/.rvm/gems/ruby-2.2.10/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:54:in `run'
/home/deployer/.rvm/gems/ruby-2.2.10/gems/sshkit-1.5.1/lib/sshkit/runners/parallel.rb:13:in `block (2 levels) in execute'
Tasks: TOP => deploy:updated => bundler:install
(See full trace by running task with --trace)
The deploy has failed with an error: #<SSHKit::Runner::ExecuteError: Exception while executing on host xxx.xxx.xx.xx: bundle exit status: 127
bundle stdout: Nothing writte
bundle stderr: rbenv: bundle: command not found

How can I fix this? Mine Capfileand other info:
*Capfile*
require 'capistrano/setup'
require 'capistrano/deploy'
require 'capistrano/rbenv'
require 'capistrano/bundler'
require 'capistrano/rails/assets'
require 'capistrano/rails/migrations'
require 'whenever/capistrano'
require 'capistrano/sidekiq'
require 'capistrano/slackify'
set :rbenv_ruby, '2.2.10'
Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }

> ruby -v
ruby 2.2.10p489 (2018-03-28 revision 63023) [x86_64-linux]

> bundler -v
Bundler version 1.17.3

> which ruby
/home/deployer/.rvm/rubies/ruby-2.2.10/bin/ruby

> which bundle
/home/deployer/.rvm/gems/ruby-2.2.10/bin/bundle

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
AVKor, 2021-01-11
@AVKor


require 'capistrano/rbenv'
> which ruby
/home/deployer/.rvm/rubies/ruby-2.2.10/bin/ruby


Does this combination bother you?

V
vsuhachev, 2021-01-11
@vsuhachev

It looks like you don't have a bundler installed on the remote host. For older versions of Ruby, it was not the default gem. You need to install it with your hands on a remote host by logging in via ssh
gem install bundler

B
Brother-Ur, 2021-01-13
@Brother-Ur

Look, you have a bundler installed in the RVM control system and it is also used. This can be seen on the tracks and this was pointed out by the comrades above. And at startup, capistrano uses rbenv, tries to find a bundler there and does not find it. So it fails with an error.
Solutions:
1. Check that the required version of the banner is installed via rbenv. Maybe it's just not there.
2. Check that it is the default. It may exist, but the ruby ​​versions are rewritten locally and therefore not found.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question