# User home

**URL:** <https://www.ruby-forum.com/t/user-home/150888>\
**Category:** Ruby\
**Created:** [October 14, 2008, 6:20pm UTC](https://www.ruby-forum.com/t/user-home/150888 "2008-10-14T18:20:49Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kless](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/cc9497/32.png) [@Kless](https://www.ruby-forum.com/u/Kless)\
**Post date:** [October 14, 2008, 6:20pm UTC](https://www.ruby-forum.com/t/user-home/150888/1 "2008-10-14T18:20:49Z")

</div>

Is there any method to get the value of user home which in Linux would  
be stored in $HOME?

Valid for windows and mac osx too

---

<div class="post-metadata">

**Author:** ![Kless](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/cc9497/32.png) [@Kless](https://www.ruby-forum.com/u/Kless)\
**Post date:** [October 14, 2008, 6:32pm UTC](https://www.ruby-forum.com/t/user-home/150888/2 "2008-10-14T18:32:37Z")

</div>

On Tue, Oct 14, 2008 at 6:19 PM, Kless [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Is there any method to get the value of user home which in Linux would  
> be stored in $HOME?

ENV[‘HOME’]

> Valid for windows and mac osx too

Not sure…

Jesus.

---

<div class="post-metadata">

**Author:** ![Kless](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/cc9497/32.png) [@Kless](https://www.ruby-forum.com/u/Kless)\
**Post date:** [October 14, 2008, 7:05pm UTC](https://www.ruby-forum.com/t/user-home/150888/3 "2008-10-14T19:05:30Z")

</div>

On 14 oct, 17:31, Jesús Gabriel y Galán [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> On Tue, Oct 14, 2008 at 6:19 PM, Kless [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > Is there any method to get the value of user home which in Linux would  
> > be stored in $HOME?
> 
> ENV[‘HOME’]
> 
> > Valid for windows and mac osx too
> 
> Not sure…  
> After of questioning on IRC:

It’s valid too on OSX.

In Windows it’s not always set, usually only if your system is on a  
domain. But can be used ENV[‘USERPROFILE’] if ENV[‘HOME’] isn’t set  
and you’ll be okay most of the time.

---

<div class="post-metadata">

**Author:** ![Kless](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/cc9497/32.png) [@Kless](https://www.ruby-forum.com/u/Kless)\
**Post date:** [October 14, 2008, 9:21pm UTC](https://www.ruby-forum.com/t/user-home/150888/4 "2008-10-14T21:21:51Z")

</div>

On Tue, Oct 14, 2008 at 6:31 PM, JesÃºs Gabriel y GalÃ¡n  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> On Tue, Oct 14, 2008 at 6:19 PM, Kless [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > Is there any method to get the value of user home which in Linux would  
> > be stored in $HOME?
> 
> ENV[‘HOME’]
> 
> > Valid for windows and mac osx too

Works fine in OS X.

Rails has a Dir.user\_home which is more complicated. No idea if that  
works on Windows, but the source is here:  
[http://noobkit.com/show/ruby/rails/rails-stable/rails/dir/user\_home.html](http://noobkit.com/show/ruby/rails/rails-stable/rails/dir/user_home.html)
