I've just made the switch from rvm to rbenv and I'm trying to use bundler for gem management. After running bundle install
and trying to run a simple sinatra app (ruby app.rb
), I get this:
Could not find haml-3.1.4 in any of the sources
Run `bundle install` to install missing gems.
Running bundle install
again had no effect. Also tried bundle update
as suggested by another question response.
This is my Gemfile:
source "http://rubygems.org"
gem "sinatra"
gem "haml"
This is what bundle show
produces
* bundler (1.0.22)
* haml (3.1.4)
* rack (1.4.1)
* rack-protection (1.2.0)
* sinatra (1.3.2)
* tilt (1.3.3)
This is what my app requires:
require "rubygems"
require "bundler/setup"
require 'sinatra'
I'm convince that this is some kind of path issue where bundler and rbenv aren't playing along. I've tried looking through rbenv's documentation but was not able to find to anything.
Note: In a different sinatra app I get the following when trying to run it:
Could not find addressable-2.2.7 in any of the sources
Run `bundle install` to install missing gems.
Supplemental info
echo $PATH
/Users/uri/.rbenv/shims:/Users/uri/.rbenv/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin
which bundle
/Users/uri/.rbenv/shims/bundle
Update
If I do bundle install --system
it works. Although I can't see this as being a viable solution.
I suggest you use the gem 'capistrano-rbenv' (https://github.com/yyuu/capistrano-rbenv )
make sure you have "rbenv" and a ruby version (e.g. 1.9.3) installed in remote server
in your config/deploy.rb (capistrano file)
in your Gemfile:
that's it. to debug if it works, just run:
You should try using chruby. chruby is an ultra-minimal (~80 lines) alternative to RVM / rbenv. Unlike rbenv, chruby does not rely on shims and simply modifies
PATH
,GEM_HOME
andGEM_PATH
.Give this rbenv plugin a try, it will make shims aware of the bundler paths
https://github.com/carsomyr/rbenv-bundler
Adding this
to deploy.rb worked for me.
http://henriksjokvist.net/archive/2012/2/deploying-with-rbenv-and-capistrano/
Just a reminder too that rbenv is not compatible with rvm they do not play nicely. For your sanity, uninstall rvm if you want to use rbenv. From the rbenv README:
Luckily, Wayne (rvm creator) provides a remove rvm easily using:
rvm implode
As a regular use or:
rvmsudo rvm implode
To clean rvm system wide.
I had a similar problem when I switched from using rvm to rbenv. I found my bundler was showing a different list of gems than my
gem list
command. First check to see which paths your bundler and gem are using. For bundler use theshow
command and select any gem.and my
gem environment
command (in part)Here I could see my gem is pointing to the correct rbenv path but my bundler is pointing to my project's vendor path.
Running the following command should fix the bundler path problem:
Bundler path should now be pointing to the rbenv path.
Also I found when I run the
rvm implode
command to uninstall rvm, there were still the following files which I needed to change to remove rvm paths:If the
~/.rvm
path still exists, you will need to remove this.You will need to open a new terminal session after changing these files. Finally after all that I finally got my bundler and gem in sync.