NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
crates.io · #98 most downloaded on crates.io
A library for managing temporary files and directories.
Last release 7 months ago
11 Mar 2026
Release timing varies
gaps range from 2 weeks to 3 months
Most releases are documented
notes for 49 of the last 60 stable releases
3 versions withdrawn
withdrawn after publishing
11 years old
66 releases · first in 2015
This release adds TempPath::try_from_path and deprecates TempPath::from_path.
This release adds TempPath::try_from_path and deprecates TempPath::from_path.
Prior to this release, TempPath::from_path made no attempts to convert relative paths into absolute paths. The following code would have deleted the wrong file:
let tmp_path = TempPath::from_path("foo")
std::env::set_current_dir("/some/other/path").unwrap();
drop(tmp_path);
Now:
TempPath::from_path will attempt to convert relative paths into absolute paths. However, this isn't always possible as we need to call std::env::current_dir, which can fail. If we fail to convert the relative path to an absolute path, we simply keep the relative path.TempPath::try_from_path behaves exactly like TempPath::from_path, except that it returns an error if we fail to convert a relative path into an absolute path (or if the passed path is empty).Neither function attempt to verify the existence of the file in question.
Thanks to @meng-xu-cs for reporting this issue.
Support NamedTempFile::persist on RedoxOS (#393) (thanks to @Andy-Python-Programmer).
One column per quarter.
NamedTempFile::persist on RedoxOS (#393) (thanks to @Andy-Python-Programmer).Allow getrandom 0.4.x while retaining support for getrandom 0.3.x.
getrandom 0.4.x while retaining support for getrandom 0.3.x.Actually support WASIp2 without the nightly feature. This library is now feature complete on WASIp2 without any additional feature flags.
chore: release v3.23.0
chore: release v3.23.0 (#381)
Updated windows-sys requirement to allow version 0.61.x
windows-sys requirement to allow version 0.61.xunstable-windows-keep-open-tempfile feature.Updated windows-sys requirement to allow version 0.60.x
windows-sys requirement to allow version 0.60.xRename Builder::keep(bool) (via deprecation) to Builder::disable_cleanup(bool) to make it clear that behaves differently from NamedTempFile::keep(). T…
This release mostly unifies the behavior/capabilities around "keeping" temporary files:
Builder::keep(bool) (via deprecation) to Builder::disable_cleanup(bool) to make it clear that behaves differently from NamedTempFile::keep(). The former disables automatic cleanup while the latter consumes the NamedTempFile object entirely and unsets the "temporary file" attribute (on Windows).TempDir::into_path (via deprecation) to TempDir::keep to mirror NamedTempFile::keep.TempDir::disable_cleanup, NamedTempFile::disable_cleanup, and TempPath::disable_cleanup making it possible to disable automatic cleanup in-place after creating a temporary file/directory (equivalent to calling Builder::disable_cleanup before creating the file/directory).Additionally, it adds a few spooled temporary file features: git lo
SpooledTempFile::into_file for turning a SpooledTempFile into a regular unnamed temporary file, writing it to the backing storage ("rolling" it) if it was still stored in-memory.spooled_tempfile_in and SpooledTempFile::new_in methods for creating spooled temporary files in a specific directory. This makes it possible to choose the backing device for your spooled temporary file which is rather important on Linux where the default temporary directory is likely backed by memory (defeating the entire point of having a spooled temporary file).Finally, this release improves documentation, especially the top-level documentation explaining which temporary file type to use.
BREAKING for those with deny(warnings):
Builder::keep deprecated in favor of Builder::disable_cleanup.TempDir::into_path is deprecated in favor of TempDir::keep.Don't unlink temporary files immediately on Windows (fixes #339). Unfortunately, this seemed to corrupt the file object (possibly a Windows kernel bug
Remove direct dependency on cfg-if. It's still in the tree, but we didn't really need to use it in this crate.
cfg-if. It's still in the tree, but we didn't really need to use it in this crate.unstable-windows-keep-open-tempfile) to test a potential fix to #339.Make NamedTempFile::persist_noclobber atomic on Apple operating systems. It's now atomic on MacOS, Windows, and Linux (depending on the OS version and
rustix to 1.0.0.NamedTempFile::persist_noclobber atomic on Apple operating systems. It's now atomic on MacOS, Windows, and Linux (depending on the OS version and filesystem used).Fix build with windows-sys 0.52. Unfortunately, we have no CI for older windows-sys versions at the moment...
windows-sys 0.52. Unfortunately, we have no CI for older windows-sys versions at the moment...Make sure to use absolute paths in when creating unnamed temporary files (avoids a small race in the "immediate unlink" logic) and in Builder::make_in
Builder::make_in (when creating temporary files of arbitrary types).getrandom, use platform (e.g., CPU) specific randomness sources where possible.Update getrandom to 0.3.0 (thanks to @paolobarbolini).
getrandom to 0.3.0 (thanks to @paolobarbolini).windows-sys versions 0.59.x in addition to 0.59.0 (thanks @ErichDonGubler).Re-seed the per-thread RNG from system randomness when we repeatedly fail to create temporary files (#314). This resolves a potential DoS vector (#178
Re-seed the per-thread RNG from system randomness when we repeatedly fail to create temporary files (#314). This resolves a potential DoS vector (#178) while avoiding getrandom in the common case where it's necessary. The feature is optional but enabled by default via the getrandom feature.
For libc-free builds, you'll either need to disable this feature or opt-in to a different getrandom backend.
Make the wasip2 target work (requires tempfile's "nightly" feature to be enabled). #305.
Add with_suffix constructors for easily creating new temporary files with a specific suffix (e.g., a specific file extension). Thanks to @Borgerr.
with_suffix constructors for easily creating new temporary files with a specific suffix (e.g., a specific file extension). Thanks to @Borgerr.Add a keep(keep: bool) function to builder that suppresses delete-on-drop behavior (thanks to @RalfJung).
keep(keep: bool) function to builder that suppresses delete-on-drop behavior (thanks to @RalfJung).windows-sys from 0.52 to 0.59.Add the ability to override the default temporary directory. This API shouldn't be used in general, but there are some cases where it's unavoidable.
Handle potential integer overflows in 32-bit systems when seeking/truncating "spooled" temporary files past 4GiB (2³²).
Thanks to @stoeckmann for finding and fixing both of these issues.
Drop redox_syscall dependency, we now use rustix for Redox.
redox_syscall dependency, we now use rustix for Redox.Builder::permissions for setting the permissions on temporary files and directories (thanks to @Byron).Updates minimum rustix version to 0.38.25
Update rustix to fix a potential panic on persist_noclobber on android.
persist_noclobber on android.Added with_prefix and with_prefix_in to TempDir and NamedTempFile to make it easier to create temporary files/directories with nice prefixes.
with_prefix and with_prefix_in to TempDir and NamedTempFile to make it easier to create temporary files/directories with nice prefixes.Tempfile builds on haiku again.
BREAKING: This release updates the MSRV to 1.63. This isn't an API-breaking change (so no major release) but it's still a breaking change for some use…
BREAKING: This release updates the MSRV to 1.63. This isn't an API-breaking change (so no major release) but it's still a breaking change for some users.
Update rustix min version to 0.37.11
NamedTempFile and SpooledTempFile methods to the underlying File object for
better performance (especially vectorized writes, etc.).AsFd and AsHandle.Update rustix from 0.36 to 0.37.1. This makes wasi work on rust stable
windows-sys, redox_syscallWrite for &NamedTempFile<F> where &F: Write. Unfortunately, this can cause compile issues in unrelated code (https://github.com/Stebalien/tempfile/issues/224).SECURITY: Prior tempfile releases depended on remove_dir_all version 0.5.0 which was vulnerable to a TOCTOU race. This same race is present in rust ve…
SECURITY: Prior tempfile releases depended on remove_dir_all version 0.5.0 which was vulnerable to a TOCTOU race. This same race is present in rust versions prior to 1.58.1.
Features:
NamedTempFile can now abstract over different kinds of files (e.g.,
unix domain sockets, pipes, etc.):
Builder::make and Builder::make_in for generalized temp file
creation.NamedTempFile::from_parts to complement NamedTempFile::into_parts.NamedTempFile to support wrapping non-File types.Bug Fixes/Improvements:
NamedTempFile::persist_noclobber is now always atomic on linux when renameat_with is
supported. Previously, it would first link the new path, then unlink the previous path.Trivia:
libc to rustix on wasi/unix. This now makes direct syscalls instead of calling
through libc.remove_dir_all dependency. The rust standard library has optimized their internal version
significantly.Breaking:
1.48.0.must_use.NamedTempFile may lead to type inference issues in some cases.Replace rand with fastrand for a significantly smaller dependency tree. Cryptographic randomness isn't necessary for temporary file names, and isn't a
Features:
SpooledTempFile.Bug Fixes:
O_EXCL flag.Other than that, this release mostly includes small cleanups and simplifications.
Features:
0.8.1.0Other than that, this release mostly includes small cleanups and simplifications.
Breaking: The minimum rust version is now 1.40.0.
Breaking: The minimum rust version is now 1.32.0.
Features:
0.7.Breaking: The minimum rust version is now 1.32.0.
No longer implement the soft-deprecated description.
Documentation:
Features:
append option to the builder.description.source instead of cause.Breaking: The minimum rust version is now 1.30.
Fix a bug where flushing a SpooledTempFile to disk could fail to write part of the file in some rare, yet-to-reproduced cases.
This is a bugfix release.
Fixes:
PathPersistError.SpooledTempFile to disk could fail to write part
of the file in some rare, yet-to-reproduced cases.Builder::prefix and Builder::suffix now accept a generic &AsRef . This could affect type inference.
Breaking:
Builder::prefix and Builder::suffix now accept a generic &AsRef<OsStr>.
This could affect type inference.Features:
&AsRef<OsStr> in the builder: &OsStr, &OsString, &Path, etc.Fixes:
Misc:
Don't hide temporary files on windows, fixing #66 and #69.
Added a spooled temporary file implementation. This temporary file variant starts out as an in-memory temporary file but "rolls-over" onto disk when i
Features:
Misc:
Bugs:
Now compiles on unsupported platforms.
- update rand to 0.5
Actually *delete* temporary files on non-Linux unix systems (thanks to @oliverhenshaw for the fix and a test case).
- Restore NamedTempFile::new_in
Adds temporary directory support (@KodrAus)
- Redox Support
Remove build script and bump minimum rustc version to 1.9.0
Don't build platform-specific dependencies on all platforms.
Fix crates.io tags. No interesting changes.
Export PersistError.
Export PersistError.
Add Read/Write/Seek impls on &NamedTempFile. This mirrors the implementations on &File. One can currently just deref to a &File but these implementati
Add Read/Write/Seek impls on &NamedTempFile. This mirrors the
implementations on &File. One can currently just deref to a &File but these
implementations are more discoverable.
Add LFS Support.
Add LFS Support.
Implement AsRef for NamedTempFile allowing named temporary files to be borrowed as Files.
AsRef<File> for NamedTempFile allowing named temporary files to
be borrowed as Files.NamedTempFile to an unnamed temporary File.- Arm bugfix
This release replaces TempFile with a tempfile() function that returns std::File objects. These are significantly more useful because most rust librar
This release replaces TempFile with a tempfile() function that returns
std::fs::File objects. These are significantly more useful because most rust
libraries expect normal File objects.
To continue supporting shared temporary files, this new version adds a
reopen() method to NamedTempFile.
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Your coding agent can read these notes before it upgrades. Set up the MCP server →