Ashley Bye
Ashley Bye

Reputation: 1750

Where does Passenger look for Gems

I am following the Rails3 tutorial 2nd Edition from the Rails website. However, rather than using the rails server I want to use my apache setup on OS X Lion. As such, I have installed Passenger and the Passenger Preference Pane. I can get to the welcome page without any problems but if I click the link to view my Application Environment I get the following error message:

 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  

If I look in /Library/Ruby/Gems/1.8/ and any of the subdirectories I find no reference to coffee script. However, a quick ash$ bundle show coffee-script-source shows me the gem files are at /Users/ash/.rvm/gems/ruby-1.9.3-p194@rails3tutorial2ndEd/gems/coffee-script-source-1.3.1

(n.b. If I use rails server I don't have this problem, but that is not the resolution I want)

As a total Ruby newbie, how should I be configuring my Passenger setup to find the correct files?

Upvotes: 1

Views: 1376

Answers (1)

Kevin
Kevin

Reputation: 56049

Phusion probably only knows where your system gems are, not your rvm gems; you need to set the GEM_HOME environment variable to show it where to look.

If you're using apache, presumably you have a .htaccess file to start Phusion. In there, before the PassengerEnabled line, add

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

The other way, which I believe should work without Apache, is to create a file called setup_load_paths.rb (if it doesn't exist) in your application's config directory and add this line:

ENV['GEM_HOME']='/Users/ash/.rvm/gems/ruby-1.9.3-p194@rails3tutorial2ndEd/gems

Upvotes: 4

Related Questions