Apache/fastcgi setup can't find custom config/*.yml file!

All,

Apache 2/FastCGI on Linux

My fastcgi config. file is set up to run the “test” RAILS_ENV.

When I go to access a view associated with a particular controller, I
keep getting a ENOENT (file not found) error on a custom config. file
that I am attempting to load.

What I can’t figure out is why it can’t find the file.

Here’s the code that loads it in my controller:

require ‘yaml’

class ESimplyController < ApplicationController
@@config = “”
@@config = YAML.load_file(“config/eSimplyConf.yml”)

This setup works fine in my development environment.

When this code gets called, I get the following error in my test.log
file:

Errno::ENOENT (No such file or directory - config/eSimplyConf.yml):
/usr/lib/ruby/1.8/yaml.rb:143:in initialize' /usr/lib/ruby/1.8/yaml.rb:143:inload_file’
/app/controllers/e_simply_controller.rb:5
/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in
require' /usr/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependenc ies.rb:147:inrequire’
/usr/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependenc
ies.rb:65:in require_or_load' /usr/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependenc ies.rb:30:independ_on’
/usr/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependenc
ies.rb:85:in require_dependency' /usr/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependenc ies.rb:98:inconst_missing’
/usr/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependenc
ies.rb:131:in const_missing' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/routing. rb:237:intraverse_to_controller’
generated/routing/recognition.rb:30:in eval' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/routing. rb:237:intraverse_to_controller’
generated/routing/recognition.rb:30:in recognize_path' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/routing. rb:477:inrecognize!’
/usr/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/dispatcher.rb:38:in
dispatch' /usr/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/fcgi_handler.rb:150:inprocess_
request’
/usr/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/fcgi_handler.rb:54:in
process!' /usr/lib/ruby/1.8/fcgi.rb:600:ineach_cgi’
/usr/lib/ruby/1.8/fcgi.rb:117:in session' /usr/lib/ruby/1.8/fcgi.rb:104:ineach_request’
/usr/lib/ruby/1.8/fcgi.rb:36:in each' /usr/lib/ruby/1.8/fcgi.rb:597:ineach_cgi’
/usr/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/fcgi_handler.rb:53:in
process!' /usr/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/fcgi_handler.rb:23:inprocess!’
/var/www/html/eSimplyTest/public/dispatch.fcgi:26

Rendering
/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/te
mplates/rescues/layout.rhtml (500 Internal Error)

=========== END OF ERROR =======================

I’m under the impression that the relative path to my config file is OK
and that it will just be interpreted relative to RAILS_ROOT (which to
the best of my knowledge, is correct)? Is that not true for some
reason?

Thanks,
Wes

What I really can’t figure out is why it can find the database.yml file
but not my custom one.

Is there something special about the way that yaml.rb looks for files?

Some env. var. that I need to set?

Wes

On Apr 13, 2006, at 9:17 AM, Wes G. wrote:


Posted via http://www.ruby-forum.com/.


Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails

Wes-

When you try to load files from the filesystem in a rails app, never

use relative paths or you will get errors just like you are seeing.
Change this line:

@@config = YAML.load_file(“config/eSimplyConf.yml”)

To this:

@@config = YAML.load_file(“#{RAILS_ROOT}/config/eSimplyConf.yml”)

And you will be good to go.

Cheers-
-Ezra

Wes-

THe book is called Rails Deployment. SO it will cover running your

own VPS or dedicated server for rails as well as shared hosting and
clusters. It also has many practical development techniques and
advanced active record tips and well as a TDD and BDD chapter. I am
pushing hard to get the beta book out before RailsCOnf in June.

Cheers-
-Ezra

Ezra,

Thanks! That was exactly my problem - that I wasn’t using “absolute”
paths.

Just growing pains into big-boy deployment.

When’s your book coming out and what will it be?

Wes

Ezra Z. wrote:

On Apr 13, 2006, at 9:17 AM, Wes G. wrote:


Posted via http://www.ruby-forum.com/.


Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails

Wes-

When you try to load files from the filesystem in a rails app, never
use relative paths or you will get errors just like you are seeing.
Change this line:

@@config = YAML.load_file(“config/eSimplyConf.yml”)

To this:

@@config = YAML.load_file(“#{RAILS_ROOT}/config/eSimplyConf.yml”)

And you will be good to go.

Cheers-
-Ezra