1

我正在关注 Rails 网站上的 Rails3 教程第 2 版。但是,我不想使用 rails 服务器,而是想在 OS X Lion 上使用我的 apache 设置。因此,我安装了Passenger 和Passenger Preference Pane。我可以毫无问题地进入欢迎页面,但是如果我单击链接查看我的应用程序环境,我会收到以下错误消息:

 Ruby (Rack) application could not be started
These are the possible causes:
There may be a syntax error in the application's code. Please check for such errors and fix them.
A required library may not installed. Please install all libraries that this application requires.
The application may not be properly configured. Please check whether all configuration files are written correctly, fix any incorrect configurations, and restart this application.
A service that the application relies on (such as the database server or the Ferret search engine server) may not have been started. Please start that service.
Further information about the error may have been written to the application's log file. Please check it in order to analyse the problem.
Error message:
Could not find coffee-script-source-1.3.1 in any of the sources (Bundler::GemNotFound)
Exception class:
PhusionPassenger::UnknownError
Application root:
/Users/ash/NetBeansProjects/ruby/first_app
Backtrace:
#   File    Line    Location
0   /Library/Ruby/Gems/1.8/gems/bundler-1.1.3/lib/bundler/spec_set.rb   90  in `materialize'
1   /Library/Ruby/Gems/1.8/gems/bundler-1.1.3/lib/bundler/spec_set.rb   83  in `map!'
2   /Library/Ruby/Gems/1.8/gems/bundler-1.1.3/lib/bundler/spec_set.rb   83  in `materialize'
3   /Library/Ruby/Gems/1.8/gems/bundler-1.1.3/lib/bundler/definition.rb 127 in `specs'
4   /Library/Ruby/Gems/1.8/gems/bundler-1.1.3/lib/bundler/definition.rb 172 in `specs_for'
5   /Library/Ruby/Gems/1.8/gems/bundler-1.1.3/lib/bundler/definition.rb 161 in `requested_specs'
6   /Library/Ruby/Gems/1.8/gems/bundler-1.1.3/lib/bundler/environment.rb    23  in `requested_specs'
7   /Library/Ruby/Gems/1.8/gems/bundler-1.1.3/lib/bundler/runtime.rb    11  in `setup'
8   /Library/Ruby/Gems/1.8/gems/bundler-1.1.3/lib/bundler.rb    107 in `setup'
9   /Library/Ruby/Gems/1.8/gems/passenger-3.0.12/lib/phusion_passenger/utils.rb 326 in `prepare_app_process'
10  /Library/Ruby/Gems/1.8/gems/passenger-3.0.12/lib/phusion_passenger/rack/application_spawner.rb  156 in `initialize_server'
11  /Library/Ruby/Gems/1.8/gems/passenger-3.0.12/lib/phusion_passenger/utils.rb 572 in `report_app_init_status'
12  /Library/Ruby/Gems/1.8/gems/passenger-3.0.12/lib/phusion_passenger/rack/application_spawner.rb  154 in `initialize_server'
13  /Library/Ruby/Gems/1.8/gems/passenger-3.0.12/lib/phusion_passenger/abstract_server.rb   204 in `start_synchronously'
14  /Library/Ruby/Gems/1.8/gems/passenger-3.0.12/lib/phusion_passenger/abstract_server.rb   180 in `start'
15  /Library/Ruby/Gems/1.8/gems/passenger-3.0.12/lib/phusion_passenger/rack/application_spawner.rb  129 in `start'
16  /Library/Ruby/Gems/1.8/gems/passenger-3.0.12/lib/phusion_passenger/spawn_manager.rb 253 in `spawn_rack_application'
17  /Library/Ruby/Gems/1.8/gems/passenger-3.0.12/lib/phusion_passenger/abstract_server_collection.rb    132 in `lookup_or_add'
18  /Library/Ruby/Gems/1.8/gems/passenger-3.0.12/lib/phusion_passenger/spawn_manager.rb 246 in `spawn_rack_application'
19  /Library/Ruby/Gems/1.8/gems/passenger-3.0.12/lib/phusion_passenger/abstract_server_collection.rb    82  in `synchronize'
20  /Library/Ruby/Gems/1.8/gems/passenger-3.0.12/lib/phusion_passenger/abstract_server_collection.rb    79  in `synchronize'
21  /Library/Ruby/Gems/1.8/gems/passenger-3.0.12/lib/phusion_passenger/spawn_manager.rb 244 in `spawn_rack_application'
22  /Library/Ruby/Gems/1.8/gems/passenger-3.0.12/lib/phusion_passenger/spawn_manager.rb 137 in `spawn_application'
23  /Library/Ruby/Gems/1.8/gems/passenger-3.0.12/lib/phusion_passenger/spawn_manager.rb 275 in `handle_spawn_application'
24  /Library/Ruby/Gems/1.8/gems/passenger-3.0.12/lib/phusion_passenger/abstract_server.rb   357 in `__send__'
25  /Library/Ruby/Gems/1.8/gems/passenger-3.0.12/lib/phusion_passenger/abstract_server.rb   357 in `server_main_loop'
26  /Library/Ruby/Gems/1.8/gems/passenger-3.0.12/lib/phusion_passenger/abstract_server.rb   206 in `start_synchronously'
27  /Library/Ruby/Gems/1.8/gems/passenger-3.0.12/helper-scripts/passenger-spawn-server  99  

如果我查看/Library/Ruby/Gems/1.8/任何子目录,我发现没有引用咖啡脚本。但是,快速ash$ bundle show coffee-script-source向我展示了 gem 文件位于/Users/ash/.rvm/gems/ruby-1.9.3-p194@rails3tutorial2ndEd/gems/coffee-script-source-1.3.1

(nb如果我使用rails服务器我没有这个问题,但这不是我想要的解决方案)

作为一个 Ruby 新手,我应该如何配置我的乘客设置以找到正确的文件?

4

1 回答 1

4

Phusion 可能只知道您的系统 gem 在哪里,而不是您的 rvm gem;您需要设置GEM_HOME环境变量以显示它在哪里查看。

如果你使用的是 apache,大概你有一个.htaccess文件来启动 Phusion。在那里,在 PassengerEnabled 行之前,添加

SetEnv GEM_HOME '/Users/ash/.rvm/gems/ruby-1.9.3-p194@rails3tutorial2ndEd/gems'

另一种方法,我认为应该在没有 Apache 的情况下工作,是在应用程序的配置目录中创建一个名为 setup_load_paths.rb 的文件(如果它不存在)并添加以下行:

ENV['GEM_HOME']='/Users/ash/.rvm/gems/ruby-1.9.3-p194@rails3tutorial2ndEd/gems
于 2012-04-26T15:31:41.313 回答