From: knu@... Date: 2016-09-07T10:35:36+00:00 Subject: [ruby-core:77206] [Ruby trunk Feature#12695] File.expand_path should resolve ~/ using /etc/passwd when HOME is not set Issue #12695 has been updated by Akinori MUSHA. Bash seems to do that: % bash -c 'unset HOME; echo ~' /home/knu As far as I tested most other known shells like tcsh, zsh, ash, dash and pdksh do not, but we could follow the best. 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. I think following Bash should be the way to go. ---------------------------------------- Feature #12695: File.expand_path should resolve ~/ using /etc/passwd when HOME is not set https://bugs.ruby-lang.org/issues/12695#change-60422 * Author: M��rten Svantesson * Status: Open * Priority: Normal * Assignee: ---------------------------------------- I would expect a call like File.expand_path('~/.ssh/known_hosts') to work even though HOME is not set. A reason this is important to fix is that libraries (in my use case Net::SSH) do calls like File.expand_path('~/.ssh/known_hosts'), but this will often fail when the code is run in a unix service, since HOME often isn't set then. I considered reporting this as a bug, but the current behaviour is actually documented. -- https://bugs.ruby-lang.org/ Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe> <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>