Feature #7361

Adding Pathname#touch

Added by Alexander E. Fischer about 3 years ago. Updated 10 months ago.

Assignee:Akira Tanaka


Pathname has an #mkdir method to create a directory at the path, but does not have a #touch method to create an empty file at that path.

There were numerous cases where I had to fallback to using

new_file = Pathname.new('location/for/new/file')

instead of simply being able to use:


I would like to add this method. If you like it, let me know. I will provide a patch then.

Related issues

Related to Ruby trunk - Feature #7378: Adding Pathname#write Closed 06/02/2012


#1 Updated by Yusuke Endoh about 3 years ago

  • Status changed from Open to Assigned
  • Assignee set to Akira Tanaka
  • Target version set to next minor

#2 Updated by Ben Rexin 10 months ago

Any way i can help?

#3 Updated by Daniel Berger 10 months ago

I'm a little surprise there isn't an option for this in FileUtils. Something like FileUtils.touch('/location/for/new', :force => true). I'd be in favor of adding that, or an option to FileUtils.mkpath.

Also available in: Atom PDF