rbenv: version `2.2.3' is not installed (set by RBENV_VERSION environment variable)

11,437

Solution 1

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

This must be inside of deploy.rb.

Solution 2

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)

Solution 3

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.

Share:
11,437
Askar
Author by

Askar

Learning Ruby on Rails and other web dev related stuff.

Updated on June 11, 2022

Comments

  • Askar
    Askar almost 2 years

    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 [email protected]: Exception while executing as [email protected]: 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 [email protected]: 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 [email protected]: Exception while executing as [email protected]: 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.