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
{{ message }}
Repository navigation
Pathname + FileUtils making sweet music together #64
I love Pathname. I love FileUtils. Let's bring these two classes EVEN CLOSER TOGETHER by adding some tragically missing helpers. I would be happy to create a PR for this amazing functionality. Something like this, perhaps?
Don't get too excited, but I have a branch. It looks like this, which matches the style of the Dir facade methods. One oddity - the existing rmtree method returnsself for some reason. I have no idea why and I didn't do that here.
classPathname# * FileUtils *# See <tt>FileUtils.mkdir_p</tt>.defmkdir_p(...)require'fileutils';FileUtils.mkdir_p(self, ...)end# See <tt>FileUtils.ln</tt>.defln(...)require'fileutils';FileUtils.ln(self, ...)end# See <tt>FileUtils.ln_s</tt>.defln_s(...)require'fileutils';FileUtils.ln_s(self, ...)end# See <tt>FileUtils.ln_sf</tt>.defln_sf(...)require'fileutils';FileUtils.ln_sf(self, ...)end# See <tt>FileUtils.cp</tt>.defcp(...)require'fileutils';FileUtils.cp(self, ...)end# See <tt>FileUtils.cp_r</tt>.defcp_r(...)require'fileutils';FileUtils.cp_r(self, ...)end# See <tt>FileUtils.mv</tt>.defmv(...)require'fileutils';FileUtils.mv(self, ...)end# See <tt>FileUtils.rm</tt>.defrm(...)require'fileutils';FileUtils.rm(self, ...)end# See <tt>FileUtils.rm_r</tt>.defrm_r(...)require'fileutils';FileUtils.rm_r(self, ...)end# See <tt>FileUtils.rm_rf</tt>.defrm_rf(...)require'fileutils';FileUtils.rm_rf(self, ...)endaliasrmtreerm_rfend
I have a concern this proposal make harder to Pathname into the core classes might become more difficult as a result of this proposal, since pathname.rb would become more dependent on FileUtils functionality.
Hi @hsbt. I read through some of the earlier discussion and I understand what you are saying. Your concern is valid. I think we should still be able to add features like this to Pathname, though, and the community would benefit.
What's the best way to achieve that?
@eregon maybe you can help me to understand the options, I would am happy to do whatever work is required to make this happen.
I have a concern this proposal make harder to Pathname into the core classes might become more difficult as a result of this proposal, since pathname.rb would become more dependent on FileUtils functionality.
Yeah I have related concerns as well, and I'm thinking to file a https://bugs.ruby-lang.org/ ticket to discuss it.
The fundamental issue seems that core Pathname doesn't have all methods that the Pathname gem has (specially it doesn't have any of the methods that uses require), that seems a big source of confusion, and I'm not sure why it's done that way.
For instance why is it a concern that core Pathname require 'fileutils' in some methods if it just works anyway?
Activity
gurgeous commentedon Oct 9, 2025
Don't get too excited, but I have a branch. It looks like this, which matches the style of the Dir facade methods. One oddity - the existing
rmtreemethod returnsselffor some reason. I have no idea why and I didn't do that here.I even have tests, which look like this:
The style seem a bit dated. I wanted to use
doandtapand add a helper to DRY it up, but I showed restraint and matched the existing stuff.eregon commentedon Oct 9, 2025
I think this would make sense (though adding this would need others to approve it besides me).
Could you make a PR?
gurgeous commentedon Oct 9, 2025
Great, thanks. See #65. Happy to do more work here, whatever is required.
hsbt commentedon Oct 10, 2025
I have no strong opinion for oppose or agree.
I have a concern this proposal make harder to
Pathnameinto the core classes might become more difficult as a result of this proposal, sincepathname.rbwould become more dependent onFileUtilsfunctionality.gurgeous commentedon Oct 10, 2025
Hi @hsbt. I read through some of the earlier discussion and I understand what you are saying. Your concern is valid. I think we should still be able to add features like this to
Pathname, though, and the community would benefit.What's the best way to achieve that?
@eregon maybe you can help me to understand the options, I would am happy to do whatever work is required to make this happen.
eregon commentedon Oct 10, 2025
Yeah I have related concerns as well, and I'm thinking to file a https://bugs.ruby-lang.org/ ticket to discuss it.
The fundamental issue seems that core Pathname doesn't have all methods that the Pathname gem has (specially it doesn't have any of the methods that uses
require), that seems a big source of confusion, and I'm not sure why it's done that way.For instance why is it a concern that core Pathname
require 'fileutils'in some methods if it just works anyway?hsbt commentedon Oct 10, 2025
That's consensus with akr and me. We should avoid loading other libraries by simply calling methods from the embedded core classes.
gurgeous commentedon Oct 12, 2025
What's the way forward? Here are some ideas:
require, life goes onI'm happy to do whatever, I just want the functionality.
gurgeous commentedon Oct 23, 2025
I could put together a PR for any of these... Just bringing this up again since I'm still excited to do it :)
eregon commentedon Oct 26, 2025
Ah I forgot to backlink here but I filed https://bugs.ruby-lang.org/issues/21640
gurgeous commentedon Oct 26, 2025
Thanks, I will chime in there
eregon commentedon Nov 27, 2025
I think the best path forward here would be to file a new ticket at https://bugs.ruby-lang.org/projects/ruby-master/issues about this feature.
It's still not clear to me what will happen to this gem in https://bugs.ruby-lang.org/issues/21640
gurgeous commentedon Dec 7, 2025
ok, see https://bugs.ruby-lang.org/issues/21766
gurgeous commentedon Jan 15, 2026
FYI I am giving up on this. Here's what I settled on for my personal core_ext:
eregon commentedon Jan 16, 2026
Sorry about that, see #65 (comment)
If you want a pathname-like gem that offers this kind of convenience and is well tested, feel free to use the
pathgem: https://github.com/eregon/path/blob/master/lib/path/fileutils.rbIf any of the methods you want are missing a PR is welcome.
gurgeous commentedon Jan 17, 2026
No worries all. I will check out Path! Always excited to jump into new projects and move things forward :)