SiftMac
Is it safe to delete? · Project folders · Updated 21 November 2026

Is it safe to delete a Rust project’s target folder?

By Mohit Nippanikar, who makes SiftMac

The short answer
On this page
  1. What’s in target
  2. Where it is
  3. How big it gets
  4. How to delete it
  5. What happens afterwards
  6. Keep it while you’re working
  7. Questions

1. What’s in target

Cargo writes all build output for a workspace into one target folder at the workspace root: compiled dependencies, your binaries and libraries, test executables, documentation, and incremental data that makes small rebuilds quick.

Each profile and each target gets its own build of every dependency, which is why target grows well past the size of the code.

2. Where it is

~/Projects/my-crate/target

Next to the workspace’s top Cargo.toml, unless CARGO_TARGET_DIR or the build.target-dir setting points somewhere else. To list the ones under your code folder with their sizes:

find ~/Projects -name Cargo.toml -execdir sh -c 'test -d target && du -sh "$PWD/target"' \; 2>/dev/null

3. How big it gets

It depends on the dependency tree, which profiles and targets you’ve built, and how long since anything cleared it. Cargo’s automatic cleanup covers its download cache in ~/.cargo, not target, so a project you keep building only gains. To measure, and to preview a clean:

du -sh target target/*
cargo clean --dry-run

cargo clean --dry-run prints a summary of what would be deleted without deleting it; add --verbose to list the files.

4. How to delete it

From the project folder, with no build running:

cargo clean

With no options, that deletes the whole target directory. Narrower options:

Deleting the folder in Finder does the same. First copy out any program you use straight from target/release, or install it with cargo install --path . so it lives in ~/.cargo/bin instead.

5. What happens afterwards

6. Keep it while you’re working

In a project you build every day, target is what keeps each build quick, so clearing it buys space at the price of one full build. Finished projects are the ones worth clearing. The crates themselves are stored once for all projects in Cargo’s registry.

Questions

Does cargo clean delete Cargo.lock or my code?

No. It only removes the target directory, or the parts of it you choose. Cargo.lock, Cargo.toml and src stay.

Why is my target folder so much bigger than my code?

It holds compiled copies of every dependency for each profile and target you’ve built, plus incremental data kept to speed up rebuilds.

Can several projects share one target folder?

Yes, by pointing CARGO_TARGET_DIR or build.target-dir at one folder. Then there’s a single place to clear, but cleaning it costs every project that uses it a full build.

How SiftMac handles it. Its Developer files category lists target folders that sit next to a Cargo.toml, in projects whose own files haven’t changed for 1, 3 or 6 months, as Rust build output. None is ticked until you tick it, and cleared ones are deleted rather than shelved, since the next build makes them again.

Download SiftMac · scanning is free, and so is your first 2 GB of cleaning · See how it works