I installed rvm and am using 1.9.2 with rails 3.05. I was able to create a new application but once I moved into the directory and tried to start the server ("rails s"), I got this error message

Could not find gem 'sqlite3 (>= 0)' in any of the gem sources listed in your Gemfile.
Run `bundle install` to install missing gems.

I did "bundle install" as per the instruction and it did some fetching and then seemed to run into some more problems. See below. Note, when I use the default ruby/rails on my mac os I am able to start the server. This is only a problem I have when I use a version created in rvm?

Fetching source index for http://rubygems.org/
Using rake (0.9.2) 
Using abstract (1.0.0) 
Using activesupport (3.0.5) 
Using builder (2.1.2) 
Using i18n (0.6.0) 
Using activemodel (3.0.5) 
Using erubis (2.6.6) 
Using rack (1.2.4) 
Using rack-mount (0.6.14) 
Using rack-test (0.5.7) 
Using tzinfo (0.3.29) 
Using actionpack (3.0.5) 
Using mime-types (1.16) 
Using polyglot (0.3.2) 
Using treetop (1.4.10) 
Using mail (2.2.19) 
Using actionmailer (3.0.5) 
Using arel (2.0.10) 
Using activerecord (3.0.5) 
Using activeresource (3.0.5) 
Using bundler (1.0.18) 
Using thor (0.14.6) 
Using railties (3.0.5) 
Using rails (3.0.5) 
/Users/michaeljohnmitchell/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/package/tar_input.rb:122:in `initialize': no metadata found in /Users/michaeljohnmitchell/.rvm/gems/ruby-1.9.2-p290/cache/sqlite3-1.3.4.gem (Gem::Package::FormatError)
    from /Users/michaeljohnmitchell/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/package/tar_input.rb:20:in `new'
    from /Users/michaeljohnmitchell/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/package/tar_input.rb:20:in `open'
    from /Users/michaeljohnmitchell/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/package.rb:44:in `open'
    from /Users/michaeljohnmitchell/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/format.rb:62:in `from_io'
    from /Users/michaeljohnmitchell/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/format.rb:46:in `block in from_file_by_path'
    from /Users/michaeljohnmitchell/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/open-uri.rb:35:in `open'
    from /Users/michaeljohnmitchell/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/open-uri.rb:35:in `open'
    from /Users/michaeljohnmitchell/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/format.rb:45:in `from_file_by_path'
    from /Users/michaeljohnmitchell/.rvm/gems/ruby-1.9.2-p290/gems/bundler-1.0.18/lib/bundler/rubygems_integration.rb:100:in `spec_from_gem'
    from /Users/michaeljohnmitchell/.rvm/gems/ruby-1.9.2-p290/gems/bundler-1.0.18/lib/bundler/source.rb:77:in `fetch'
    from /Users/michaeljohnmitchell/.rvm/gems/ruby-1.9.2-p290/gems/bundler-1.0.18/lib/bundler/installer.rb:50:in `block in run'
    from /Users/michaeljohnmitchell/.rvm/gems/ruby-1.9.2-p290/gems/bundler-1.0.18/lib/bundler/installer.rb:49:in `run'
    from /Users/michaeljohnmitchell/.rvm/gems/ruby-1.9.2-p290/gems/bundler-1.0.18/lib/bundler/installer.rb:8:in `install'
    from /Users/michaeljohnmitchell/.rvm/gems/ruby-1.9.2-p290/gems/bundler-1.0.18/lib/bundler/cli.rb:220:in `install'
    from /Users/michaeljohnmitchell/.rvm/gems/ruby-1.9.2-p290/gems/bundler-1.0.18/lib/bundler/vendor/thor/task.rb:22:in `run'
    from /Users/michaeljohnmitchell/.rvm/gems/ruby-1.9.2-p290/gems/bundler-1.0.18/lib/bundler/vendor/thor/invocation.rb:118:in `invoke_task'
    from /Users/michaeljohnmitchell/.rvm/gems/ruby-1.9.2-p290/gems/bundler-1.0.18/lib/bundler/vendor/thor.rb:263:in `dispatch'
    from /Users/michaeljohnmitchell/.rvm/gems/ruby-1.9.2-p290/gems/bundler-1.0.18/lib/bundler/vendor/thor/base.rb:386:in `start'
    from /Users/michaeljohnmitchell/.rvm/gems/ruby-1.9.2-p290/gems/bundler-1.0.18/bin/bundle:13:in `<top (required)>'
    from /Users/michaeljohnmitchell/.rvm/gems/ruby-1.9.2-p290/bin/bundle:19:in `load'
    from /Users/michaeljohnmitchell/.rvm/gems/ruby-1.9.2-p290/bin/bundle:19:in `<main>'
Michael-Mitchells-MacBook-Pro:demo michaeljohnmitchell$ rails s

When different versions of gems are installed by bundler or directly by rubygems, there are also executable scripts that are installed (such as rails, rake, and ironically, bundle). Running the correct versions of these scripts as you work with different bundles would be impossible so the solution that bundler has come up with is to prefix your commands with bundle exec, which will cause them to be run in the context of your bundle and launch the correct version from your Gemfile:

bundle exec rails s

The other option is to tell bundler to install these scripts in a directory so you can call them from there:

bundle install --binstubs
# same as:
bundle install --binstubs=./bin

The safer option I think is to use bundle exec, which you can shorten using a shell alias as it can get annoying to type every time.

  • Right. I just ran into that yesterday. Seems like a recent change with Bundler and Rails? – slhck Sep 28 '11 at 7:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.