Skip to main content

shared_target_dir

Function shared_target_dir 

Source
pub async fn shared_target_dir() -> Result<PathBuf>
Expand description

Return the Cargo target directory every project’s CLI-managed builds share, creating it if needed.

Compiled units are fingerprint-keyed, so one ~/.water/build_cache/target serves every project on the machine: a second water run reuses the dependency graph the first one compiled instead of cold-building it per project. The directory sits beside the per-project managed_backends containers rather than inside one — generated sources are wiped when the CLI’s scaffold templates change, while compiled artifacts do not go stale for that reason.

The directory is a first-class cache entry: it carries the same metadata.toml the per-project containers do, so the garbage collector reports it in usage surveys and reclaims it under the same unused-days policy once nothing has built for that long. One target also means one Cargo build-directory lock: builds of different projects serialize, and a waiting build prints Blocking waiting for file lock on build directory — visible through the piped progress render — for the holder’s duration.

§Errors

Returns an error if the Water home cannot be determined, the global config cannot be loaded, or the cache directory cannot be created.