I'm wondering how a one can use Bundler with Sinatra. The idea is to use the gems that Bundler downloads inside the .gems folder.
+4
A:
Inside your Sinatra app, you just have to require the bundler environment.rb:
require 'vendor/gems/environment.rb'
require 'sinatra'
get '/' do
"Hello world!"
end
Alternatively, if you don't want to add the additional require
at the top of your app, you can instead invoke sinatra via gem exec
(e.g. gem exec ruby myapp.rb
)
This assumes that you have a Gemfile
in the root of your application. It might look like this:
gem "sinatra", "0.9.4"
This also assumes that you've already installed bundler (sudo gem install bundler
) and that you ran gem bundle
to put all the gem dependencies listed in your Gemfile
under vendor/gems
.
Ryan McGeary
2009-11-11 02:42:36