[Radiant] About "couldn't find HOME environment" problem
dave4c03
dave4c03 at greatchiro.com
Fri Apr 27 03:07:45 CDT 2007
I performed the following
- cd ~user/myRadiantApp
- 'unset HOME' and verified it was gone
- 'echo ~' returns /var/www/vhosts/myDomain
- 'pwd' returns /var/www/vhosts/myDomain/myRadiantApp
- 'emacs test1.rb' and pasted in your code
- 'ruby test1.rb' ran with no errors
It is not very clear to me where home should be. My Fedora Core 4 system
running Plesk 8.1 seems to automatically set HOME when 'su user'. I do not
see HOME as providing any useful information. As far as I can see, the only
thing that matters is where myRadiantApp is.
For example, I could have put myRadiantApp under httpdocs. Instead I setup
my system is set up as follows
/var/www/vhosts/myDomain/ <----- ENV['HOME'] normally set by Linux
|---httpdocs/ ----->ln -s /var/www/vhosts/myDomain/myRadiantApp/public
httpdocs
|---myRadiantApp/
|---public/
| |---dispatch.fcgi
|---vendor/
|-radiant (I froze radiant so all application code owned by same
user/permissions)
I do not think you can count on where HOME is relative to myRadiantApp
before I unset HOME linux has set it to /var/www/vhosts/myDomain
'
On 4/26/07, keita <keita.yamaguchi at gmail.com> wrote:
>
> Hi John,
>
> Thank you for reading my mail. but I can't agree server configuration
> causes this problem. I explain more details.
>
> First, CGI and Apache/fast-cgi doesn't set HOME variable if you don't
> set SetENV. So dispatchers in these doesn't know HOME in most cases.
> Webrick or Mongrel users are O.K. because know HOME in most cases. I
> agree that this is a server specific and configuration issue. Radiant
> doesn't need to care it.
>
>
> > How does generator_base_extension.rb affect the HOME environment
> > variable?
>
> generator_base_extension.rb gets HOME environment as follows(radiant
> 0.6.0 / rails 1.2.3):
>
> (lib/plugins/extension_patches/lib/generator_base_extension.rb)
> require 'rails_generator'
>
> (rails/railties/lib/rails_generator.rb)
> require 'rails_generator/lookup'
> Rails::Generator::Base.send(:include, Rails::Generator::Lookup)
>
> (rails/railties/lib/rails_generator/lookup.rb:51)
> Rails::Generator::Lookup.included
>
> (rails/railties/lib/rails_generator/lookup.rb:98)
> Rails::Generator::Lookup::ClassMethods.use_component_sources!
>
> (rails/railties/lib/rails_generator/lookup.rb:25)
> Dir.user_home
>
> If ENV['HOME'] is nil (this is the case of CGI and Apache/fast-cgi),
> it calls File.expand_path '~'. But File.expand_path needs to know
> HOME, check it by the following commands:
>
> unset HOME
> ruby -e 'File.expand_path "~"'
>
> This is the reason of the error message (but this isn't the root cause
> of the problem, I think). so, if rails dispatchers(CGI,
> Apache/fast-cgi) load rails/railties/lib/rails_generator.rb, then
> happen the error.
>
>
> > Does the default Rails generator set the HOME environment
> > variable in environment.rb?
>
> No. Rails generator(like script/generate) doesn't read
> config/environment.rb but config/boot.rb. This problem is about
> dispatchers(.fcgi, .cgi, .rb), not generator.
>
> I believe normally rails applications don't need to set HOME in
> environment.rb. I checked Mephisto, Typo and Beast. Such rails
> applications don't need to set HOME in CGI and Apache/fast-cgi because
> these dispatchers don't require rails/railties/lib/rails_generator.rb.
>
> I think rails generators are for spitting out Ruby code. Why do
> radiant's dispatchers need to generate new code? I can't understand
> the advantage and I believe dispatchers don't need to generate any
> code.
>
> If it is right, this is the waste misloading problem of
> Radinat::Initializer. Radinat::Initializer.run(:process, &config) in
> config/environment.rb loads lib/plugins/extension_patches/init.rb and
> it requires lib/plugins/extension_patches/lib/generator_base_extension.rb.
> I think this is the root cause of the problem. Please try to reproduce
> the problem by unsetting HOME and exec the following code:
>
> require "pp"
> begin
> require 'config/environment.rb'
> rescue Exception
> pp $@
> end
>
>
> Summary of my opinion:
>
> 1. I agree that ENV['HOME'] == nil is server specific(CGI,
> Apache/fast-cgi) and hosting configuration issue. So radiant doesn't
> need to care it.
>
> 2. rails/railties/lib/rails_generator.rb need to know HOME.
>
> 3. It is radiant issue that Radiant's dispatcher loads
> rails/railties/lib/rails_generator.rb, and other rails applications'
> dispatchers don't load rails_generator.rb.
>
> 4. I believe dispatchers don't need to generate any code and must not.
>
> 5. If 4 is true, the cause of this problem is waste loading of
> generator_base_extension.rb and rails/railties/lib/rails_generator.rb
> for dispatchers. Generators like script/generate need to requires
> rails_generator.rb and dispatchers don't.
>
> For above reasons, I conclude this is a problem of radiant. Is it
> right? My arguments is based on the assumption of 4, so I am sorry for
> wasting your time if this assumption is wrong. I don't think of the
> advantage that dispatchers act as generator because I am not familiar
> with rails.
>
> ----
> Keita Yamaguchi
> _______________________________________________
> Radiant mailing list
> Post: Radiant at lists.radiantcms.org
> Search: http://radiantcms.org/mailing-list/search/
> Site: http://lists.radiantcms.org/mailman/listinfo/radiant
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.radiantcms.org/pipermail/radiant/attachments/20070427/e6bb8b25/attachment.html
More information about the Radiant
mailing list