16 stable releases

2.11.0 Nov 20, 2023
2.9.0 Oct 31, 2022
2.7.0 Feb 19, 2022
2.6.0 May 6, 2021
0.1.2 Feb 10, 2020

#9 in Filesystem

Download history 150957/week @ 2024-01-02 165777/week @ 2024-01-09 194401/week @ 2024-01-16 183527/week @ 2024-01-23 180783/week @ 2024-01-30 184083/week @ 2024-02-06 174920/week @ 2024-02-13 185200/week @ 2024-02-20 204930/week @ 2024-02-27 205329/week @ 2024-03-05 227404/week @ 2024-03-12 224897/week @ 2024-03-19 166639/week @ 2024-03-26 210999/week @ 2024-04-02 199828/week @ 2024-04-09 160539/week @ 2024-04-16

773,274 downloads per month
Used in 891 crates (133 directly)


1.5K SLoC


Crates.io GitHub Actions

fs-err is a drop-in replacement for std::fs that provides more helpful messages on errors. Extra information includes which operations was attempted and any involved paths.

Error Messages

Using std::fs, if this code fails:

let file = File::open("does not exist.txt")?;

The error message that Rust gives you isn't very useful:

The system cannot find the file specified. (os error 2)

...but if we use fs-err instead, our error contains more actionable information:

failed to open file `does not exist.txt`
    caused by: The system cannot find the file specified. (os error 2)


fs-err's API is the same as std::fs, so migrating code to use it is easy.

// use std::fs;
use fs_err as fs;

let contents = fs::read_to_string("foo.txt")?;

println!("Read foo.txt: {}", contents);

fs-err uses std::io::Error for all errors. This helps fs-err compose well with traits from the standard library like std::io::Read and crates that use them like serde_json:

use fs_err::File;

let file = File::open("my-config.json")?;

// If an I/O error occurs inside serde_json, the error will include a file path
// as well as what operation was being performed.
let decoded: Vec<String> = serde_json::from_reader(file)?;

println!("Program config: {:?}", decoded);

Minimum Supported Rust Version

The oldest rust version this crate is tested on is 1.40.

This crate will generally be conservative with rust version updates. It uses the autocfg crate to allow wrapping new APIs without incrementing the MSRV.

If the tokio feature is enabled, this crate will inherit the MSRV of the selected tokio version.


Licensed under either of

at your option.


Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.


~19K SLoC