Before I talk about how I got my Sinatra blog working, I want to rant. I am using Sinatra 1.0 with Bundler gem for managing dependencies.

My awful host (Dreamhost) just messed up again. Though I am aware shared hosts are not liable for issues that happen to your application when they upgrade dependencies, I am still disappointed by its inability to support any Ruby framework well.

I like to inform everyone interested in jumping to Rails/ Sinatra development that it's best you go for reliable options like BurstNet Linux VPS plan, Slicehost, Rackspace and if you're so ambitious — Amazon ECS!

Here's why Dreamhost shared or VPS will not work for you:

  1. Dreamhost will kill processes that consume memory. Running "bundle install" will not work on a shared host.
  2. Dreamhost PS is just as unreliable as Dreamhost shared hosting for Ruby programmers. You'll get more value from Linode or Slicehost.
  3. You'll waste hours fixing issues you're not supposed to fix.

If you don't have the same patience that I have, I recommend not using a shared host.
Most of my sites are now transferred to a reliable VPS server. I have over three applications that are in their alpha versions and hosted on VPS servers.

Why should you use Bundler even if bundle commands do not work on Dreamhost?

Bundler actually solves several errors like "can't activate activesupport 2.3.8. already activated 3.0.3." But first how do you install bundler?

Follow my blog post about installing your own gems on Dreamhost.

My Gemfile looks like this:


source :gemcutter

gem 'sinatra', '1.0'
gem 'pony', '1.0.1'
gem 'activesupport', '2.3.8'
gem 'activerecord','2.3.8'
gem 'rdiscount', '1.6.5'
gem 'sinatra-captcha', '0.1.0.0'
gem 'rack-flash', '0.1.1'
gem 'hpricot', '0.8.2'
gem 'sinatra-bundles', '0.4.0'
gem 'rugalytics', '0.2.0'
gem 'sinatra-content-for', '0.2'
gem 'syntax', '1.0.0'
gem 'haml', '3.0.18'

Install your gems using the usual commands:

gem install haml -v=3.0.18

You might get following error:

Ruby (Rack) application could not be started

Specifying your gem path will fix the issue.

Gem.clear_paths
ENV['GEM_HOME'] = '/home/username/.gems'
ENV['GEM_PATH'] = File.expand_path('~/.gems') + ':/usr/lib/ruby/gems/1.8'

require 'rubygems'
require 'bundler'

Bundler.require

FileUtils.mkdir_p 'log' unless File.exists?('log')
log = File.new("log/sinatra.log", "a")
$stdout.reopen(log)
$stderr.reopen(log)

disable :run, :reload
set :environment, :production
set :views, File.dirname(__FILE__) + '/views'
require 'yourapp'
run Sinatra::Application

The code for logging errors has been helpful for me.
As some people say, "if there's a will, there's a way." But we all have limitations and sometimes some issues are not worth fixing. Have a stress-free life everyone!

comments powered byDisqus

Hello! I am Kat. I've been a developer for several years. When I'm not sitting down, reading and working for long hours, I am traveling to some place of interest.
If you want to reach out, you can send me an email or add me up on Google Plus.