Forum: Ruby User home

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
125aa997aecefa6ebd4431f9b89e0bed?d=identicon&s=25 Kless (Guest)
on 2008-10-14 18:20
(Received via mailing list)
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
E088bb5c80fd3c4fd02c2020cdacbaf0?d=identicon&s=25 Jesús Gabriel y Galán (Guest)
on 2008-10-14 18:32
(Received via mailing list)
On Tue, Oct 14, 2008 at 6:19 PM, Kless <jonas.esp@googlemail.com> 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.
125aa997aecefa6ebd4431f9b89e0bed?d=identicon&s=25 Kless (Guest)
on 2008-10-14 19:05
(Received via mailing list)
On 14 oct, 17:31, Jesús Gabriel y Galán <jgabrielyga...@gmail.com>
wrote:
> On Tue, Oct 14, 2008 at 6:19 PM, Kless <jonas....@googlemail.com> 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.
4a551074ddba4460f95d011c47190d0e?d=identicon&s=25 Henrik --- (malesca)
on 2008-10-14 21:21
(Received via mailing list)
On Tue, Oct 14, 2008 at 6:31 PM, Jesús Gabriel y Galán
<jgabrielygalan@gmail.com> wrote:
> On Tue, Oct 14, 2008 at 6:19 PM, Kless <jonas.esp@googlemail.com> 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/ra...
This topic is locked and can not be replied to.