# About "couldn't find HOME environment" problem

**URL:** <https://www.ruby-forum.com/t/about-couldnt-find-home-environment-problem/92979>\
**Category:** Radiant CMS\
**Created:** [April 26, 2007, 8:35am UTC](https://www.ruby-forum.com/t/about-couldnt-find-home-environment-problem/92979 "2007-04-26T08:35:08Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![keita](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/977dab/32.png) [@keita](https://www.ruby-forum.com/u/keita)\
**Post date:** [April 26, 2007, 8:35am UTC](https://www.ruby-forum.com/t/about-couldnt-find-home-environment-problem/92979/1 "2007-04-26T08:35:08Z")

</div>

Hi,

Some few people (including me) reported “couldn’t find HOME  
environment” problem in this ML and trac(for example ticket #500).  
Ticket #500 was closed by the reason “This is an issue with your  
server setup. It’s not a problem with Radiant.”, but I don’t think so.  
I believe this is because  
lib/plugins/extension\_patches/lib/generator\_base\_extension.rb does  
“require ‘rails\_generator’”. Dispatchers(.cgi, .fcgi and .rb) of  
Radiant don’t need this file and I think these must not load  
rails\_generator. The problem happens to people using CGI or Apache(or  
Lighttpd)/fast-cgi in most cases because HOME environment is not a  
standard CGI metavariable.

I think the solution is that move  
lib/plugins/extension\_patches/lib/generator\_base\_extension.rb to  
lib/generators/generator\_base\_extension.rb and load it in  
script/generate etc. Is it right? I am not familiar with rails, sorry  
if I am wrong.

* * *

Keita Y.

---

<div class="post-metadata">

**Author:** ![keita](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/977dab/32.png) [@keita](https://www.ruby-forum.com/u/keita)\
**Post date:** [April 26, 2007, 5:23pm UTC](https://www.ruby-forum.com/t/about-couldnt-find-home-environment-problem/92979/2 "2007-04-26T17:23:54Z")

</div>

keita wrote:

> standard CGI metavariable.  
> How does generator\_base\_extension.rb affect the HOME environment  
> variable? Does the default Rails generator set the HOME environment  
> variable in environment.rb? I don’t believe it does. So again this isn’t  
> a problem with Radiant. It’s a problem with the way your hosting  
> environment is configured.

We could certainly add a few lines to environment.rb that were commented  
out like this:

# Depending on how your envoronment is set up you may need to uncomment

# the following line and enter the correct path to your home directory:

#ENV[‘HOME’] = ‘/path/to/your/home/directory’

Would this be helpful?

–  
John L.  
[http://wiseheartdesign.com](http://wiseheartdesign.com)

---

<div class="post-metadata">

**Author:** ![keita](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/977dab/32.png) [@keita](https://www.ruby-forum.com/u/keita)\
**Post date:** [April 26, 2007, 5:50pm UTC](https://www.ruby-forum.com/t/about-couldnt-find-home-environment-problem/92979/3 "2007-04-26T17:50:01Z")

</div>

John,

I had this very same problem last night and the only way to solve it  
was to use a line just like you suggested:

ENV[‘HOME’] = ‘/home/xyz/’

My environment is Litespeed 3.03 running on Centos. Took me a while to  
figure it out. Maybe a _gotcha_ section in the install docs would  
help.

Sincerely,

AEM

---

<div class="post-metadata">

**Author:** ![keita](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/977dab/32.png) [@keita](https://www.ruby-forum.com/u/keita)\
**Post date:** [April 27, 2007, 10:09am UTC](https://www.ruby-forum.com/t/about-couldnt-find-home-environment-problem/92979/4 "2007-04-27T10:09:26Z")

</div>

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  
’

---

<div class="post-metadata">

**Author:** ![keita](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/977dab/32.png) [@keita](https://www.ruby-forum.com/u/keita)\
**Post date:** [April 27, 2007, 2:57pm UTC](https://www.ruby-forum.com/t/about-couldnt-find-home-environment-problem/92979/5 "2007-04-27T14:57:11Z")

</div>

On 4/27/07, keita [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> 1. 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.
> 
> 2. I believe dispatchers don’t need to generate any code and must not.

I must agree with you, Keita. Nice writeup

---

<div class="post-metadata">

**Author:** ![keita](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/977dab/32.png) [@keita](https://www.ruby-forum.com/u/keita)\
**Post date:** [April 27, 2007, 8:35am UTC](https://www.ruby-forum.com/t/about-couldnt-find-home-environment-problem/92979/6 "2007-04-27T08:35:14Z")

</div>

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 Y.

---

<div class="post-metadata">

**Author:** ![keita](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/977dab/32.png) [@keita](https://www.ruby-forum.com/u/keita)\
**Post date:** [April 30, 2007, 9:06pm UTC](https://www.ruby-forum.com/t/about-couldnt-find-home-environment-problem/92979/7 "2007-04-30T21:06:23Z")

</div>

keita wrote:

> 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.

OK, I see what you are saying now. Please reopen the ticket and submit a  
patch for it if you can.

–  
John L.  
[http://wiseheartdesign.com](http://wiseheartdesign.com)
