I'm trying to vendorize my ruby application so that I don't have to manually install any gems on the server and can deploy my application as an rpm in our puppet setup.
This nearly works, except despite me adding a require 'bundler' to the Gemfile, there is no trace of the bundler making it to the vendor directory. So, my application fails with a
no such file to load -- bundler
Precisely at the point where load our dependencies.
require 'bundler'
Bundler.setup
Is there something obvious I am missing here or can bundler not actually vendorize itself?
For what it's worth, I'm using jruby 1.7.8 and the application in question has the following Gemfile:
# run with --local to use locally cached gems
# bundle install --full-index --without testing development
# vendorized setup for production
# bundle install --full-index --without testing development --deployment
source 'https://rubygems.org'
gem 'bundler'
gem 'sinatra'
gem 'sinatra-flash'
gem 'sinatra-contrib'
gem 'rack-parser', :require => 'rack/parser'
gem 'dynamic_attributes', :github => 'joona/dynamic_attributes', :require => false
gem 'httparty'
gem 'haml'
gem 'json'
gem 'airbrake'
# gem 'rake'
#gem 'omniauth-google' # TO-DO: deprecate
gem 'bcrypt-ruby', :require => 'bcrypt'
gem 'oauth'
gem 'oauth2'
gem 'omniauth'
gem 'omniauth-dropbox'
gem 'omniauth-facebook'
gem 'omniauth-google-oauth2'
gem 'omniauth-linkedin'
gem 'omniauth-twitter'
gem 'omniauth-windowslive', :git => 'git://github.com/joona/omniauth-windowslive.git'
gem 'lumber'
gem "log4r-gelf"
gem "resque", :github => "resque/resque", :branch => '1-x-stable'
gem "resque-pool"
gem 'tux', :require => false
gem 'actionmailer'
gem 'actionpack', '4.0.1'
gem 'activesupport', '4.0.1', :require => false
gem 'activerecord', '4.0.1'
platforms :jruby do
gem 'activerecord-jdbc-adapter' #, :github => 'jruby/activerecord-jdbc-adapter'
gem 'jdbc-mysql'
gem 'activerecord-jdbcmysql-adapter'
end
platforms :ruby do
gem 'mysql2'
end
group :testing do
gem 'shoulda-matchers', :require => false
gem 'webmock', '1.8.0', :require => false
gem 'database_cleaner', '1.0.1'
gem "sequel", "~> 4.3.0", :require => false
gem 'rspec'
gem 'capybara'
#gem 'vcr'
gem 'simplecov', :require => false
gem 'launchy'
gem 'rack-test', :require => false
gem 'faker'
gem 'fabrication'
gem 'sinatra-sessionography', :require => false
platforms :ruby do
gem 'sqlite3'
end
platforms :jruby do
gem 'jdbc-sqlite3'
end
end
#
group :development do
gem 'guard', "1.8.3", :require => false
gem 'guard-sass', '1.3.2', :require => false
gem 'guard-less', '0.1.2', :require => false
gem 'guard-process', '1.0.6', :require => false
gem 'guard-rspec', '3.1.0', :require => false
gem 'juicer'
gem 'foreman', :require => false
# shotgun with logging quickfix!
#gem 'shotgun', :github => 'joona/shotgun'
gem 'guard-shotgun', :git => 'https://github.com/rchampourlier/guard-shotgun.git'
gem 'capistrano', '~> 2'
gem 'rvm-capistrano'
end
group :production do
platforms :ruby do
gem 'passenger'
end
platforms :jruby do
gem 'fishwife'
end
end
The reason this doesn't work is because
Bundler.setup
is the code that actually sets up your load path to find the vendored gems. If Bundler were vendored, it wouldn't be able to find it to do that setup.You can do one of two things:
Install Bundler as a system gem. This is the most common solution. You could build a separate RPM to install it (or maybe there's already one out there you can use) and depend on it in your app's RPM.
Use Bundler's standalone mode. This will give you an application that does not depend on Bundler at all. In that case, you should remove the
require 'bundler'
andBundler.setup
lines from your application and instead addrequire_relative 'bundle/bundler/setup'
(with the path adjusted if you're calling it from a file located somewhere other than the root directory of your project).