Skip to content

Instantly share code, notes, and snippets.

@MeanderingCode
Created November 5, 2011 22:11
Show Gist options
  • Save MeanderingCode/1342098 to your computer and use it in GitHub Desktop.
Save MeanderingCode/1342098 to your computer and use it in GitHub Desktop.
Diff for TracksApp/tracks to get it working on Dreamhost shared hosting
diff --git a/config/environment.rb b/config/environment.rb
index 1fc8f03..246951b 100644
--- a/config/environment.rb
+++ b/config/environment.rb
@@ -2,11 +2,26 @@
# Uncomment below to force Rails into production mode
# (Use only when you can't set environment variables through your web/app server)
-# ENV['RAILS_ENV'] = 'production'
+ ENV['RAILS_ENV'] = 'production'
+
+if ENV['RAILS_ENV'] == 'production'
+ ENV['GEM_HOME'] = '/home/user/.rvm/gems/ruby-1.8.7-p352'
+ ENV['GEM_PATH'] = '/home/user/.rvm/gems/ruby-1.8.7-p352:/home/user/.rvm/gems/ruby-1.8.7-p352@global' + ':/usr/lib/ruby/gems/1.8'
+ ENV['BUNDLE_PATH'] = '/home/user/.rvm/gems/ruby-1.8.7-p352'
+end
# Bootstrap the Rails environment, frameworks, and default configuration
require File.join(File.dirname(__FILE__), 'boot')
+if ENV['RAILS_ENV'] == 'production'
+ ENV['GEM_HOME'] = '/home/user/.rvm/gems/ruby-1.8.7-p352'
+ ENV['GEM_PATH'] = '/home/user/.rvm/gems/ruby-1.8.7-p352:/home/user/.rvm/gems/ruby-1.8.7-p352@global' + ':/usr/lib/ruby/gems/1.8'
+ ENV['BUNDLE_PATH'] = '/home/user/.rvm/gems/ruby-1.8.7-p352'
+end
+
+require 'rubygems'
+Gem.clear_paths
+
require 'yaml'
SITE_CONFIG = YAML.load_file(File.join(File.dirname(__FILE__), 'site.yml'))
@@ -74,6 +89,8 @@ end
# Include your application configuration below
+require 'bundler'
+Bundler.require
require 'name_part_finder'
require 'tracks/todo_list'
diff --git a/config/initializers/mongrel_workaround.rb b/config/initializers/mongrel_workaround.rb
index dcad693..bc32e4e 100644
--- a/config/initializers/mongrel_workaround.rb
+++ b/config/initializers/mongrel_workaround.rb
@@ -13,7 +13,8 @@ begin
end
end
-mongrel115 = check_mongrel_around_115
+#mongrel115 = check_mongrel_around_115
+mongrel115 = false
if Rails.version == '2.3.14' && mongrel115 && self.class.const_defined?(:Mongrel)
diff --git a/config/preinitializer.rb b/config/preinitializer.rb
index a6b4d1e..6fc36c4 100644
--- a/config/preinitializer.rb
+++ b/config/preinitializer.rb
@@ -13,6 +13,7 @@ end
begin
# Set up load paths for all bundled gems
ENV["BUNDLE_GEMFILE"] = File.expand_path("../../Gemfile", __FILE__)
+ Gem.clear_paths
Bundler.setup
rescue Bundler::GemNotFound
raise RuntimeError, "Bundler couldn't find some gems." +
@MeanderingCode
Copy link
Author

This is, as stated in the description, a diff of what I had to change in the config/ directory in order to get things running on Dreamhost shared hosting under Passenger with rvm.

IMPORTANT: This is not a patch. Note the environment vars and paths
IMPORTANT: I had to run a bundle pack and bundle install --path vendor/cache

Notable:

  • The environment variables being set twice is because of conflicting reports and lots of troubleshooting. I haven't checked, now that it's running, which one is needed (or both) for initialization.
  • The Bundler.require
  • The Gem.clear_paths is important, but I don't know if inclusion in both preinitializer.rb && evironment.rb are neccessary or if only one would do
  • I don't know why the mongrel check caused Passenger to error out, but I do know mongrel is not installed on Dreamhost shared servers ( I've never used Mongrel, myself)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment