Lamnk
Lamnk

Reputation: 534

Why does Bundler.require load the wrong path?

I'm having a problem with Bundler and Sinatra. First i used this in my app.rb:

require 'rubygems'
require 'bundler/setup'
require 'sinatra'
require 'haml'
require 'redis'
...

However I read about Bundler.require and thought it's a nice DRY way because the gems specified in Gemfile are the ones I will require in my app anyway. Why should I specify the requires again in app.rb? So I changed my code to:

require 'rubygems'
require 'bundler'
Bundler.require(:default)

Much nicer huh? Not until problem ensues:

Errno::ENOENT at /
No such file or directory - /home/lamnk/.rvm/gems/ruby-1.9.2-head/gems/bundler-1.0.7/lib/bundler/views/index.haml
file: tilt.rb location: read line: 119

Clearly bundler has moved the app's root path to its own. But why is that?

Upvotes: 1

Views: 1067

Answers (1)

Sinetris
Sinetris

Reputation: 8945

Old answer:

Take a look at "using the rubygems bundler for your app" on the Engine Yard blog.

New answer:

As Lamnk pointed out, that post on Engine Yard is old; so I made a simple app https://github.com/sinetris/sinatra-example-bundler

Upvotes: 3

Related Questions