# HOME and USERPROFILE aliasing under Windows

**URL:** <https://www.ruby-forum.com/t/home-and-userprofile-aliasing-under-windows/141954>\
**Category:** IronRuby\
**Created:** [July 2, 2008, 12:32am UTC](https://www.ruby-forum.com/t/home-and-userprofile-aliasing-under-windows/141954 "2008-07-02T00:32:27Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![John\_LSSIRONRUBY](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/4491bb/32.png) [@John\_LSSIRONRUBY](https://www.ruby-forum.com/u/John_LSSIRONRUBY)\
**Post date:** [July 2, 2008, 12:32am UTC](https://www.ruby-forum.com/t/home-and-userprofile-aliasing-under-windows/141954/1 "2008-07-02T00:32:27Z")

</div>

MRI currently expects the HOME environment variable to be set under  
Windows. Various operations involving ~ and Dir will fail if HOME is not  
defined.

However, HOME is rarely defined under Windows by default. Instead  
USERPROFILE is what normally represents HOME. IronRuby is considering  
aliasing HOME to USERPROFILE if HOME isn’t already defined at startup  
time.

Does this seem like something reasonable to do in our implementation?

Thanks,  
-John

---

<div class="post-metadata">

**Author:** ![John\_LSSIRONRUBY](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/4491bb/32.png) [@John\_LSSIRONRUBY](https://www.ruby-forum.com/u/John_LSSIRONRUBY)\
**Post date:** [July 2, 2008, 1:04am UTC](https://www.ruby-forum.com/t/home-and-userprofile-aliasing-under-windows/141954/2 "2008-07-02T01:04:02Z")

</div>

On Wed, Jul 2, 2008 at 12:29 AM, John L. (IRONRUBY)  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> MRI currently expects the HOME environment variable to be set under Windows.  
> Various operations involving ~ and Dir will fail if HOME is not defined.
> 
> However, HOME is rarely defined under Windows by default. Instead  
> USERPROFILE is what normally represents HOME. IronRuby is considering  
> aliasing HOME to USERPROFILE if HOME isn’t already defined at startup time.

USERPROFILE sometimes matches the location of roaming profiles, and  
not the HOMEDRIVE+HOMEPATH used is some NT domains.

Ruby 1.9 uses a different list of options for HOME in case if not  
defined:

[ruby-core:12347]

[http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/12347](http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/12347)

"  
In 1.9, when ENV[‘HOME’] isn’t set, it will be set using  
HOMEDRIVE+HOMEPATH, USERPROFILE, and “Personal” special-folder  
if they are all unset."

I think similar approach should be taked by 1.8

But again, those are my comments and only that.

## Regards,

## Luis L. AREA 17

Human beings, who are almost unique in having the ability to learn from  
the experience of others, are also remarkable for their apparent  
disinclination to do so.  
Douglas Adams

---

<div class="post-metadata">

**Author:** ![John\_LSSIRONRUBY](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/4491bb/32.png) [@John\_LSSIRONRUBY](https://www.ruby-forum.com/u/John_LSSIRONRUBY)\
**Post date:** [July 2, 2008, 1:39am UTC](https://www.ruby-forum.com/t/home-and-userprofile-aliasing-under-windows/141954/3 "2008-07-02T01:39:10Z")

</div>

John L.:

> > [http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/12347](http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/12347)  
> > Awesome. We’ll match the 1.9 behavior then.  
> > Actually, to clarify this a bit further, we won’t _set_ HOME, instead  
> > we’ll use HOMEDRIVE+HOMEPATH, USERPROFILE, and “Personal” everywhere  
> > that Ruby uses HOME if HOME isn’t defined.

I don’t think we should be setting HOME arbitrarily for the process.

Thanks,  
-John

---

<div class="post-metadata">

**Author:** ![John\_LSSIRONRUBY](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/4491bb/32.png) [@John\_LSSIRONRUBY](https://www.ruby-forum.com/u/John_LSSIRONRUBY)\
**Post date:** [July 2, 2008, 8:26am UTC](https://www.ruby-forum.com/t/home-and-userprofile-aliasing-under-windows/141954/4 "2008-07-02T08:26:15Z")

</div>

On Wed, Jul 2, 2008 at 1:33 AM, John L. (IRONRUBY)  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > > [ruby-core:12347]  
> > > But again, those are my comments and only that.
> > 
> > Awesome. We’ll match the 1.9 behavior then.
> 
> Actually, to clarify this a bit further, we won’t _set_ HOME, instead we’ll use HOMEDRIVE+HOMEPATH, USERPROFILE, and “Personal” everywhere that Ruby uses HOME if HOME isn’t defined.
> 
> I don’t think we should be setting HOME arbitrarily for the process.

For me was clear:

ENV[‘HOME’] || ENV[‘HOMEDRIVE’] + ENV[‘HOMEPATH’] ||  
ENV[‘USERPROFILE’] for every time user try to do:

File.expand\_path(‘~’)  
Dir.chdir do … end  
etc.

## Regards,

## Luis L. AREA 17

Human beings, who are almost unique in having the ability to learn from  
the experience of others, are also remarkable for their apparent  
disinclination to do so.  
Douglas Adams

---

<div class="post-metadata">

**Author:** ![John\_LSSIRONRUBY](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/4491bb/32.png) [@John\_LSSIRONRUBY](https://www.ruby-forum.com/u/John_LSSIRONRUBY)\
**Post date:** [July 2, 2008, 1:09am UTC](https://www.ruby-forum.com/t/home-and-userprofile-aliasing-under-windows/141954/5 "2008-07-02T01:09:18Z")

</div>

Luis L.:

> "  
> In 1.9, when ENV[‘HOME’] isn’t set, it will be set using  
> HOMEDRIVE+HOMEPATH, USERPROFILE, and “Personal” special-folder  
> if they are all unset."
> 
> I think similar approach should be taked by 1.8
> 
> But again, those are my comments and only that.

Awesome. We’ll match the 1.9 behavior then.

Thanks,  
-John

---

<div class="post-metadata">

**Author:** ![John\_LSSIRONRUBY](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/4491bb/32.png) [@John\_LSSIRONRUBY](https://www.ruby-forum.com/u/John_LSSIRONRUBY)\
**Post date:** [July 2, 2008, 8:38am UTC](https://www.ruby-forum.com/t/home-and-userprofile-aliasing-under-windows/141954/6 "2008-07-02T08:38:33Z")

</div>

Hi,

On Wed, Jul 2, 2008 at 12:58 AM, Luis L. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> Ruby 1.9 uses a different list of options for HOME in case if not defined:
> 
> [ruby-core:12347]
> 
> [http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/12347](http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/12347)

Ah, good. I also noticed one case where MRI still relies on HOME: irb  
is actually uses ENV[‘HOME’] only, to find the irbrc file with  
customizations, and if it doesn’t find it, irb uses the current dir  
(which is kinda weird).

lib/irb/init.rb:

if home = ENV[“HOME”]  
yield proc{|rc| home+“/.irb#{rc}”}  
end  
home = Dir.pwd

So, I ended up explicitly defining HOME on Windows.

Thanks,  
–Vladimir

---

<div class="post-metadata">

**Author:** ![John\_LSSIRONRUBY](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/4491bb/32.png) [@John\_LSSIRONRUBY](https://www.ruby-forum.com/u/John_LSSIRONRUBY)\
**Post date:** [July 3, 2008, 9:00pm UTC](https://www.ruby-forum.com/t/home-and-userprofile-aliasing-under-windows/141954/7 "2008-07-03T21:00:41Z")

</div>

same problem reported at #20475. and i agree that HOME Env should  
handle by that class

-Jirapong

On Jul 2, 2008, at 5:31 AM, “John L. (IRONRUBY)”
