Search code examples
sinatrapassengergemfilevlad-deployer

Deploying Sinatra app to Passenger 4.0.0.rc6 by vlad. On production server it keeps requiring :development group in Gemfile


On production server Passenger(4.0.0.rc6 + nginx) keeps requiring the :development group in Gemfile. After manually commenting them out from Gemfile the app runs fine. Otherwise, Passenger would fail on starting the app because of the missing gems.

I checked the error page, it seemed Passenger was running in production mode:

Environment (value of RAILS_ENV, RACK_ENV, WSGI_ENV and PASSENGER_ENV)
production

Below are sources of my simple app, am I missing any setting to have Passenger work? Thanks.

Here is my app.rb, a simple sinatra app.

require 'rubygems'
require 'sinatra'
get "/" do
   "Hello!"
end

I deploy it by vlad to production server. Here is the config/deploy.rb

require 'bundler/vlad'
set :application, "sinatratest"
set :domain, "server domain"
set :deploy_to, "path/on/server"
set :repository, "mygithub branch"

And my config.ru

require 'rubygems'
require 'sinatra'
require './app'
run Sinatra::Application

And Gemfile

source 'https://rubygems.org'
gem 'sinatra'
group :development do
    gem 'vlad', require: false
    gem 'vlad-git', require: false
end

Solution

  • Answer to my own question:

    See the vlad part in Bundler manual, require 'bundler/vlad' and create a new task which runs both vlad:update and vlad:bundle:install or insert vlad:bundle:install to the original vlad:update command.

    If the server uses RVM then it needs to set the path of bundle explicitly either by source ~/.rvm/scripts/rvm in the vlad task or use the vlad-extra gem, see this post.

    What I am doing to make it work:

    In config/deploy.rb:

    require 'bundler/vlad'
    set :bundle_cmd, "source $HOME/.rvm/scripts/rvm && bundle" 
    

    In Rakefile:

    namespace :vlad do
      desc "Run vlad:update and vlad:bundle:install"
      task :deploy => %w[vlad:update vlad:bundle:install]
    end
    

    On local machine run rake vlad:deploy and it works.