Skip to content

Instantly share code, notes, and snippets.

@Sutto
Created July 17, 2010 23:36
Show Gist options
  • Save Sutto/479941 to your computer and use it in GitHub Desktop.
Save Sutto/479941 to your computer and use it in GitHub Desktop.
Automatic .rvmrc detection + bundler setup on passenger
if ENV['MY_RUBY_HOME'] && ENV['MY_RUBY_HOME'].include?('rvm')
rvm_path = File.dirname(File.dirname(ENV['MY_RUBY_HOME']))
rvm_lib_path = File.join(rvm_path, 'lib')
# Differentiate between new and old passenger versions
if File.exist?(File.join(rvm_lib_path, "rvm", "environment.rb"))
$LOAD_PATH.unshift rvm_lib_path
require 'rvm'
RVM.use_from_path! Dir.pwd # Passenger starts in the app root
end
end
# Select the correct item for which you use below.
# If you're not using bundler, remove it completely.
ENV['BUNDLE_GEMFILE'] = File.expand_path('../Gemfile', File.dirname(__FILE__))
# If we're using a Bundler 1.0 beta
require 'bundler/setup'
# Or Bundler 0.9...
if File.exist?(".bundle/environment.rb")
require '.bundle/environment'
else
require 'rubygems'
require 'bundler'
Bundler.setup
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment