https://redmine.ruby-lang.org/https://redmine.ruby-lang.org/favicon.ico?17113305112016-08-24T02:34:22ZRuby Issue Tracking SystemRuby master - Feature #12695: File.expand_path should resolve ~/ using /etc/passwd when HOME is not sethttps://redmine.ruby-lang.org/issues/12695?journal_id=602562016-08-24T02:34:22Zshyouhei (Shyouhei Urabe)shyouhei@ruby-lang.org
<ul></ul><p>+1 it makes sense to me.</p> Ruby master - Feature #12695: File.expand_path should resolve ~/ using /etc/passwd when HOME is not sethttps://redmine.ruby-lang.org/issues/12695?journal_id=602712016-08-24T16:13:56Znobu (Nobuyoshi Nakada)nobu@ruby-lang.org
<ul></ul><p>Why doesn't your service launcher set <code>HOME</code>?</p> Ruby master - Feature #12695: File.expand_path should resolve ~/ using /etc/passwd when HOME is not sethttps://redmine.ruby-lang.org/issues/12695?journal_id=604152016-09-07T08:43:44Zakr (Akira Tanaka)akr@fsij.org
<ul></ul><p>I think its good idea.</p>
<p>Although POSIX doesn't specify it for shell, we can define it in Ruby.</p> Ruby master - Feature #12695: File.expand_path should resolve ~/ using /etc/passwd when HOME is not sethttps://redmine.ruby-lang.org/issues/12695?journal_id=604202016-09-07T09:04:22Zknu (Akinori MUSHA)knu@ruby-lang.org
<ul></ul><p>Makes sense. Ruby knows how to resolve ~user, so you may well expect it to resolve ~ as well given that the login name is identified.</p> Ruby master - Feature #12695: File.expand_path should resolve ~/ using /etc/passwd when HOME is not sethttps://redmine.ruby-lang.org/issues/12695?journal_id=604222016-09-07T10:35:36Zknu (Akinori MUSHA)knu@ruby-lang.org
<ul></ul><p>Bash seems to do that:</p>
<p>% bash -c 'unset HOME; echo ~'<br>
/home/knu</p>
<p>As far as I tested most other known shells like tcsh, zsh, ash, dash and pdksh do not, but we could follow the best.</p>
<p>Through my testing, I found fish unique in that it automatically defines a missing HOME on startup and then expands ~ simply to $HOME. While it would keep things simple and efficient, Ruby is not a shell after all, and altering the environment would clearly be something unasked for.</p>
<p>I think following Bash should be the way to go.</p> Ruby master - Feature #12695: File.expand_path should resolve ~/ using /etc/passwd when HOME is not sethttps://redmine.ruby-lang.org/issues/12695?journal_id=604442016-09-08T07:43:32Znobu (Nobuyoshi Nakada)nobu@ruby-lang.org
<ul></ul><p><a href="https://github.com/ruby/ruby/compare/trunk...nobu:feature/12695-homedir" class="external">https://github.com/ruby/ruby/compare/trunk...nobu:feature/12695-homedir</a></p> Ruby master - Feature #12695: File.expand_path should resolve ~/ using /etc/passwd when HOME is not sethttps://redmine.ruby-lang.org/issues/12695?journal_id=616652016-11-25T06:41:10Zmatz (Yukihiro Matsumoto)matz@ruby.or.jp
<ul></ul><p>Accepted.</p>
<p>Matz.</p> Ruby master - Feature #12695: File.expand_path should resolve ~/ using /etc/passwd when HOME is not sethttps://redmine.ruby-lang.org/issues/12695?journal_id=617492016-11-26T11:37:06Znobu (Nobuyoshi Nakada)nobu@ruby-lang.org
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Closed</i></li></ul><p>Applied in changeset r56902.</p>
<hr>
<p>file.c: home directory from system</p>
<ul>
<li>file.c (rb_default_home_dir): resolve home directory from the<br>
system database when HOME is not set. [Feature <a class="issue tracker-2 status-5 priority-4 priority-default closed" title="Feature: File.expand_path should resolve ~/ using /etc/passwd when HOME is not set (Closed)" href="https://redmine.ruby-lang.org/issues/12695">#12695</a>]</li>
</ul> Ruby master - Feature #12695: File.expand_path should resolve ~/ using /etc/passwd when HOME is not sethttps://redmine.ruby-lang.org/issues/12695?journal_id=640422017-04-03T02:31:40Zpabs (Paul Wise)
<ul></ul><p>Does anyone know if this also fixes the Dir.home value? Currently (in 2.3) that doesn't work when HOME is unset either.</p>
<pre><code>pabs@chianamo ~ $ unset HOME
pabs@chianamo /home/pabs $ ruby -e 'print Dir.home'
-e:1:in `home': couldn't find HOME environment -- expanding `~' (ArgumentError)
from -e:1:in `<main>'
</code></pre> Ruby master - Feature #12695: File.expand_path should resolve ~/ using /etc/passwd when HOME is not sethttps://redmine.ruby-lang.org/issues/12695?journal_id=640592017-04-04T11:37:35Znobu (Nobuyoshi Nakada)nobu@ruby-lang.org
<ul></ul><p>This is a new feature of 2.4.</p> Ruby master - Feature #12695: File.expand_path should resolve ~/ using /etc/passwd when HOME is not sethttps://redmine.ruby-lang.org/issues/12695?journal_id=851582020-04-17T07:34:31Zshyouhei (Shyouhei Urabe)shyouhei@ruby-lang.org
<ul><li><strong>Related to</strong> <i><a class="issue tracker-1 status-5 priority-4 priority-default closed" href="/issues/16787">Bug #16787</a>: [patch] allow Dir.home to work for non-login procs when $HOME not set</i> added</li></ul>