dirs-rs

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

Library
Cargo
v7.0.0
738 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
46%
MIT

Svix

Automation · Developer Tools

3,463

Open source, self-hostable webhook infrastructure that handles delivery, retries, HMAC signing, and multi-tenant event management so you never have to build a webhooks system from scratch.

View details
91
Repo Health
77
Technical
67
Dependency
Built with
Rust 46%
C# 16%
Updated 1 weeks ago
Rust
66%
Apache 2.0

Temps

Analytics · Devops · Monitoring

865

A self-hosted Rust PaaS that replaces Vercel, Sentry, PostHog, Pingdom, Resend, and E2B with one binary — plus 440+ CLI operations agents like Claude Code can drive directly.

View details
81
Repo Health
86
Technical
66
Dependency
Built with
Rust 66%
TypeScript 33%
Updated 1 weeks ago
TypeScript
68%
AGPL 3.0

Tolaria

Note Taking

20,161

A free, open-source, local-first desktop app for managing markdown knowledge bases on macOS, Windows, and Linux — for second brains, company docs, or AI assistant memory and procedures.

View details
84
Repo Health
71
Technical
68
Dependency
Built with
TypeScript 68%
HTML 15%
Updated 6 days ago
Python
73%
Apache 2.0

Unsloth

AI Assistants · AI Development

78,493

Run and fine-tune LLMs, diffusion, audio and embedding models on your own hardware, from a native desktop app, a browser UI, or a Python library.

View details
89
Repo Health
83
Technical
70
Dependency
Built with
Python 73%
TypeScript 22%
Updated 6 days ago
Rust
50%
Apache 2.0

Vibe Kanban

AI Agents · AI Code Assistants · Project Management

28,441

A kanban board for planning work and dispatching Claude Code, Codex, Gemini CLI, and eight other coding agents into isolated git worktrees, then reviewing and merging their diffs from one UI.

View details
72
Repo Health
75
Technical
63
Dependency
Built with
Rust 50%
TypeScript 46%
Updated 1 months ago
TypeScript
95%
Apache 2.0

Void

AI Code Assistants · Automation · Code Editors

28,733

Open-source AI code editor with direct LLM integration and data privacy

View details
44
Repo Health
84
Technical
68
Dependency
Built with
TypeScript 95%
Updated 5 months 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