title: Bundle with capistrano installed by chef
body: <p>I'm configuring a vagrant box using chef and then deploying my app using capistrano. </p>
  
  <p>my chef recipe to install bundler is the following: </p>
  
  <pre><code>include_recipe "rbenv"
  
  include_recipe "rbenv::ruby_build"
  
  rbenv_ruby node[:rbenv][:ruby] do 
    global true
  end
  
  rbenv_gem "bundler" do
    ruby_version node[:rbenv][:ruby]
  end
  </code></pre>
  
  <p>using the <a href="https://github.com/RiotGames/rbenv-cookbook" rel="nofollow">Riot rbenv cookbook</a></p>
  
  <p>When I try using the <code>bundle</code> with capistrano I figured that the executed bundle is one that was preinstalled on the box, rather than the one installed by chef. </p>
  
  <p>Here's the problem: </p>
  
  <pre><code>$ which bundle
  /opt/rbenv/shims/bundle
  $ sudo which bundle
  /usr/bin/bundle
  $ sudo su -
  root# which bundle
  /opt/rbenv/shims/bundle
  </code></pre>
  
  <p>Basically it appears that Capistrano runs the commands using the second form, were it uses the <code>/usr/bin/bundle</code>. </p>
  
  <p>I've tried running: </p>
  
  <pre><code>$ sudo bundle
  /usr/lib/ruby/vendor_ruby/bundler/rubygems_ext.rb:8:in `require': no such file to load -- rubygems (LoadError)
      from /usr/lib/ruby/vendor_ruby/bundler/rubygems_ext.rb:8
      from /usr/lib/ruby/vendor_ruby/bundler.rb:11:in `require'
      from /usr/lib/ruby/vendor_ruby/bundler.rb:11
      from /usr/bin/bundle:4:in `require'
      from /usr/bin/bundle:4
  </code></pre>
  
  <p>and I obtain exactly the same exception I see in Capistrano.</p>
  
  <p>If I manually uninstall <code>bundler</code> then here's what I obtain: </p>
  
  <pre><code>$ bundle
  Bundler::GemfileNotFound
  $ sudo bundle
  sudo: bundle: command not found
  $ sudo su - 
  root# bundle
  Bundler::GemfileNotFound
  </code></pre>
  
  <p><strong>UPDATE</strong></p>
  
  <p>I've figured that the whole ruby version is not available for sudoers: </p>
  
  <pre><code>$ ruby -v
  ruby 2.0.0p353 (2013-11-22 revision 43784) [x86_64-linux]
  $ sudo ruby -v
  ruby 1.8.7 (2011-06-30 patchlevel 352) [x86_64-linux]
  </code></pre>
  
  <p>even more troubles. </p>
  
  <p>Can you help me ? </p>
  
  <p>thanks. </p>