Skip to content

How to get a temp directory in any OS with Ruby

Robert Greiner
Robert Greiner

I needed this over the weekend and the existing online help is less than helpful. As it turns out, just like with everything I try to do in Ruby, the solution is simple.

require 'tmpdir'
temp = Dir.tmpdir() 
puts temp #C:/Users/Robert/AppData/Local/Temp

This is all built into Ruby, you don't need to install any gems or anything.

Please consider subscribing, it's free.
Technology

Robert Greiner Twitter

Professional optimist. I write a weekly newsletter for humans at the intersection of business, technology, leadership, and career growth.


Related Posts

Members Public

AI Rule #1 - Customer First

In 1985, Warren Buffett wisely said, "The first rule of investment is don't lose. And the second rule of investment is don't forget the first rule, and that's all the rules there are." Similarly, the first rule of AI investment is to

AI Rule #1 - Customer First
Members Public

Navigating the Upside Down as a Technology Leader

Ideas for leading technology organizations with confidence and creativity.

Navigating the Upside Down as a Technology Leader
Members Public

Artist for a Day

The future of creative output is multiplied by AI.

Artist for a Day