Reputation: 1263
Since I have require capistrano-bundler
and capistrano-rbenv
gems, and have set as follow in deploy.rb file:
# rbenv
set :rbenv_type, :user
set :rbenv_ruby, '2.0.0-p645'
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}
# bundler
set :bundle_roles, :all # this is default
set :bundle_servers, -> { release_roles(fetch(:bundle_roles)) } # this is default
set :bundle_binstubs, -> { shared_path.join('bin') } # default: nil
set :bundle_gemfile, -> { release_path.join('Gemfile') } # default: nil
set :bundle_path, -> { shared_path.join('bundle') } # this is default
set :bundle_without, %w{development test}.join(' ') # this is default
set :bundle_flags, '--deployment --quiet' # this is default
set :bundle_env_variables, {} # this is default
Clearly bundle_path is not in shared
subpath, it should be /home/deploy/.rbenv/shims/bundle
. So how can I get that path after I have set rbenv's settings. I struggle for a long time but found nothing both on github or google.com
.
Thx.
Upvotes: 2
Views: 749
Reputation: 481
To get rbenv's gem path you can do rbenv exec gem environment gemdir
.
However, I think the problem comes from the combination of the :bundle_path
, :bundle_flags
settings, and how bundler interacts with rbenv.
Because of the --deployment
option (set in :bundle_flags
), the installed gems won't install their binaries in rbenv's system gemdir, but on app/shared/bundle
, so you won't get them in your $PATH
.
To fix this, you need to add your command to both :rbenv_map_bins
and :bundle_bins
so that it is properly prefixed.
For example, for jekyll, you need to set:
set :rbenv_map_bins, fetch(:rbenv_map_bins, []).push('jekyll')
set :bundle_bins, fetch(:bundle_bins, []).push('jekyll')
This makes the command executed by capistrano to be something like
RBENV_ROOT=#{fetch(:rbenv_path)} RBENV_VERSION=#{fetch(:rbenv_ruby)} #{fetch(:rbenv_path)}/bin/rbenv exec bundle exec jekyll
which will work because bundle
is in :rbenv_map_bins
and bundle install --deployment
creates a .bundler/config
file that sets the path to app/share/bundle
Upvotes: 1