我是Ruby on Rails的新手,并继承了一个非常大的遗留应用程序,我需要在开发环境中运行。我从头开始创建了一个OSX Mountain Lion虚拟机,用作我的开发盒。我正在使用ruby 1.8.7&铁轨2.2.2。我为apache2安装了最新的phusion乘客模块。
尝试在Safari中加载应用时,我收到了这个非常通用的错误消息。 apache日志没有显示任何内容,rails应用程序的日志没有显示任何内容。很明显,在启动时没有找到某些gem,并且init阶段正在中止。或者RubyGems本身不是正确的版本?
这个应用程序可以使用 ruby脚本/服务器运行,我可以在Web浏览器中运行其他rails应用程序,所以看起来这个特定的应用程序有一些东西。
有什么方法可以让我看到可能潜伏在引擎盖下的更多细节吗?看起来我应该能够访问关键错误消息,告诉我究竟是什么阻止应用启动。我希望看到一些特定的宝石不存在或什么的。或者这种回溯是否说明了一些我不明白的事情?
非常感谢您的帮助。
保罗。
附加说明:
刚试过乘客站立(乘客在我的app目录中启动),应用程序出现在浏览器中(减去一些静态图像)。这说明了我的apache配置吗?
错误讯息:
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>
其他版本的东西:
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
宝石清单:
*** 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)
宝石环境:
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文件:
# 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
答案 0 :(得分:0)
在以下行中的environment.rb文件中找到问题:
# 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
环境变量确实是空的,因此正在调用退出。在我看到的任何东西中,puts字符串都没有出现过。我终于进去并编辑了退出并得到了nil无法变成字符串的错误。我将ENV ['DEB_HOST_TYPE']的值硬编码为它应该是什么,现在应用程序运行。
还想提一下当我将puts更改为$ stderr.puts时,消息显示在乘客生成的错误页面上。