7

When I run a deploy script, I'm having errors:

[cb123fad]  rbenv: version `2.2.3' is not installed (set by RBENV_VERSION environment variable)
DEBUG [cb123fad]
(Backtrace restricted to imported tasks)
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as deploy@xx.xx.xx.xx: Exception while executing as deploy@xx.xx.xx.xx: bundle exit status: 1
bundle stdout: rbenv: version `2.2.3' is not installed (set by RBENV_VERSION environment variable)
bundle stderr: Nothing written

SSHKit::Runner::ExecuteError: Exception while executing as deploy@xx.xx.xx.xx: bundle exit status: 1
bundle stdout: rbenv: version `2.2.3' is not installed (set by RBENV_VERSION environment variable)
bundle stderr: Nothing written

SSHKit::Command::Failed: bundle exit status: 1
bundle stdout: rbenv: version `2.2.3' is not installed (set by RBENV_VERSION environment variable)
bundle stderr: Nothing written

Tasks: TOP => deploy:initial
(See full trace by running task with --trace)
The deploy has failed with an error: Exception while executing as deploy@xx.xx.xx.xx: Exception while executing as deploy@xx.xx.xx.xx: bundle exit status: 1
bundle stdout: rbenv: version `2.2.3' is not installed (set by RBENV_VERSION environment variable)
bundle stderr: Nothing written

Capfile has set :rbenv_ruby, '2.2.3'

Server and locally I have installed ruby 2.2.3p173

Changing the value from 2.2.3 to 2.2.3p173 for set :rbenv_ruby didn't work.

Askar
  • 5,784
  • 10
  • 53
  • 96

3 Answers3

23

I solved the same problem setting :rbenv_path. Yours should be:
set :rbenv_path, '/home/your/.rbenv/'

This must be inside of deploy.rb.

Askar
  • 5,784
  • 10
  • 53
  • 96
yysskk
  • 346
  • 2
  • 4
  • 1
    Hi! Unfortunately just adding `set :rbenv_path` in the `Capfile` didn't work for me. Thanks for your time. – Askar Dec 07 '15 at 12:04
  • 1
    This should be in deploy.rb, not Capfile. – will_in_wi Dec 07 '15 at 12:12
  • This fails for me `set :rbenv_path, '~/.rbenv'` in deploy.rb. The path is correct because if I alter it, cap immediately hits an error... This is something introduced recently; previous deploys were working. I really don't get it – Jerome Dec 10 '15 at 16:13
  • Thanx! You made my day. I was struggling with this problem for an hour :) However, strange, cause `ruby -v` showed correct version in my case, and `bundle update` etc. worked also OK. So this seems exclusively related to deployment with Capistrano. – kovpack Dec 15 '15 at 23:19
  • Like @jerome mentioned, you could abbreviate the path to a generic one: `$HOME/.rbenv`. This did work for me. – Besi Sep 18 '17 at 15:54
7

https://github.com/capistrano/sshkit/issues/303 and https://github.com/capistrano/rbenv/pull/59

NOTES

set :rbenv_path, '/home/your/.rbenv/' # works
set :rbenv_path, '~your/.rbenv/' # doesn't work

This issue is created due to a change in sshkit.

diff --git a/Gemfile.lock b/Gemfile.lock
index b85dabe..a909ee0 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -57,6 +57,7 @@ GEM
     code_metrics (0.1.3)
     coderay (1.1.0)
     colored (1.2)
+    colorize (0.7.7)
     concord (0.1.5)
       adamantium (~> 0.2.0)
       equalizer (~> 0.0.9)
@@ -215,7 +216,8 @@ GEM
     slop (3.6.0)
     spoon (0.0.4)
       ffi
-    sshkit (1.8.1)
+    sshkit (1.7.1)
+      colorize (>= 0.7.0)
       net-scp (>= 1.1.2)
       net-ssh (>= 2.8.0)
     terminal-table (1.5.2)
paul.belt
  • 289
  • 3
  • 3
5

The above answere did not work for me. gem update --system, then bundle install would lead to a fatal: No live threads left. Deadlock? error.

bundle exec cap development deploy

completes the deployment if gem 'sshkit', '~> 1.7.1' is spedified.

However, what may occur is that sshkitgem might get updated to 1.8.0or greater. In that case, assuming a standard Ubuntu server set-up, in deploy.rb

set :rbenv_path, '$HOME/.rbenv'

will allow deployments to complete.

Jerome
  • 5,583
  • 3
  • 33
  • 76