tmpdir() public

Returns the operating system’s temporary file path.

Show source
Register or log in to add new notes.
October 31, 2009
2 thanks

Don't forget to require 'tmpdir'

If you simply say Dir.tmpdir you might get a nice surprise:

irb> Dir.tmpdir
NoMethodError: undefined method `tmpdir' for Dir:Class

from (irb):1

Strangely, this method seems to be stored in a file that Ruby doesn’t require by default. Just require 'tmpdir' and all should be well.

irb> require 'tmpdir'
=> true
irb> Dir.tmpdir
=> "/var/folders/An/AnwlXPZFH2aRLCERERQDKE+++TI/-Tmp-"