How to force external gems to be loaded from vendor folder

Go To


I'm packaging up a gem with few external dependencies (such as 'liquid', 'fastercsv', etc..), the only requirement here is that the user installing the gem doesn't have access to the net (some proxy restrictions). I put my gems inside "vendor/bundle/jruby/1.9" folder, just wondering how I can force the user to use those gems instead of downloading them from


2012-04-04 00:55
by sebarmeli


If you really want to do it, you can edit your gem's Gemfile and remove those gems as dependencies.

This means that when a user installs your gem, he won't download any other gems.

Within your gem, you'll need to require each of the inner gems of yours.

If you want to be sure you get your own inner gem, rather than a pre-existing gem on the user's system, you can use the load path: save it, overwrite it with your own, load your gems, then restore the load path.

2012-04-04 01:19
by joelparkerhenderson
Thanks joelparkerhenderson. Should I include "gemspec" in my Gemfile, or should I clear it? Also, should I require the internal gems like require 'vendor/bundle.../liquid' instead of require 'liquid' - sebarmeli 2012-04-04 01:29
Good question, I don't know; I personally would try it without. For your second question, I would first try altering the load path, with the goal being to have your gem's files be able to do require as usual like: require 'liquid' - joelparkerhenderson 2012-04-04 01:46
ah ok so doing something like $:.unshift File.dirname('vendor') in the prj_name.rb file - sebarmeli 2012-04-04 02:45