From: chris@... Date: 2018-11-20T16:10:21+00:00 Subject: [ruby-core:89911] [Ruby trunk Bug#15324] Dir.home test doesn't match actual Ruby or system behaviour Issue #15324 has been reported by chrisseaton (Chris Seaton). ---------------------------------------- Bug #15324: Dir.home test doesn't match actual Ruby or system behaviour https://bugs.ruby-lang.org/issues/15324 * Author: chrisseaton (Chris Seaton) * Status: Open * Priority: Normal * Assignee: * Target version: * ruby -v: * Backport: 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN ---------------------------------------- This test currently asserts that `Dir.home(user)` should return ENV['HOME'] if user is the current user. We don't think this is correct - `Dir.home(user)` uses the expanded value of `~user`, which explictly uses the login database, and explicitly not any current value of `HOME`. See the documentation on tilde expansion here: http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_06_01 "[if there is an explict user name after the tilde then] the tilde-prefix shall be replaced by a pathname of the initial working directory associated with the login name obtained using the getpwnam() function as defined in the System Interfaces volume of POSIX.1-2017 [as opposed to reading HOME]" `getpwnam` is what `File.expand_path` does. To see the problem, run MRI's test with `HOME` set to something else (again, see the link above to see that setting `HOME` is explicitly allowed). ``` $ HOME=/nothing make test-all ... 1) Failure: TestDir#test_home [/Users/chrisseaton/Documents/mri-test-upstream/ruby/test/ruby/test_dir.rb:378]: <"/nothing"> expected but was <"/Users/chrisseaton">. ... ``` We've encountered this test failure for real, so it isn't hypothetical. The patch corrects the test to match actual Ruby behaviour. ---Files-------------------------------- dir.patch (538 Bytes) -- https://bugs.ruby-lang.org/ Unsubscribe: