Returns the first element of `candidates` for which [dir.exists()] is `TRUE`. If none exist but one has a parent directory that exists, creates that candidate and returns it. Errors if none of the candidates or their parents exist.
Details
This is the stateless primitive used by [CandidatePath] for resolution. Scripts that just need "give me the first of these paths that exists" can call it directly.
See also
[CandidatePath] for the stateful, caching wrapper used by the R6 classes in this package; [invalidate_candidate_paths()] for the save-time cache clearer that makes objects portable across hosts.
Other multi_host_paths:
CandidatePath,
invalidate_candidate_paths()
Examples
d <- tempfile()
dir.create(d)
first_existing_path(c("/definitely/not/there", d))
#> [1] "/tmp/RtmpoyXnmG/file1dc8284a6139"
