Wes Gamble
2006-Apr-13 15:54 UTC
[Rails] 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:in `load_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:in `require'' /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:in `depend_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:in `const_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:in `traverse_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:in `traverse_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:in `recognize!'' /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:in `process_ 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:in `each_cgi'' /usr/lib/ruby/1.8/fcgi.rb:117:in `session'' /usr/lib/ruby/1.8/fcgi.rb:104:in `each_request'' /usr/lib/ruby/1.8/fcgi.rb:36:in `each'' /usr/lib/ruby/1.8/fcgi.rb:597:in `each_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:in `process!'' /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 -- Posted via http://www.ruby-forum.com/.
Wes Gamble
2006-Apr-13 16:18 UTC
[Rails] Re: Apache/fastcgi setup can''t find custom config/*.yml file
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 -- Posted via http://www.ruby-forum.com/.
Ezra Zygmuntowicz
2006-Apr-13 21:32 UTC
[Rails] Re: Apache/fastcgi setup can''t find custom config/*.yml file
On Apr 13, 2006, at 9:17 AM, Wes Gamble wrote:> 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 > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/railsWes- 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 Gamble
2006-Apr-13 21:58 UTC
[Rails] Re: Re: Apache/fastcgi setup can''t find custom config/*.yml
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 Zygmuntowicz wrote:> On Apr 13, 2006, at 9:17 AM, Wes Gamble wrote: > >> -- >> Posted via http://www.ruby-forum.com/. >> _______________________________________________ >> Rails mailing list >> Rails@lists.rubyonrails.org >> 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-- Posted via http://www.ruby-forum.com/.
Ezra Zygmuntowicz
2006-Apr-13 23:39 UTC
[Rails] Re: Re: Apache/fastcgi setup can''t find custom config/*.yml
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 On Apr 13, 2006, at 2:58 PM, Wes Gamble wrote:> 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 Zygmuntowicz wrote: >> On Apr 13, 2006, at 9:17 AM, Wes Gamble wrote: >> >>> -- >>> Posted via http://www.ruby-forum.com/. >>> _______________________________________________ >>> Rails mailing list >>> Rails@lists.rubyonrails.org >>> 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 > > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails