dirs-rs

Platform-specific standard directory paths for config, cache, and data on Linux, macOS, and Windows.

Library
Cargo
v7.0.0
739 stars
Apache License 2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
33 /100 Needs Attention
Development Activity 0
Maintenance 0
Community 44
Maturity 60
Momentum 28

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
88 /100 Excellent
Architecture 88
Code Quality 82
Innovation 90
Learning Curve 92

dirs is a tiny, low-level Rust library that provides the platform-specific, user-accessible locations for storing and retrieving configuration, cache, and other application data. It resolves the correct paths by following each operating system’s native conventions: the XDG base and user directory specifications on Linux and Redox, the Known Folder API on Windows, and the Standard Directories guidelines on macOS.

With a minimal API of 18 standalone functions such as home_dir(), config_dir(), and cache_dir(), the crate returns an Option<PathBuf> for each well-known directory without ever creating folders or checking for their existence. It is intentionally focused on user-writable directories, making it a dependable foundation for any cross-platform tool that needs to know where files belong.

What You Get

  • A minimal API of 18 standalone functions covering home, config, cache, data, state, runtime, and executable directories.
  • User-directory helpers for common folders such as audio, desktop, documents, downloads, pictures, and videos.
  • Correct path resolution across Linux, Redox, macOS, iOS, Windows (Vista and later), and WebAssembly.
  • A dependency-light footprint that builds on the companion dirs-sys crate for the low-level system calls.

Common Use Cases

  • Locating a writable config directory so a CLI tool can persist user settings across sessions.
  • Choosing a cache directory to store downloaded or computed artifacts without polluting the home folder.
  • Resolving a data directory for application state that should survive restarts.
  • Building cross-platform desktop or command-line tools that must respect native OS folder conventions.

Under The Hood

Architecture

The crate is organized as a thin, platform-dispatching facade in src/lib.rs, which exposes 18 documented public functions and delegates each call to a platform module selected at compile time via cfg attributes: win.rs for Windows, mac.rs for macOS and iOS, wasm.rs for wasm32, and lin.rs as the fallback for Linux, Redox, and other Unix-like systems (aliased as sys). Each backend implements the same function set independently — for example lin.rs resolves config_dir() by reading $XDG_CONFIG_HOME and falling back to $HOME/.config, while mac.rs returns ~/Library/Application Support — so the public API stays identical while behavior follows native OS conventions. Low-level system access (reading the home directory via getpwuid_r, calling SHGetKnownFolderPath, parsing XDG user-dir files) is deferred to the companion dirs-sys crate.

Tech Stack

Written in pure Rust (roughly 23 KB of source across five files) with a single runtime dependency, dirs-sys 0.5.0, which in turn wraps windows-sys for the Known Folder API on Windows. The crate has no build script, uses the standard cargo toolchain, and targets a very old minimum Rust version (1.13 on most platforms), reflecting its stable, low-churn design. It is dual-licensed MIT OR Apache-2.0.

Code Quality

The code is exceptionally compact and readable: platform modules are written as one-line function bodies chaining env::var_os, and_then, and or_else over Option<PathBuf>, which keeps the fallback logic explicit and side-effect free. #![deny(missing_docs)] enforces that every public function carries documentation, and each is accompanied by a per-platform value table in its doc comment. Testing is light — a couple of #[cfg(test)] smoke tests exist in lib.rs and lin.rs (e.g. checking for a user-dirs.dirs file) rather than a comprehensive suite — which is a reasonable trade-off given the logic is a thin, declarative mapping to OS conventions.

API Design

The public API is about as ergonomic as it gets: flat, free-standing functions with self-describing names (home_dir, cache_dir, config_dir, runtime_dir) that each return Option<PathBuf>, requiring zero setup, no structs to construct, and no error handling beyond a None check. Documentation is a standout — every function includes a table mapping the returned value across Linux, macOS, and Windows with concrete examples — and the README clearly steers users toward the sister directories crate when they need project-scoped paths, setting expectations rather than over-promising.

Used by 33 apps in this directory

Rust
99%
MIT

abtop

Developer Tools · Monitoring

3,669

Like htop, but for your AI coding agents — monitor Claude Code, Codex CLI, and OpenCode sessions, tokens, context windows, rate limits, and orphan ports all from one terminal screen.

View details
74
Repo Health
79
Technical
78
Dependency
Built with
Rust 99%
Updated 2 weeks ago
Rust
54%
Other

Cameleer

AI Agents

23

A local-first desktop workspace for managing AI agents in an enterprise-style workflow — agent directory, Kanban task tracking, workspace chat, and a full runtime/audit log of agent actions and tool approvals.

View details
40
Repo Health
65
Technical
76
Dependency
Built with
Rust 54%
JavaScript 24%
TypeScript 15%
Updated 2 months ago
Rust
54%
Other

Cap

Team Chat · Video Conferencing

22,884

Open source Loom alternative with GPU-accelerated recording, instant share links, AI summaries, and full self-hosting via Docker Compose.

View details
89
Repo Health
81
Technical
64
Dependency
Built with
Rust 54%
TypeScript 42%
Updated 4 days ago
TypeScript
84%
Apache 2.0

Continue

AI Code Assistants · AI Development · Automation

36,049

Open-source coding agent for VS Code, JetBrains, and CLI with support for 30+ LLM providers.

View details
73
Repo Health
88
Technical
62
Dependency
Built with
TypeScript 84%
Updated 5 days ago
Go
32%
Apache 2.0

CubeSandbox

AI Agents · Developer Tools · Security

12,728

Instant, concurrent, hardware-isolated MicroVM sandboxes for AI agents — E2B-API compatible, sub-60ms cold starts, and a built-in zero-trust egress proxy, all self-hostable at scale.

View details
82
Repo Health
88
Technical
63
Dependency
Built with
Go 32%
Rust 26%
C 22%
Updated 1 weeks ago
Rust
80%
MIT

fabro

Developer Tools · Devops

1,658

Define AI agent workflows as code graphs, route tasks across any LLM, and intervene only where it matters.

View details
82
Repo Health
83
Technical
67
Dependency
Built with
Rust 80%
TypeScript 15%
Updated 5 days ago
Python
65%
MIT

Flowfile

Data Engineering

363

Visual ETL that compiles to Polars — build pipelines on a canvas, export as standalone Python, and run anywhere without platform lock-in.

View details
83
Repo Health
81
Technical
66
Dependency
Built with
Python 65%
Vue 17%
TypeScript 17%
Updated 5 days ago
Rust
99%
Other

Fluree DB

Databases

469

A temporal, verifiable graph database with git-like branching, integrated vector/text/geo search, and RDF/SPARQL/JSON-LD/openCypher support — benchmarked at 10.4x faster than the next database on the full Wikidata dump.

View details
87
Repo Health
74
Technical
65
Dependency
Built with
Rust 99%
Updated 5 days ago
Rust
88%
GPL 2.0

Fresh

Code Editors · Developer Tools

9,052

A zero-configuration terminal text editor with familiar keybindings, full mouse support, LSP-powered IDE features, and a built-in orchestrator for running multiple coding agents in parallel worktrees.

View details
86
Repo Health
88
Technical
71
Dependency
Built with
Rust 88%
Updated 5 days ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers