Giter Site home page Giter Site logo

rbenv's Introduction

Capistrano::rbenv

This gem provides idiomatic rbenv support for Capistrano 3.x (and 3.x only).

Please Note

If you want to use this plugin with Cap 2.x, please use 1.x version of the gem. Source code and docs for older integration is available in another repo

Thanks a lot to @yyuu for merging his gem with official one.

Installation

Add this line to your application's Gemfile:

gem 'capistrano', '~> 3.9'
gem 'capistrano-rbenv', '~> 2.2'

And then execute:

$ bundle install

Usage

# Capfile
require 'capistrano/rbenv'


# config/deploy.rb
set :rbenv_type, :user # or :system, or :fullstaq (for Fullstaq Ruby), depends on your rbenv setup
set :rbenv_ruby, '2.4.2'

# in case you want to set ruby version from the file:
# set :rbenv_ruby, File.read('.ruby-version').strip

set :rbenv_prefix, "RBENV_ROOT=#{fetch(:rbenv_path)} RBENV_VERSION=#{fetch(:rbenv_ruby)} #{fetch(:rbenv_path)}/bin/rbenv exec"
set :rbenv_map_bins, %w{rake gem bundle ruby rails}
set :rbenv_roles, :all # default value

If your rbenv is located in some custom path, you can use rbenv_custom_path to set it.

Defining the ruby version

To set the Ruby version explicitly, add :rbenv_ruby to your Capistrano configuration:

# config/deploy.rb
set :rbenv_ruby, '2.4.2'

Alternatively, allow the remote host's rbenv to determine the appropriate Ruby version by omitting :rbenv_ruby. This approach is useful if you have a .ruby-version file in your project.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

rbenv's People

Contributors

creitve avatar dmarkow avatar eddiesel avatar foobarwidget avatar guillehorno avatar ivanovaleksey avatar jonhyman avatar kirs avatar knejad avatar koenpunt avatar leehambley avatar mattbrictson avatar miry avatar neektza avatar paviensky avatar rmoriz avatar seenmyfate avatar spikeheap avatar will-in-wi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rbenv's Issues

Issue with capistrano/rbenv

[84][chimkan: /Users/chimkan/Core/sources/basic.chimkan.com]$ cap -vT
cap aborted!
no such file to load -- capistrano/rbenv
org/jruby/RubyKernel.java:1082:in `require'
/Users/chimkan/Core/sources/basic.chimkan.com/Capfile:19:in `(root)'
org/jruby/RubyKernel.java:1101:in `load'
org/jruby/RubyKernel.java:1101:in `load'
(See full trace by running task with --trace)

I'm using JRUBY 1.7.5 and I have the gem capistrano-rbenv installed

 gem "capistrano-rbenv" , github: "capistrano/rbenv"

Am I missing anything?

User .ruby-version to determine ruby version?

Is it reasonable to use the .ruby-version file to set the appropriate ruby version (and override it by setting rbenv_ruby?

I think this avoids having the ruby version set in two different places.

edit: whups - missed the closed dup of this:
set :rbenv_ruby, File.read('.ruby-version').strip

.ruby-version support

Hey, I'm trying to use cap v3, with capistrano-rbenv but I get "rbenv: rbenv_ruby is not set"

I haven't set the rbenv_ruby variable because I already have a .ruby-version file in my proyect that define the ruby version. So I don't want to repeat that information in two locations.

Does capistrano-rbenv supports .ruby-version files to get the version in any wat?

Does it make any sense?? If it doesn't support and it make sense I can to make a PR providing that functionality…..

thanks!

Different rbenv's behaviour

Hello.

I've two servers (staging and vagrant). Both are set as a separate environments (config/deploy/staging.rb, config/deploy/vagrant.rb).

On staging I've user's rbenv (/~.rbenv), on vagrant it's system (/opt/rbenv).

deploy.rb:
set :rbenv_ruby, '2.1.2'
set :rbenv_map_bins, %w{rake gem bundle ruby rails}
set :rbenv_roles, :all # default value

staging.rb:
set :rbenv_custom_path, '~/.rbenv'
set :rbenv_type, :user
set :rbenv_prefix, "RBENV_ROOT=#{fetch(:rbenv_path)} RBENV_VERSION=#{fetch(:rbenv_ruby)} #{fetch(:rbenv_path)}/bin/rbenv exec"

vagrant.rb
set :rbenv_type, :system # or :system, depends on your rbenv setup
set :rbenv_custom_path, '/opt/rbenv'
set :rbenv_prefix, "RBENV_ROOT=#{fetch(:rbenv_path)} RBENV_VERSION=#{fetch(:rbenv_ruby)} #{fetch(:rbenv_path)}/bin/rbenv exec"

Whatever I'm runing (cap staging deploy, cap vagrant deploy) it always tries to use user rbenv and throws error if it's not found:

virvit$ cap vagrant deploy
DEBUG [fe6d5d20] Running /usr/bin/env [ ! -d ~/.rbenv/versions/2.1.2 ] on 192.168.33.10
DEBUG [fe6d5d20] Command: [ ! -d ~/.rbenv/versions/2.1.2 ]
DEBUG [fe6d5d20] Finished in 0.127 seconds with exit status 0 (successful).
ERROR rbenv: 2.1.2 is not installed or not found in ~/.rbenv/versions/2.1.2

Thank you for any advice or help.

rbenv:validate failing for installed ruby version

I'm getting the following error when running bundle exec cap staging rbenv:validate:

DEBUG [658b6acd] Running /usr/bin/env [ ! -d ~/.rbenv/versions/2.0.0-p247 ] on staging.mysite.com
DEBUG [658b6acd] Command: [ ! -d ~/.rbenv/versions/2.0.0-p247 ]
DEBUG [658b6acd] Finished in 3.986 seconds with exit status 1 (failed).

when I have confirmed that the correct version is in fact installed at that location on my staging machine:

$ ls -al ~/.rbenv/versions
drwxrwxr-x  3 myuser mygrp 4096 Dec 31 05:59 .
drwxr-xr-x 10 myuser mygrp 4096 Aug 14 06:19 ..
drwxr-xr-x  6 myuser mygrp 4096 Aug 14 06:18 2.0.0-p247

I am using 2.0.0 with the configuration from your README:

set :rbenv_type, :user
set :rbenv_ruby, '2.0.0-p247'
set :rbenv_prefix, "RBENV_ROOT=#{fetch(:rbenv_path)} RBENV_VERSION=#{fetch(:rbenv_ruby)} #{fetch(:rbenv_path)}/bin/rbenv exec"
set :rbenv_map_bins, %w{rake gem bundle ruby rails}
set :rbenv_roles, :all # default value

Any insight is greatly appreciated.

Can't find rbenv, probably pty issue

This is probably a pty and configuration issue on my part, but I can't get Capistrano to detect rbenv.

❯ be cap staging deploy --dry-run
 INFO [8e94716d] Running [ ! -d ~/.rbenv/versions/2.0.0-p247 ] on redacted
DEBUG [8e94716d] Command: [ ! -d ~/.rbenv/versions/2.0.0-p247 ]
ERROR rbenv: 2.0.0-p247 is not installed or not found in ~/.rbenv/versions/2.0.0-p247

Running [ ! -d ~/.rbenv/versions/2.0.0-p247 ] on the machine with an interactive shell returns the following:

❯ [ ! -d ~/.rbenv/versions/2.0.0-p247 ]                                                                                                                                                                                                                                         2.0.0-p247

❯ echo "$?"                                                                                                                                                                                                                                                                     2.0.0-p247
1

I've tried set :pty, true and set :pty, false and neither setting helps. What should I do to debug this? The default shell on the server is zsh.

rbenv_map_bins not set

I keep getting the follow error. Tried to debug but I'm stuck.

undefined method include?' for nil:NilClass /Users/matbox/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/bundler/gems/rbenv-362dbc02ef96/lib/capistrano/tasks/rbenv.rake:6:inblock in <top (required)>'
...

Looks like for some reason rbenv_map_bins is not set (OS Mavericks). How can that happen?

My environment:

$ rbenv -v
rbenv 0.4.0-74-g95a039a

$ which ruby
/Users/matbox/.rbenv/shims/ruby

$ ruby -v
ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-darwin13.0.0]

Some relevant lines from my Gemfile:

require 'capistrano/rbenv'
require 'capistrano/bundler'
require 'capistrano/rails/assets'

set :rbenv_type, :user
set :rbenv_ruby, '2.0.0p-247'

Licence missing in the rubygems version and in the gemspec

The "capistrano-rbenv" gem seems not to have a license at all. Unless a license that specifies otherwise is included, nobody else can use, copy, distribute, or modify that library without being at risk of take-downs, shake-downs, or litigation.

I know, that this gem has a license on github, however it's missing one at rubygems and in a gemspec.

zrzut ekranu z 2018-09-03 11-07-32

Cannot require 'capistrano/rbenv'

I'm trying to upgrade a Rails project to use Capistrano 3. I'm encountering the following error:

> cap -T
cap aborted!
no such file to load -- capistrano/rbenv
org/jruby/RubyKernel.java:1082:in `require'
Capfile:3:in `(root)'
org/jruby/RubyKernel.java:1101:in `load'
org/jruby/RubyKernel.java:1101:in `load'
(See full trace by running task with --trace)

Gemfile:

group :development do
  gem 'capistrano', '~> 3.0', require: false
  gem 'capistrano-bundler', require: false
  gem 'capistrano-rails', require: false
  gem 'capistrano-rbenv', github: 'capistrano/rbenv', require: false
end

Capfile:

require 'capistrano/setup'
require 'capistrano/deploy'
require 'capistrano/rbenv'
require 'capistrano/bundler'
require 'capistrano/rails/assets'
require 'capistrano/rails/migrations'

Removing the offending line allows me to see the tasks and run through most of my deploy script (apart from tasks that require rbenv support). Any ideas?

Could not locate Gemfile

Using rbenv
gem 'capistrano', '> 3.4.0'
gem 'capistrano-rails', '
> 1.1.3'
gem 'capistrano-bundler', '> 1.1.4'
gem 'capistrano-rbenv', '
> 2.0.3'

set :rbenv_type, :user # or :system, depends on your rbenv setup
set :rbenv_ruby, "2.2.0"
set :rbenv_prefix, "RBENV_ROOT=#{fetch(:rbenv_path)} RBENV_VERSION=#{fetch(:rbenv_ruby)} #{fetch(:rbenv_path)}/bin/rbenv exec"
set :rbenv_map_bins, %w{rake gem bundle ruby rails}
set :rbenv_roles, :all # default value

When I try execute mailman_daemon with capistrano I have this error. I'm with this for two days. The command "bundle exec mailman_daemon start" works on console

namespace :mailman do  
  desc "Mailman::Start"
  task :start do 
    on roles(:app) do
      with rails_env: fetch(:rails_env) do
        execute :bundle, :exec, :'script/mailman_daemon start', :args=> :start
      end
    end
    # on roles(:app) do
    #   execute "cd #{current_path}&& bundle exec script/mailman_daemon start", raise_on_non_zero_exit: false
    # end
  end
$ cap mailman:start
DEBUG[23824710] Running /usr/bin/env [ -d ~/.rbenv/versions/2.2.0 ] on gestor.imentore.com.br
DEBUG[23824710] Command: [ -d ~/.rbenv/versions/2.2.0 ] 
DEBUG[23824710] Finished in 2.018 seconds with exit status 0 (successful).
INFO[4a2f3d68] Running RBENV_ROOT=~/.rbenv RBENV_VERSION=2.2.0 ~/.rbenv/bin/rbenv exec                          
bundle exec script/mailman_daemon start on gestor.imentore.com.br
DEBUG[4a2f3d68] Command: ( RBENV_ROOT=~/.rbenv RBENV_VERSION=2.2.0 RAILS_ENV=production RBENV_ROOT=~/.rbenv RBENV_VERSION=2.2.0 ~/.rbenv/bin/rbenv exec bundle exec script/mailman_daemon start )
DEBUG[4a2f3d68]     [31mCould not locate Gemfile[0

rbenv:install task?

Because of the nth time installing rbenv manually I wrote the following lines, which adds cap #{env} rbenv:install to the list of available tasks. It may relate to this request (never tried the 2.x version): #51

namespace :rbenv do
  desc 'Install rbenv'
  task :install do
    on roles(:web) do
      begin
        execute "git clone https://github.com/rbenv/rbenv.git #{fetch(:rbenv_path)}"
      rescue SSHKit::Command::Failed
        puts "rbenv already installed, updating..."
        execute "cd #{fetch(:rbenv_path)} && git pull"
      end        
      # execute "~/.rbenv/bin/rbenv init"
      execute "mkdir -p #{fetch(:rbenv_path)}/plugins"
      begin
        execute "git clone https://github.com/rbenv/ruby-build.git #{fetch(:rbenv_path)}/plugins/ruby-build"
      rescue SSHKit::Command::Failed
        puts "rbenv/ruby-build plugin already installed, updating..."
        execute "cd #{fetch(:rbenv_path)}/plugins/ruby-build && git pull"
      end   
      rbenv_ruby = File.read('.ruby-version').strip
      execute "#{fetch(:rbenv_path)}/bin/rbenv install -s #{fetch(:rbenv_ruby)||rbenv_ruby}"
      execute "#{fetch(:rbenv_path)}/bin/rbenv global #{fetch(:rbenv_ruby)||rbenv_ruby}"
      execute "#{fetch(:rbenv_path)}/shims/gem install bundler --no-document"
      if fetch(:rbenv_ruby).nil?
        puts "\nPlease uncomment the line `# set :rbenv_ruby, File.read('.ruby-version').strip` to enable capistrano rbenv"
      end
    end
  end
end

I'm happy to prepare a pull request...

command exit status not corret

when I run

./bin/cap production rbenv:check

I got these output

DEBUG [58700ea4] Running [ ! -d /usr/local/rbenv/versions/ruby-2.0.0-p247 ] on 60.191.205.88
DEBUG [58700ea4] Command: [ ! -d /usr/local/rbenv/versions/ruby-2.0.0-p247 ]
DEBUG [58700ea4] Finished in 0.504 seconds command failed.

the check is actually pass ,but the debug message tell me it's failed....

I found it seems the test method of sshkit will set the exit_status to 1 if the expression value is false.
so using

  if test "[ ! -d #{fetch(:rbenv_ruby_dir)} ]"

the debug message is command failed
and using

  unless test "[ -d #{fetch(:rbenv_ruby_dir)} ]"

the debug message is command successful

I'm not sure this should be fixed by sshkit or here..

rbenv_custom_path doesn't work

I set :rbenv_custom_path, shared_path.join('rbenv') in my config/deploy.rb, but capistrano doesn't seem to pick up the setting. It looks like the :rbenv_path variable set in the load:defaults task is only getting called once, and that before the Capfile is run (so :rbenv_custom_path isn't set yet).

Overriding :rbenv_path directly (instead of :rbenv_custom_path) in my Capfile works.

My Capfile:

# Load DSL and Setup Up Stages
require 'capistrano/setup'

# Includes default deployment tasks
require 'capistrano/deploy'
require 'capistrano/maintenance'
require 'capistrano/bundler'
require 'capistrano/rails'
require 'capistrano/rbenv'

# Loads custom tasks from `lib/capistrano/tasks' if you have any defined.
Dir.glob('lib/capistrano/tasks/*.cap').each { |r| import r }

My config/deploy.rb:

# config valid only for Capistrano 3.1
lock '3.1.0'

set :application, 'web'
set :repo_url, '[email protected]:me/web.git'
[...]

set :rbenv_ruby, '2.1.2'
set :rbenv_prefix, "RBENV_ROOT=#{fetch(:rbenv_path)} RBENV_VERSION=#{fetch(:rbenv_ruby)} #{fetch(:rbenv_path)}/bin/rbenv exec"
set :rbenv_map_bins, %w{rake gem bundle ruby rails}
set :rbenv_custom_path, shared_path.join('rbenv')

and yet:

$ bundle exec cap production rbenv:validate
DEBUG [8188b910] Running /usr/bin/env [ ! -d ~/.rbenv/versions/2.1.2 ] on app1.r23s.net
DEBUG [8188b910] Command: [ ! -d ~/.rbenv/versions/2.1.2 ]
DEBUG [8188b910] Finished in 1.510 seconds with exit status 0 (successful).
ERROR rbenv: 2.1.2 is not installed or not found in ~/.rbenv/versions/2.1.2

sshkit dependency problem

Hello,

I'm having problems when running bundle install.
It displays this error:

screen shot 2013-12-16 at 10 23 54 pm

Here are my gems

gem 'capistrano', '~> 3.0.1'
gem 'capistrano-bundler', '~> 1.0.0'
gem 'capistrano-rails', '~> 1.0.0'
gem 'capistrano-rbenv', '~> 2.0'

Thanks.

specifying and updating bundler

unfortunately, bundler fails if it finds a 2.0 lockfile.

for this and other use-cases, it would be great to

a) specify a specific bundler version
b) have a task to update it

is this a suitable place to propse this feature?

Capistrano Deploy Not Working

I'm a newbie, deploying to my first production environment. I ran into this and don't know what's going on:

➜  bankruptcy_sleuth git:(master) ✗ bundle exec cap production deploy --trace
** Invoke production (first_time)
** Execute production
** Invoke load:defaults (first_time)
** Execute load:defaults
** Invoke deploy (first_time)
** Execute deploy
** Invoke deploy:starting (first_time)
** Invoke deploy:set_rails_env (first_time)
** Execute deploy:set_rails_env
** Invoke deploy:set_shared_assets (first_time)
** Execute deploy:set_shared_assets
** Invoke deploy:hook_rbenv_bins (first_time)
** Execute deploy:hook_rbenv_bins
** Invoke rbenv:check (first_time)
** Execute rbenv:check
DEBUG [3d41b1a7] Running [ ! -d ~/.rbenv/versions/2.0.0-p353 ] on 162.243.241.94
DEBUG [3d41b1a7] Command: [ ! -d ~/.rbenv/versions/2.0.0-p353 ]
cap aborted!
deploy
/Users/chris/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/net-ssh-2.7.0/lib/net/ssh.rb:215:in `start'
/Users/chris/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/sshkit-1.2.0/lib/sshkit/backends/netssh.rb:169:in `ssh'
/Users/chris/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/sshkit-1.2.0/lib/sshkit/backends/netssh.rb:122:in `block in _execute'
/Users/chris/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/sshkit-1.2.0/lib/sshkit/backends/netssh.rb:119:in `tap'
/Users/chris/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/sshkit-1.2.0/lib/sshkit/backends/netssh.rb:119:in `_execute'
/Users/chris/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/sshkit-1.2.0/lib/sshkit/backends/netssh.rb:62:in `test'
/Users/chris/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/bundler/gems/rbenv-8326795409e2/lib/capistrano/tasks/rbenv.rake:33:in `block (3 levels) in <top (required)>'
/Users/chris/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/sshkit-1.2.0/lib/sshkit/backends/netssh.rb:54:in `instance_exec'
/Users/chris/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/sshkit-1.2.0/lib/sshkit/backends/netssh.rb:54:in `run'
/Users/chris/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/sshkit-1.2.0/lib/sshkit/runners/parallel.rb:12:in `block (2 levels) in execute'
Tasks: TOP => rbenv:check

relevant link?:
rbenv/rbenv#377

Rbenv update & setup tasks

Hello,

In Capistrano 2.x, there was an ability to run cap [environment] rbenv:update and cap [environment] rbenv:setup. Are these tasks looking to be added back in?

set `:rbenv_type, :system` doesn't work

I'm probably doing something fatally wrong but set :rbenv_type, :system doesn't work for me.

The problem is that rbenv_path is evaluated and set before I have a chance to set :rbenv_type. When I take a look to this capistrano fragment (which I believe is responsible for the odd behaviour).

stages.each do |stage|
  Rake::Task.define_task(stage) do
    invoke 'load:defaults' # <== HERE rbenv_path is set
    load 'config/deploy.rb'
    load "config/deploy/#{stage}.rb" # <== HERE my rbenv_type is set
    load "capistrano/#{fetch(:scm)}.rb"
    set(:stage, stage.to_sym)
    I18n.locale = fetch(:locale, :en)
    configure_backend
  end
end

A simple workaround worked for me - instead of setting variables directly I pass lambdas which will be evaluated later with proper values. So instead of:

set :rbenv_path, rbenv_path

I use

set :rbenv_path, -> { ... }

But still it seems to me quite odd as I'm the only user who is affected by this?

p

Somehow accidentally created this. Please remove.

Does Homebrew installed rbenv supported?

I am using Mac OS X as server and not Linux. I am wondering if using Homebrew to install rbenv, will it be supported? I can't seems to get it done no matter what rbenv_custom_path I use

/usr/local/bin/rbenv
/Users/mech/.rbenv/shims/ruby
/Users/mech/.rbenv/versions/2.1.4/bin/ruby

If I set as this:

set :rbenv_ruby, '2.1.4'
set :rbenv_custom_path, '/Users/mech/.rbenv'

I am unable to make it work with these:

set :rbenv_custom_path, '/usr/local/Cellar/rbenv/0.4.0'
set :rbenv_path, '/usr/local/Cellar/rbenv/0.4.0' # Is there such a thing?

I always will encounter this:

bash: /Users/mech/.rbenv/bin/rbenv: No such file or directory

It is quite obvious that I do not have this path: ~/.rbenv/bin/

Could not locate Gemfile

Hi,

I use rbenv and I has a rake task in my deploy.rb

rbenv setting:

set :rbenv_type, :user # or :system, depends on your rbenv setup
set :rbenv_ruby, '2.1.2'
set :rbenv_prefix, "RBENV_ROOT=#{fetch(:rbenv_path)} RBENV_VERSION=#{fetch(:rbenv_ruby)} #{fetch(:rbenv_path)}/bin/rbenv exec"
set :rbenv_map_bins, %w{rake gem bundle ruby rails}
set :rbenv_roles, :all # default value

invoke rake task:

  task :restart do
    on roles(:app), in: :sequence, wait: 5 do
      # Your restart mechanism here, for example:
      with rails_env: :production do
        rake "environment elasticsearch:import:model CLASS='Professor' FORCE=y"
      end
      execute :touch, release_path.join('tmp/restart.txt')
    end
  end

But when deploying, I got this error:

[c4ec7237] Command: ( RBENV_ROOT=~/.rbenv RBENV_VERSION=2.1.2 RAILS_ENV=production RBENV_ROOT=~/.rbenv RBENV_VERSION=2.1.2 ~/.rbenv/bin/rbenv exec bundle exec rake environment elasticsearch:import:model CLASS='Professor' FORCE=y )
DEBUG [c4ec7237]        Could not locate Gemfile

Bundler executable not available

I'm having a problem with running bundler. The deploy completes deploy:symlink:linked_dirs and then fails on bundler:install:

 01 RBENV_ROOT=$HOME/.rbenv RBENV_VERSION=2.4.2 $HOME/.rbenv/bin/rbenv exec bundle install --path /home/ubuntu/rails/<APPLICATION>/current/bin/bundle --without development test --deployment --quiet --binstubs
 01 rbenv: bundle: command not found

I've tried installing it manually with rbenv exec gem install bundler and rbenv rehash, but the executable bundle does not appear.

capistrano 3.10.0
capistrano-rbenv 2.1.3
capistrano-bundler 1.3.0
capistrano-rails 1.3.0
rails 4.2.10
rbenv 1.1.1

Allow stages to opt out of rbenv tasks

I have a stage which runs against an environment that will not have rbenv installed. Currently, the capistrano-rbenv tasks are being applied to all stages via Capistrano::DSL.stages.

In an attempt to get around this, I created a special role that is only used on my non-rbenv stage, and set :rbenv_roles to exclude it. However, because of capistrano/capistrano#740, even when no host matches, the blocks passed to on in the rbenv Cap tasks still execute, causing my entire Cap run to fail when exit 1 happens.

While the proper fix, IMO, is for the issue in Capistrano to get fixed, capistrano-rbenv could provide a workaround by allowing stages to opt out of having the rbenv tasks added to its run.

Because capistrano-rbenv is not really verifying that rbenv is installed, and is simply checking for the existence of :rbenv_ruby_dir, it's possible to trick the task into thinking it's installed by setting :rbenv_ruby_dir to something like /. This is a pretty bad hack, and quite unintuitive, so I still think a clearer mechanism to opt out is warranted.

Thanks for your time!

No hooks version

I am migrating my deployments from RVM to rbenv, and there are some Capistrano stages which I'd like to stay with RVM (and capistrano-rvm) until I can figure it out correctly with rbenv

Do you have a way to import the library without hooks and explicitely require hooks in a particular deploy file ?

Validation warning possibly needs clarification

In the rbenv:validate task, a failure to find appropriate ruby version will produce a message:

ERROR rbenv: 2.4.2 is not installed or not found in /usr/local/rbenv/versions/2.4.2

What it doesn't mention is that it is the targeted remote host and not the local one that is missing this version. I soon discovered that I wasn't the first of my colleagues to be confused by this.

Could a clarification along the lines of "…at the remote host" be beneficial here? I'll provide a PR if needed.

cannot load such file -- capistrano/rbenv

Hello,

I have similar problem as was mentioned here before, but the solution doesn't work in my case. (I'm using rbenv on both development and production server, and Rails 4)

In Gemfile:

# Use Capistrano for deployment
group :development do
  gem 'capistrano'
  gem 'capistrano-rails'
  gem 'capistrano-rbenv'
end

After bundle install in Gemfile.lock:

    capistrano (3.0.0)
      i18n
      rake (>= 10.0.0)
      sshkit (>= 0.0.23)
    capistrano-platform-resources (0.1.2)
      capistrano
    capistrano-rails (1.0.0)
      capistrano
    capistrano-rbenv (1.0.3)
      capistrano
      capistrano-platform-resources (>= 0.1.0)

Then cap install

In Capfile:

require 'capistrano/rbenv'
require 'capistrano/rails/assets'
require 'capistrano/rails/migrations'

After cap production deploy or bundle exec cap production deploy I get this:

$ bundle exec cap production deploy --trace
cap aborted!
cannot load such file -- capistrano/rbenv
/Users/nikos/workspace/app/Capfile:19:in `require'
/Users/nikos/workspace/app/Capfile:19:in `<top (required)>'
/Users/nikos/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/rake-10.1.0/lib/rake/rake_module.rb:25:in `load'
/Users/nikos/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/rake-10.1.0/lib/rake/rake_module.rb:25:in `load_rakefile'
/Users/nikos/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/rake-10.1.0/lib/rake/application.rb:637:in `raw_load_rakefile'
/Users/nikos/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/rake-10.1.0/lib/rake/application.rb:94:in `block in load_rakefile'
/Users/nikos/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/rake-10.1.0/lib/rake/application.rb:165:in `standard_exception_handling'
/Users/nikos/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/rake-10.1.0/lib/rake/application.rb:93:in `load_rakefile'
/Users/nikos/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/capistrano-3.0.0/lib/capistrano/application.rb:22:in `load_rakefile'
/Users/nikos/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/rake-10.1.0/lib/rake/application.rb:77:in `block in run'
/Users/nikos/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/rake-10.1.0/lib/rake/application.rb:165:in `standard_exception_handling'
/Users/nikos/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/rake-10.1.0/lib/rake/application.rb:75:in `run'
/Users/nikos/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/capistrano-3.0.0/lib/capistrano/application.rb:12:in `run'
/Users/nikos/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/capistrano-3.0.0/bin/cap:3:in `<top (required)>'
/Users/nikos/.rbenv/versions/2.0.0-p247/bin/cap:23:in `load'
/Users/nikos/.rbenv/versions/2.0.0-p247/bin/cap:23:in `<main>'

Thanks for help.

rbenv_ruby for servers with different ruby versions

Is there a way to dynamically set :rbenv_ruby based on the .ruby-version (or global version) on the server?

The use case here is that when we do rolling upgrades of servers and for a short period the old servers will have a different ruby version.

Could not locate Gemfile when trying to run gem install

I have this in my recipe:

execute :gem, :install, 'powerdns_pipe'

When I try to run, I get this:

INFO[a0f3af02] Running RBENV_ROOT=/usr/local/rbenv RBENV_VERSION=2.1.2 /usr/local/rbenv/bin/rbenv exec bundle exec gem install powerdns_pipe on 213.163.64.74
DEBUG[a0f3af02] Command: ( RBENV_ROOT=/usr/local/rbenv RBENV_VERSION=2.1.2 RBENV_ROOT=/usr/local/rbenv RBENV_VERSION=2.1.2 /usr/local/rbenv/bin/rbenv exec bundle exec gem install powerdns_pipe )
DEBUG[a0f3af02]     [31mCould not locate Gemfile[0m

Why is rbenv converting the above to bundle exec? - how would I run gem install without bundle exec?

Could not find rake-10.2.2 in any of the sources (Bundler::GemNotFound)

Hi guys,

I used rbenv with capistrano to deploy my new rails 4 app, however I run cap production deploy, everything works fine until assets:precompile, it raised this exception:

DEBUG [342f4c77] Command: cd /home/deploy/code/altcoin_exchange/production/releases/20140411034551 && ( RBENV_ROOT=~/.rbenv RBENV_VERSION=2.0.0-p451 RAILS_ENV=production RBENV_ROOT=~/.rbenv RBENV_VERSION=2.0.0-p451 ~/.rbenv/bin/rbenv exec bundle exec rake assets:precompile )
DEBUG [342f4c77]    /home/deploy/.rbenv/versions/2.0.0-p451/gemsets/common_rails4/gems/bundler-1.6.1/lib/bundler/spec_set.rb:92:in `materialize': Could not find rake-10.2.2 in any of the sources (Bundler::GemNotFound)

I managed to fix by bundle update, remove all rake and install again... Is there any other suggestions for me?

Thanks a lot,

`exec}'

Anybody got any idea on how to solve this?

DEBUG [b2d8c32c] Command: cd /var/www/ctp/releases/20140506130613 && ( RBENV_ROOT=/.rbenv RBENV_VERSION=2.1.1 RBENV_ROOT=/.rbenv RBENV_VERSION=2.1.1 ~/.rbenv/bin/rbenv exec} bundle install --binstubs /var/www/ctp/shared/bin --path /var/www/ctp/shared/bundle --without development test --deployment --quiet )
DEBUG [b2d8c32c] rbenv: no such command `exec}'

sudo: gem: command not found

Hi there, so far rbenv has been working correctly, but on this recent Ubuntu server, I am running into this problem, here is the full output of cap production deploy:

** Invoke production (first_time)
** Execute production
** Invoke load:defaults (first_time)
** Execute load:defaults
** Invoke rbenv:validate (first_time)
** Invoke rbenv:map_bins (first_time)
** Execute rbenv:map_bins
** Invoke ruby:install (first_time)
** Execute ruby:install
DEBUG[97579dee] Running /usr/bin/env [ -e /usr/local/rbenv/versions/2.1.2/bin/ruby ] on 213.163.64.74
DEBUG[97579dee] Command: [ -e /usr/local/rbenv/versions/2.1.2/bin/ruby ]
DEBUG[97579dee] Finished in 0.969 seconds with exit status 0 (successful).
DEBUG[2caa6a86] Running /usr/bin/env [ -e /usr/local/rbenv/versions/2.1.2/bin/bundler ] on 213.163.64.74
DEBUG[2caa6a86] Command: [ -e /usr/local/rbenv/versions/2.1.2/bin/bundler ]
DEBUG[2caa6a86] Finished in 0.039 seconds with exit status 0 (successful).
** Execute rbenv:validate
DEBUG[33364c84] Running /usr/bin/env [ ! -d /usr/local/rbenv/versions/2.1.2 ] on 213.163.64.74
DEBUG[33364c84] Command: [ ! -d /usr/local/rbenv/versions/2.1.2 ]
DEBUG[33364c84] Finished in 0.039 seconds with exit status 1 (failed).
** Invoke rbenv:map_bins
** Invoke bundler:map_bins (first_time)
** Execute bundler:map_bins
** 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[6c96173e] Running /usr/bin/env mkdir -p /tmp/XanPortal/ on 213.163.64.74
DEBUG[6c96173e] Command: ( RBENV_ROOT=/usr/local/rbenv RBENV_VERSION=2.1.2 /usr/bin/env mkdir -p /tmp/XanPortal/ )
INFO[6c96173e] Finished in 0.060 seconds with exit status 0 (successful).
DEBUGUploading /tmp/XanPortal/git-ssh.sh 0.0%
INFOUploading /tmp/XanPortal/git-ssh.sh 100.0%
INFO[e1c52a44] Running /usr/bin/env chmod +x /tmp/XanPortal/git-ssh.sh on 213.163.64.74
DEBUG[e1c52a44] Command: ( RBENV_ROOT=/usr/local/rbenv RBENV_VERSION=2.1.2 /usr/bin/env chmod +x /tmp/XanPortal/git-ssh.sh )
INFO[e1c52a44] Finished in 0.045 seconds with exit status 0 (successful).
** Execute git:check
DEBUG[b6b4695a] Running /usr/bin/env git ls-remote -h [email protected]:xanview/xanportal.git on 213.163.64.74
DEBUG[b6b4695a] Command: ( RBENV_ROOT=/usr/local/rbenv RBENV_VERSION=2.1.2 GIT_ASKPASS=/bin/echo GIT_SSH=/tmp/XanPortal/git-ssh.sh /usr/bin/env git ls-remote -h [email protected]:xanview/xanportal.git )
DEBUG[b6b4695a]     0212215ee263187d81121cc3641c9276445c39ac    refs/heads/internalization
DEBUG[b6b4695a]     004812875fa1b57f37411cea2000d270c55a1f8c    refs/heads/master
DEBUG[b6b4695a] Finished in 1.991 seconds with exit status 0 (successful).
** Invoke deploy:check:directories (first_time)
** Execute deploy:check:directories
INFO[7ae62ffd] Running /usr/bin/env mkdir -pv /home/deployer/xanportal/shared /home/deployer/xanportal/releases on 213.163.64.74
DEBUG[7ae62ffd] Command: ( RBENV_ROOT=/usr/local/rbenv RBENV_VERSION=2.1.2 /usr/bin/env mkdir -pv /home/deployer/xanportal/shared /home/deployer/xanportal/releases )
INFO[7ae62ffd] Finished in 0.087 seconds with exit status 0 (successful).
** Invoke deploy:check:linked_dirs (first_time)
** Execute deploy:check:linked_dirs
INFO[5b0329f2] Running /usr/bin/env mkdir -pv /home/deployer/xanportal/shared/bin /home/deployer/xanportal/shared/log /home/deployer/xanportal/shared/tmp/pids /home/deployer/xanportal/shared/tmp/cache /home/deployer/xanportal/shared/tmp/sockets /home/deployer/xanportal/shared/vendor/bundle /home/deployer/xanportal/shared/public/system on 213.163.64.74
DEBUG[5b0329f2] Command: ( RBENV_ROOT=/usr/local/rbenv RBENV_VERSION=2.1.2 /usr/bin/env mkdir -pv /home/deployer/xanportal/shared/bin /home/deployer/xanportal/shared/log /home/deployer/xanportal/shared/tmp/pids /home/deployer/xanportal/shared/tmp/cache /home/deployer/xanportal/shared/tmp/sockets /home/deployer/xanportal/shared/vendor/bundle /home/deployer/xanportal/shared/public/system )
INFO[5b0329f2] Finished in 0.092 seconds with exit status 0 (successful).
** Invoke deploy:check:make_linked_dirs (first_time)
** Execute deploy:check:make_linked_dirs
INFO[5cd888f7] Running /usr/bin/env mkdir -pv /home/deployer/xanportal/shared/config on 213.163.64.74
DEBUG[5cd888f7] Command: ( RBENV_ROOT=/usr/local/rbenv RBENV_VERSION=2.1.2 /usr/bin/env mkdir -pv /home/deployer/xanportal/shared/config )
INFO[5cd888f7] Finished in 0.061 seconds with exit status 0 (successful).
** Invoke deploy:check:linked_files (first_time)
** Invoke deploy:check:create_application_yml (first_time)
** Execute deploy:check:create_application_yml
DEBUGUploading /home/deployer/xanportal/shared/config/secrets.yml 0.0%
INFOUploading /home/deployer/xanportal/shared/config/secrets.yml 100.0%
** Execute deploy:check:linked_files
DEBUG[d2b84f22] Running /usr/bin/env [ -f /home/deployer/xanportal/shared/config/secrets.yml ] on 213.163.64.74
DEBUG[d2b84f22] Command: [ -f /home/deployer/xanportal/shared/config/secrets.yml ]
DEBUG[d2b84f22] Finished in 0.050 seconds with exit status 0 (successful).
** Invoke deploy:everything (first_time)
** Execute deploy:everything
** Invoke dns:install (first_time)
** Execute dns:install
INFO[7128eb95] Running /usr/bin/env sudo gem install powerdns_pipe on 213.163.64.74
DEBUG[7128eb95] Command: ( RBENV_ROOT=/usr/local/rbenv RBENV_VERSION=2.1.2 /usr/bin/env sudo gem install powerdns_pipe )
DEBUG[7128eb95]     sudo: gem: command not found
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing on host 213.163.64.74: sudo exit status: 1
sudo stdout: Nothing written
sudo stderr: Nothing written

As you can see it goes through the rbenv checks and setup successfully and if I login as root or deployer, I am able to run the "gem" command.

Any ideas?

General advice about Cap/rbenv

This definitely is not a bug, so if there's a better place to be asking this question, please tell me and I'll post over there for such things from now on.

If you're still with me...

I spent the last two days trying to figure out how to make a my deploy to a Vagrant box run faster. It takes roughly 30 minutes. Not unexpected considering that I'm trying to create a box almost from bare metal (i.e., it has the OS and pretty much nothing else), but it's too slow for what I need.

Part of the process is using knife-solo to provision the box. I wrote a rake task for it, called with a "before" hook in Cap. It works just great, and Cap manages the entire deploy process, which is nice. The slowdown comes when I install Ruby. I'm installing directly from source. It works, but man, it's dog slow, even on a beefier AWS box. That one recipe takes 15-20 minutes to run for a fresh box.

So I experimented with getting rbenv working. It seems to take much less time to install Ruby. I have no idea why, but the time drops to about 5 minutes. Much better. Getting it to work with Cap was a little challenging, believe it or not, but I got it working -- until I hit a snag.

Part of my provisioning process is to set up the deploy user in an automated fashion. Cap doesn't complain when I don't use the capistrano-rbenv gem. As soon as I plug that in, however, the initial rbenv:validate check fails because ... the deploy user isn't there yet, of course, and rbenv says it can't authenticate.

So I'm stuck. If I don't use rbenv with Cap, the Ruby install takes forever. If I use it, Cap is driving my deploy and the rbenv:validate check fails if the deploy user isn't there, which it's not until after I provision the box. Catch-22.

Does anyone have a suggestion about how to escape the conundrum?

rbenv vars support

Hi, I have created a few tasks to manage environmental variables with rbenv-vars plugin.

I'm willing to create PR with them if it makes sense to add this kind of features.

Probably it would be a good idea to add them separated from the core rbenv features. That way it will be optional to add them.

require 'capistrano/rbenv'
require 'capistrano/rbenv/vars'

I have a this tasks

cap rbenv:vars:add[key,value]      # Add environmental variable
cap rbenv:vars:remove[key]         # Remove environmental variable
cap rbenv:vars:show                # Show current environmental variables

rbenv:validate fails erroneously

I am trying to run a cap staging deploy with capistrano/rbenv and capistrano/bundler. I know for a fact that rbenv is correctly installed at the location being queried. I am only running the verification task on pc-app-1 as dev (our deploy user)
Here's some output:

Issuing the rbenv:validate command

justin@jkarnes-pcube:~/Projects/PerfectCube/PC$ cap staging rbenv:validate
00:00 rbenv:validate
      rbenv: 2.3.4 is not installed or not found in /home/dev/.rbenv/versions/2.3.4

Verifying rbenv 2.3.4 existence

dev@pc-app-1:~$ ls ~/.rbenv/versions
2.3.4
dev@pc-app-1:~$ ls /home/dev/.rbenv/versions # being explicit
2.3.4

Configuration relevant to the library

set :rbenv_type, :user
set :rbenv_ruby, '2.3.4'
set :rbenv_custom_path, "/home/dev/.rbenv" # removing this does nothing to solve the issue
set :rbenv_prefix, "RBENV_ROOT=#{fetch(:rbenv_path)} RBENV_VERSION=#{fetch(:rbenv_ruby)}
 {fetch(:rbenv_path)}/bin/rbenv exec"

Development machine and Local machine are both Ubuntu 16.04

If you need anything else or additional output, please let me know and I will work with you in solving this issue.

Add a global version

Hi

I use your gem to deploy our rails apps, which works perfectly. But I want to start our application server from systemd. Which does not work right now, because rbenv does not have a version set.

To alleviate this problem I have created a task like this inlib/capistrano/tasks/rbenv.rake:

namespace :rbenv do
  task :set_global_version do
    on roles(:app) do
      rbenv_ruby = fetch(:rbenv_ruby)
      rbenv_path = fetch(:rbenv_path)
      execute "echo #{rbenv_ruby} >> #{rbenv_path}/version"
    end
  end
end

Would this be something that you would consider adding?

Thanks & Best
tostr

Fresh Capistrano file and when I attempt to deploy:check rbenv:validate not found.

Any ideas?

bretthardin@Bretts-MacBook-Pro ~/Dropbox/code/bgg-tools (master ✘)✹✭ ᐅ cap production deploy:check
(Backtrace restricted to imported tasks)
cap aborted!
Don't know how to build task 'rbenv:validate'
/Users/bretthardin/Dropbox/code/bgg-tools/Capfile:7:in `require'
/Users/bretthardin/Dropbox/code/bgg-tools/Capfile:7:in `<top (required)>'
(See full trace by running task with --trace)

Tasks: TOP => rbenv:validate error

✗ cap staging deploy
DEBUG[600ca6ad] Running /usr/bin/env [ ! -d ~/.rbenv/versions/2.1.3 ] on abc-2.compute.amazonaws.com
DEBUG[600ca6ad] Command: [ ! -d ~/.rbenv/versions/2.1.3 ]
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing on host abc-2.compute.amazonaws.com: Connection timed out - connect(2) for "abc-2.compute.amazonaws.com" port 20

Errno::ETIMEDOUT: Connection timed out - connect(2) for "abc-2.compute.amazonaws.com" port 20

Tasks: TOP => rbenv:validate
(See full trace by running task with --trace)

Kindly guide me

BouncyCastle ClassCastException

I get the following error on this line:
https://github.com/capistrano/rbenv/blob/master/lib/capistrano/tasks/rbenv.rake#L10

Basically, the error comes while executing the test command. Issue with my JRuby installation?

Exception in thread "Ruby-0-Thread-10: /Users/uzzaldevkota/.rbenv/versions/jruby-9.0.5.0/lib/ruby/gems/shared/gems/sshkit-1.8.1/lib/sshkit/runners/parallel.rb:11" java.lang.ClassCas
tException: org.bouncycastle.asn1.DERApplicationSpecific cannot be cast to org.bouncycastle.asn1.ASN1Sequence
at org.jruby.ext.openssl.impl.PKey.readRSAPrivateKey(PKey.java:151)
at org.jruby.ext.openssl.impl.PKey.readRSAPrivateKey(PKey.java:145)
at org.jruby.ext.openssl.impl.PKey.readPrivateKey(PKey.java:101)
at org.jruby.ext.openssl.PKey$PKeyModule.read(PKey.java:119)
at org.jruby.ext.openssl.PKey$PKeyModule$INVOKER$s$0$1$read.call(PKey$PKeyModule$INVOKER$s$0$1$read.gen)
at org.jruby.internal.runtime.methods.JavaMethod$JavaMethodN.call(JavaMethod.java:729)
at org.jruby.runtime.callsite.CachingCallSite.callBlock(CachingCallSite.java:77)
at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:83)
at org.jruby.ir.instructions.CallBase.interpret(CallBase.java:414)
at org.jruby.ir.interpreter.InterpreterEngine.processCall(InterpreterEngine.java:348)
at org.jruby.ir.interpreter.StartupInterpreterEngine.interpret(StartupInterpreterEngine.java:77)
at org.jruby.internal.runtime.methods.MixedModeIRMethod.INTERPRET_METHOD(MixedModeIRMethod.java:140)
at org.jruby.internal.runtime.methods.MixedModeIRMethod.call(MixedModeIRMethod.java:126)
at org.jruby.runtime.callsite.CachingCallSite.callBlock(CachingCallSite.java:77)
at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:83)
at org.jruby.ir.instructions.CallBase.interpret(CallBase.java:414)
at org.jruby.ir.interpreter.InterpreterEngine.processCall(InterpreterEngine.java:348)
at org.jruby.ir.interpreter.StartupInterpreterEngine.interpret(StartupInterpreterEngine.java:77)
at org.jruby.internal.runtime.methods.MixedModeIRMethod.INTERPRET_METHOD(MixedModeIRMethod.java:140)
at org.jruby.internal.runtime.methods.MixedModeIRMethod.call(MixedModeIRMethod.java:126)
at org.jruby.runtime.callsite.CachingCallSite.callBlock(CachingCallSite.java:77)
at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:83)
at org.jruby.ir.instructions.CallBase.interpret(CallBase.java:414)
at org.jruby.ir.interpreter.InterpreterEngine.processCall(InterpreterEngine.java:348)
at org.jruby.ir.interpreter.StartupInterpreterEngine.interpret(StartupInterpreterEngine.java:77)
at org.jruby.ir.interpreter.Interpreter.INTERPRET_BLOCK(Interpreter.java:132)
at org.jruby.runtime.MixedModeIRBlockBody.commonYieldPath(MixedModeIRBlockBody.java:148)
at org.jruby.runtime.IRBlockBody.doYield(IRBlockBody.java:179)
at org.jruby.runtime.BlockBody.yield(BlockBody.java:96)
at org.jruby.runtime.Block.yield(Block.java:166)
at org.jruby.RubyArray.collect(RubyArray.java:2286)
at org.jruby.RubyArray.map19(RubyArray.java:2300)
at org.jruby.RubyArray$INVOKER$i$0$0$map19.call(RubyArray$INVOKER$i$0$0$map19.gen)
at org.jruby.internal.runtime.methods.JavaMethod$JavaMethodZeroBlock.call(JavaMethod.java:494)
at org.jruby.runtime.callsite.CachingCallSite.callBlock(CachingCallSite.java:77)
at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:83)

Define in which "roles" you want to run the "rbenv:validate" task

Right now this validation is run in all servers. In my case my db server is not a Ruby server so it has not any Ruby and, of course, any rbenv installation.

What is worst.. my database server is not accessible from my development host so my capistrano session breaks with this

** Invoke rbenv:validate (first_time)
** Execute rbenv:validate
DEBUG [61062783] Running /usr/bin/env [ ! -d ~/.rbenv/versions/2.0.0-p247 ] on dev.exchangeplatform.daliaresearch.com
DEBUG [61062783] Command: [ ! -d ~/.rbenv/versions/2.0.0-p247 ]
DEBUG [f24f6f8c] Running /usr/bin/env [ ! -d ~/.rbenv/versions/2.0.0-p247 ] on dbsdev001.dalia.internal
DEBUG [f24f6f8c] Command: [ ! -d ~/.rbenv/versions/2.0.0-p247 ]
DEBUG [61062783] Finished in 1.906 seconds with exit status 1 (failed).
cap aborted!
getaddrinfo: nodename nor servname provided, or not known

Check this line:

ERROR rbenv: 2.1.1 is not installed or not found in /usr/local/rbenv/versions/2.1.1

I'm getting this error:

$ cap staging deploy
/usr/local/lib/ruby/gems/2.1.0/gems/sshkit-1.3.0/lib/sshkit.rb:3: warning: already initialized constant SSHKit::StandardError
/usr/local/Cellar/ruby/2.1.1/lib/ruby/gems/2.1.0/gems/sshkit-1.3.0/lib/sshkit.rb:3: warning: previous definition of StandardError was here
DEBUG [e8e78628] Running /usr/bin/env [ ! -d /usr/local/rbenv/versions/2.1.1 ] on direct.monitor.zanview.com
DEBUG [e8e78628] Command: [ ! -d /usr/local/rbenv/versions/2.1.1 ]
DEBUG [e8e78628] Finished in 1.338 seconds with exit status 0 (successful).
ERROR rbenv: 2.1.1 is not installed or not found in /usr/local/rbenv/versions/2.1.1

I'm deploying to many servers and would like to install rbenv with capistrano, I have a task in lib/capistrano/tasks/ruby.cap that sets up rubyenv and ruby-build and installs both including ruby. How would I run this task without triggering this error?

is there supposed to be a ~/.rbenv/bin directory?

I have a server (OS X server) running several small rails applications. I had initially set it using brew to install ruby (could not get rvm to install!). I made some changes to one of the apps and ran into all kinds of problems with I updated the brew ruby version. I decided to try rbenv and set it up on the server. Lots of problems with clashes with the brew version that I eventually figured out.

I then tried to deploy and discovered that my bundle update loaded capistrano 3.1 and nothing worked. I started the conversion processes and I got stuck on:

set :rbenv_prefix, "RBENV_ROOT=#{fetch(:rbenv_path)} RBENV_VERSION=#{fetch(:rbenv_ruby)} #{fetch(:rbenv_path)}/bin/rbenv exec"

I have no bin directory on what brew installed for rbenv. I changed it to:

set :rbenv_prefix, "RBENV_ROOT=#{fetch(:rbenv_path)} RBENV_VERSION=#{fetch(:rbenv_ruby)} /usr/local/bin/rbenv exec"

and got it to work, but maybe I'm missing something. I did get a basic deploy to work, but still have to get the rest of my 'railscast/recipes' to work, like writing plists for launchd etc.

Please use .ruby_version when available

I know there are other closed issues with regards to this subject, but I have a situation where I think it justifies changing this plugin to look first for a .ruby_version file.

In our Capistrano recipes we first stop the sidekiq worker before proceeding with the deploy. Now, consider when we are upgrading Ruby from 2.2.4 to 2.3.0 with rbenv. The capistrano-sidekiq gem will run "bundle exec sidekiqctl stop..." before the deploy starts. By that time, .ruby_version points to 2.2.4 and bundle install was run previously for the current path and it should just work. But since capistrano-rbenv is overriding the Ruby version to 2.3.0 this command will fail because bundle install wasn't executed yet before trying to stop sidekiq and it will yield to an error which I had to fix manually by running bundle in that path first for the newer Ruby.

If the project .ruby_version was used when present it should just work transparently...

cannot precompile assets since i switched to rbenv (from rvm)

Hello,

i'm stuck on this issue with capistrano 3 :

#Command: 
cd /home/rails/myapp/releases/20140706030801 && ( RBENV_ROOT=~/.rbenv RBENV_VERSION=2.0.0-p481 RAILS_ENV=production RBENV_ROOT=~/.rbenv RBENV_VERSION=2.0.0-p481 ~/.rbenv/bin/rbenv exec bundle exec rake assets:precompile )

=> LoadError: libruby.so.2.0: cannot open shared object file: No such file or directory - /home/rails/myapp/shared/bundle/ruby/2.0.0/gems/therubyracer-0.12.1/lib/v8/init.so

rake assets:precompile works on my dev machine (rvm), and was working too on the staging server when i was using rvm (i rvm implode --force)

Any idea ? thanks in advance !

run_locally using rbenv settings

I'm not sure what the expected behaviour with rbenv and run_locally is. My naive assumption is that including the rbenv tasks would allow for rbenv support on the server to be deployed to, but shouldn't affect the local machine.

However if I do something like

run_locally do
  execute :bundle, "exec", "rake", "db:dump:load"
end

I get the following:

INFO [2d3a6c4b] Running RBENV_ROOT=~/.rbenv RBENV_VERSION=2.0.0-p247 ~/.rbenv/bin/rbenv exec bundle exec rake db:dump:load on
DEBUG [2d3a6c4b] Command: ( RBENV_ROOT=~/.rbenv RBENV_VERSION=2.0.0-p247 ~/.rbenv/bin/rbenv exec bundle exec rake db:dump:load )

Which is mimicking the server deploy behaviour. This is frustrating to me as my server has rbenv installed with the binaries in the usual location, but locally I don't have rbenv installed in that fashion.

This behaviour seems incorrect to me.

ruby is not installed or not found

The message:

00:00 rbenv:validate
      WARN  rbenv: 2.5.1
 is not installed or not found in $HOME/.rbenv/versions/2.5.1
set :rbenv_type, :user # or :system, depends on your rbenv setup
set :rbenv_ruby, `cat .ruby-version`

the directory exists:

$ ls $HOME/.rbenv/versions/2.5.1
bin  include  lib  share

capistrano 3.11.0, capistrano-rbenv 2.3.1

What may be the problem with it?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.