2

I am having trouble configuring Sinatra to use Bundler. I am confused as to where Gems should be being installed? I've read both this question and this documentation.

My Gemfile looks like:

source "http://rubygems.org"
gem "sinatra"
gem "amazon-ec2"

My config.ru looks like:

require "rubygems"
require "bundler"
Bundler.setup
require "application"
run Sinatra::Application

My application.rb looks like:

require "rubygems"
require "sinatra"
require "AWS"

#... rest of application

Now, when I run bundle install everything works correctly and Gems get installed into ~/.bundle/ in my home directory. Yet, in my app if I have a look at .bundle/config it shows:

--- 
BUNDLE_WITHOUT: ""
BUNDLE_PATH: vendor/gems

Sure enough, when I start up the app (using Passenger by the way) it says:

Could not find gem 'amazon-ec2 (>= 0, runtime)' in the gems available on this machine. (Bundler::GemNotFound)

Clearly bundle install is installing Gems in a different place to where Sinatra expects them to be. Does that mean I have to use bundle install vendor or reconfigure something else so that the application expects the Gems to be in ~/.bundle?

Community
  • 1
  • 1
aaronrussell
  • 9,389
  • 5
  • 38
  • 62
  • What version of bundler are you using? – Yehuda Katz Aug 08 '10 at 17:17
  • I'm using 0.9.26. I have managed to get things working locally by always explicitly putting gems into `vendor/gems` rather than my home directory with `bundle install vendor/gems`. However, I also had a devil's own job getting it to deploy to my server - Sinatra seems incapable of loading some gems from the system location, and some from `vendor/gems` at the same time - AFAICT, all gems need to be loaded from the same location. Bundler works effortlessly with Rails 3, but seems a nightmare with Sinatra. I'm sure I'm doing something wrong :( – aaronrussell Aug 09 '10 at 18:43

1 Answers1

2

About a year after @aaronrussell 's initial posting, I hit the same problem with Passenger, Nginx, Bundler, Sinatra. I got through it by running this on production:

bundle install --deployment

Bundled gems go in ./vendor/bundle

Here are some details on bundler deployment mode

Noah Thorp
  • 936
  • 8
  • 10