Question

I'm new to Ruby on Rails and have inherited a pretty large legacy app that I need to get running in a dev environment. I've created a OSX Mountain Lion virtual machine from scratch to use as my dev box. I'm running with ruby 1.8.7 & rails 2.2.2. I have the latest phusion passenger module installed for apache2.

I'm getting this very generic error message when trying to load the app in Safari. The apache log is not showing anything and the log for the rails app is not showing anything. It seems obvious that some gem is not being found on startup and the init phase is aborting. Or RubyGems itself is not the right version?

This same application can run using ruby script/server and I can run other rails apps in the web browser, so it seems there is something about this particular application.

Is there any way for me to see more details that might be lurking under the hood? It seems like I should be able to get access to the key error message that would tell me what exactly is keeping the app from starting. I would expect to see that some specific gem is not present or something. Or does this backtrace say something very obvious that I don't understand?

Thanks very much for any help.

Paul.

Additional Note:

Just tried passenger stand alone (passenger start in my app directory) and the app comes up in the browser (minus some static images). Does that say something about my apache config?

Error Message:

Ruby on Rails application could not be started
Phusion Passenger has listed more information about the error below

The aplication has exited during startup (i.e. during the evaluation
of config/environment.rb). The error message may have been written to
the web server's log file. Please check the web server's log file
(i.e. not the (Rails) application's log file) to find out why the
application exited. If that doesn't help, then please use the
backtrace below to debug the problem.

Application root:
/Users/paul/Code/Site4/www_app
Backtrace:
#   File    Line    Location
0   /Users/paul/Code/Site4/www_app/config/environment.rb    29  in `exit'
1   /Users/paul/Code/Site4/www_app/config/environment.rb    29  
2   /Users/paul/.rvm/rubies/ruby-1.8.7-p371/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb   36  in `gem_original_require'
3   /Users/paul/.rvm/rubies/ruby-1.8.7-p371/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb   36  in `require'
4   /Users/paul/.rvm/gems/ruby-1.8.7-p371/gems/passenger-3.0.19/lib/phusion_passenger/classic_rails/application_spawner.rb  222 in `preload_application'
5   /Users/paul/.rvm/gems/ruby-1.8.7-p371/gems/passenger-3.0.19/lib/phusion_passenger/classic_rails/application_spawner.rb  181 in `initialize_server'
6   /Users/paul/.rvm/gems/ruby-1.8.7-p371/gems/passenger-3.0.19/lib/phusion_passenger/utils.rb  563 in `report_app_init_status'
7   /Users/paul/.rvm/gems/ruby-1.8.7-p371/gems/passenger-3.0.19/lib/phusion_passenger/classic_rails/application_spawner.rb  174 in `initialize_server'
8   /Users/paul/.rvm/gems/ruby-1.8.7-p371/gems/passenger-3.0.19/lib/phusion_passenger/abstract_server.rb    204 in `start_synchronously'
9   /Users/paul/.rvm/gems/ruby-1.8.7-p371/gems/passenger-3.0.19/lib/phusion_passenger/abstract_server.rb    180 in `start'
10  /Users/paul/.rvm/gems/ruby-1.8.7-p371/gems/passenger-3.0.19/lib/phusion_passenger/classic_rails/application_spawner.rb  149 in `start'
11  /Users/paul/.rvm/gems/ruby-1.8.7-p371/gems/passenger-3.0.19/lib/phusion_passenger/spawn_manager.rb  219 in `spawn_rails_application'
12  /Users/paul/.rvm/gems/ruby-1.8.7-p371/gems/passenger-3.0.19/lib/phusion_passenger/abstract_server_collection.rb 132 in `lookup_or_add'
13  /Users/paul/.rvm/gems/ruby-1.8.7-p371/gems/passenger-3.0.19/lib/phusion_passenger/spawn_manager.rb  214 in `spawn_rails_application'
14  /Users/paul/.rvm/gems/ruby-1.8.7-p371/gems/passenger-3.0.19/lib/phusion_passenger/abstract_server_collection.rb 82  in `synchronize'
15  /Users/paul/.rvm/gems/ruby-1.8.7-p371/gems/passenger-3.0.19/lib/phusion_passenger/abstract_server_collection.rb 79  in `synchronize'
16  /Users/paul/.rvm/gems/ruby-1.8.7-p371/gems/passenger-3.0.19/lib/phusion_passenger/spawn_manager.rb  213 in `spawn_rails_application'
17  /Users/paul/.rvm/gems/ruby-1.8.7-p371/gems/passenger-3.0.19/lib/phusion_passenger/spawn_manager.rb  132 in `spawn_application'
18  /Users/paul/.rvm/gems/ruby-1.8.7-p371/gems/passenger-3.0.19/lib/phusion_passenger/spawn_manager.rb  275 in `handle_spawn_application'
19  /Users/paul/.rvm/gems/ruby-1.8.7-p371/gems/passenger-3.0.19/lib/phusion_passenger/abstract_server.rb    357 in `__send__'
20  /Users/paul/.rvm/gems/ruby-1.8.7-p371/gems/passenger-3.0.19/lib/phusion_passenger/abstract_server.rb    357 in `server_main_loop'
21  /Users/paul/.rvm/gems/ruby-1.8.7-p371/gems/passenger-3.0.19/lib/phusion_passenger/abstract_server.rb    206 in `start_synchronously'
22  /Users/paul/.rvm/gems/ruby-1.8.7-p371/gems/passenger-3.0.19/helper-scripts/passenger-spawn-server   99  

apache config:

LoadModule passenger_module /Users/paul/.rvm/gems/ruby-1.8.7-p371/gems/passenger-3.0.19/ext/apache2/mod_passenger.so
PassengerRoot /Users/paul/.rvm/gems/ruby-1.8.7-p371/gems/passenger-3.0.19
PassengerRuby /Users/paul/.rvm/wrappers/ruby-1.8.7-p371/ruby

<Directory "/Users/paul/Code">
    Order allow,deny
    Allow from all
</Directory>

NameVirtualHost *:80

<VirtualHost *:80>
    RailsEnv development
    ServerName www.local.com
    DocumentRoot /Users/paul/Code/Site4/www_app/public
    <Directory /Users/paul/Code/Site4/www_app/public>
       AllowOverride all
       Options -MultiViews
    </Directory>
 </VirtualHost>

Misc versions of things:

rvm list

rvm rubies

=* ruby-1.8.7-p371 [ i686 ]

# => - current
# =* - current && default
#  * - default

DBDev:~ paul$ gem --version
1.8.25
DBDev:~ paul$ rails --version
Rails 2.2.2

gem list:

*** LOCAL GEMS ***

actionmailer (2.2.2)
actionpack (2.2.2)
activemerchant (1.4.1)
activemodel (3.2.11)
activerecord (2.2.2)
activeresource (2.2.2)
activesupport (3.2.11, 2.2.2)
archive-tar-minitar (0.5.2)
archive-zip (0.3.0)
arel (3.0.2)
builder (3.1.4, 3.0.4)
bundler (1.2.3)
daemon_controller (1.1.1)
deep_merge (0.1.0)
differ (0.1.1)
fastercsv (1.5.0)
fastthread (1.0.7)
haml (2.2.5)
i18n (0.6.1)
io-like (0.3.0)
multi_json (1.5.0)
mysql (2.9.0)
paperclip (2.3.5)
passenger (3.0.19)
rack (1.5.2, 1.5.1)
rails (2.2.2)
rake (10.0.3, 0.8.7)
rmagick (2.13.2)
rubygems-bundler (1.1.0)
rvm (1.11.3.6)
sqlite3 (1.3.7)
tzinfo (0.3.35)
will_paginate (2.3.16)

gem environment:

RubyGems Environment:
  - RUBYGEMS VERSION: 1.8.25
  - RUBY VERSION: 1.8.7 (2012-10-12 patchlevel 371) [i686-darwin12.2.1]
  - INSTALLATION DIRECTORY: /Users/paul/.rvm/gems/ruby-1.8.7-p371
  - RUBY EXECUTABLE: /Users/paul/.rvm/rubies/ruby-1.8.7-p371/bin/ruby
  - EXECUTABLE DIRECTORY: /Users/paul/.rvm/gems/ruby-1.8.7-p371/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86-darwin-12
  - GEM PATHS:
     - /Users/paul/.rvm/gems/ruby-1.8.7-p371
     - /Users/paul/.rvm/gems/ruby-1.8.7-p371@global
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :benchmark => false
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - http://rubygems.org/

environment.rb file:

# Be sure to restart your server when you modify this file

# Uncomment below to force Rails into production mode when
# you don't control web/app server and can't set it the proper way
# ENV['RAILS_ENV'] ||= 'production'
ENV['RAILS_ENV'] = 'development'

# Specifies gem version of Rails to use when vendor/rails is not present
RAILS_GEM_VERSION = '2.2.2' unless defined? RAILS_GEM_VERSION

# Bootstrap the Rails environment, frameworks, and default configuration
require File.join(File.dirname(__FILE__), 'boot')

# Global libraries
#require 'rubygems'
gem 'activemerchant', '=1.4.1'
require 'active_merchant'
require 'deep_merge'
require 'fastercsv'
require 'paperclip'

require 'digest/sha1'
require 'net/http'
require 'uri'

# Default host/app types.
if ENV['DEB_HOST_TYPE'].to_s.strip.empty? then
  puts 'ERROR: Environment variable DEB_HOST_TYPE is not set!  (Did you remember to export it?)  Exiting ...'
  exit 1
end
$DEB_HOST_TYPE = ENV['DEB_HOST_TYPE']
$DEB_APP_TYPE = 'admin'

Rails::Initializer.run do |config|
  config.time_zone = 'UTC'
  config.active_record.colorize_logging = false
  config.action_controller.session_store = :active_record_store
end
Was it helpful?

Solution

Found the problem in the environment.rb file in the lines:

# Default host/app types.
if ENV['DEB_HOST_TYPE'].to_s.strip.empty? then
  puts 'ERROR: Environment variable DEB_HOST_TYPE is not set!  (Did you remember to export it?)  Exiting ...'
  exit 1
end

The environment variable was indeed empty so the exit was being called. The puts string never showed up in anything I saw. I finally went in and edited out the exit and got the error that nil could not be turned into a string. I hard-coded the value of ENV['DEB_HOST_TYPE'] to what it should be and now the app runs.

Also wanted to mention when I changed the puts to $stderr.puts the message showed up on the error page produced by passenger.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top