explaingit

ruby/tmpdir

Analysis updated 2026-08-08 · repo last pushed 2026-07-13

14RubyAudience · developerComplexity · 2/5ActiveLicenseSetup · easy

TLDR

A Ruby utility that creates secure temporary folders for your app to use as scratch space, then automatically deletes them when done. Part of the official Ruby ecosystem.

Mindmap

mindmap
  root((repo))
    What it does
      Creates temp directories
      Auto cleanup after use
      Secure 0700 permissions
    Customization
      Prefix and suffix names
      Choose folder location
    Tech stack
      Ruby
      Dir class extension
    Use cases
      Process uploaded files
      Download and extract data
      Scratch space for scripts
    Audience
      Ruby developers
      Web app builders
    Security
      Owner only access
      Shared server safe

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Create a temporary folder to stash uploaded files while processing them in a web app.

USE CASE 2

Use a scratch directory to download and extract data before moving it to a final location.

USE CASE 3

Generate short-lived working space in scripts that need a holding area for intermediate files.

What is it built with?

Ruby

How does it compare?

ruby/tmpdireclectic-coding/rails_health_checksfastlane/taskqueue
Stars141413
LanguageRubyRubyRuby
Last pushed2026-07-132019-07-29
MaintenanceActiveDormant
Setup difficultyeasyeasyeasy
Complexity2/52/52/5
Audiencedeveloperdeveloperdeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · easy Time to first run · 5min

Bundled with Ruby's standard library, no installation needed, just require 'tmpdir' in your script.

Distributed under Ruby's license, which allows free use including commercial purposes as long as you keep the copyright notice.

In plain English

The ruby/tmpdir project is a small utility for Ruby applications that need to create temporary folders on the fly. It gives developers a straightforward way to generate a short-lived directory, use it for whatever they need, and have it automatically cleaned up afterward. The main feature is a function called Dir.mktmpdir that creates a fresh temporary directory with restricted permissions, only the person who created it can read or write to it. Developers can optionally customize the folder name by adding a prefix or suffix (like prefixing it with "foo" so the folder looks like "foo...random"). They can also choose where on the computer the folder gets created, defaulting to the system's standard temporary location but allowing alternatives like /var/tmp. The directory is designed to be used within a block of code and then removed automatically once that block finishes running. This tool would be used by Ruby developers building applications that need scratch space, for example, a web app that processes uploaded files might stash them in a temporary folder while working on them, or a script that downloads and extracts data might need a holding area. It is essentially infrastructure plumbing that handles the messy details of creating and tearing down temporary storage safely. One notable design choice is the emphasis on security. The folder is created with 0700 permissions, meaning only the owner can access it, and the README explicitly warns against changing this. This prevents a common pitfall where temporary files accidentally become visible to other users on the same machine, a real concern on shared servers. The project is maintained under the official Ruby organization, making it part of the broader Ruby ecosystem rather than an independent library.

Copy-paste prompts

Prompt 1
I need to create a temporary directory in my Ruby app that automatically gets deleted when my code block finishes. Show me how to use Dir.mktmpdir with a custom prefix like 'uploads' and have it clean up automatically.
Prompt 2
How do I create a temporary folder in a specific location like /var/tmp instead of the default system temp directory, using Ruby's Dir.mktmpdir?
Prompt 3
I want to safely process uploaded files in a temp folder using Ruby. Write code that creates a temp directory with a 'foo' prefix, writes files into it, and removes the folder when done without leaving anything behind.
Prompt 4
Explain why Dir.mktmpdir uses 0700 permissions and why changing them is dangerous on shared servers. Then show me the correct way to use it in a block so cleanup always happens.

Frequently asked questions

What is tmpdir?

A Ruby utility that creates secure temporary folders for your app to use as scratch space, then automatically deletes them when done. Part of the official Ruby ecosystem.

What language is tmpdir written in?

Mainly Ruby. The stack also includes Ruby.

Is tmpdir actively maintained?

Active — commit in last 30 days (last push 2026-07-13).

What license does tmpdir use?

Distributed under Ruby's license, which allows free use including commercial purposes as long as you keep the copyright notice.

How hard is tmpdir to set up?

Setup difficulty is rated easy, with roughly 5min to a first successful run.

Who is tmpdir for?

Mainly developer.

Open on GitHub → Explain another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.