You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Please consider adding Pathname.home for symmetry with Dir.home but returning a Pathname instead of a String, and to avoid having to use Pathname.new(Dir.home).
I don't understand why you don't use Pathname.new(Dir.home). What's the problem that?
It's surprising because Pathname already supports pwd, and is, as the OP stated, more verbose. Also, I don't want to interact with Dir and File at all, because using them doesn't feel elegant to me. I have had a Pathname#home monkey-patch in my own code for that reason.
All functionality from File, FileTest, and some from Dir and FileUtils is included, in an unsurprising way. It is essentially a facade for all of these, and more.
I'm +1 for this as well.
(unsurprisingly I already added .home to my path-like gem too)
I'm not sure about Pathname.~ because that looks weird syntactically, and ~ is a prefix operator yet ~Pathname doesn't make much sense. So I think just adding Pathname.home is best.
I think you (or someone else) will need to create a ticket at https://bugs.ruby-lang.org/ to get it merged though, given that Pathname will be in core in Ruby 4.0. Is that right @hsbt?
Activity
hsbt commentedon Apr 16, 2024
I don't understand why you don't use
Pathname.new(Dir.home). What's the problem that?josb commentedon Apr 16, 2024
It works, but is more verbose and I expected
Pathname.hometo work in the first place (POLA).knu commentedon Apr 16, 2024
It'd be cool to have it aliased to
~.notEthan commentedon Dec 10, 2024
I have wanted this as well. PR'd in
#43#70, maybe maintainers will accept it.der-scheme commentedon Nov 13, 2025
It's surprising because Pathname already supports pwd, and is, as the OP stated, more verbose. Also, I don't want to interact with Dir and File at all, because using them doesn't feel elegant to me. I have had a
Pathname#homemonkey-patch in my own code for that reason.eregon commentedon Nov 15, 2025
I'm +1 for this as well.
(unsurprisingly I already added
.hometo my path-like gem too)I'm not sure about
Pathname.~because that looks weird syntactically, and~is a prefix operator yet~Pathnamedoesn't make much sense. So I think just addingPathname.homeis best.eregon commentedon Nov 15, 2025
Copying from #70 (comment) for visibility: