Problem
When running cargo build, Cargo tries to output to target. If target is an ordinary file, or a symlink that points to one, this (naturally) fails with
$ cargo build
error: failed to create directory `/path/to/crate/target/debug`
Caused by:
Not a directory (os error 20)
However, if target is a broken symlink, Cargo prints a much less helpful error message:
$ ln -s /a/b/c target # assuming /a/b/c doesn't exist on your machine
$ cargo build
error: Not a directory (os error 20)
The error: failed to create directory part of the error message has been lost.
Steps
- Create a new crate with
cargo init
- Create a broken
target symlink with e.g., ln -s /a/b/c target (assuming you don't actually have /a/b/c on your computer)
- Run
cargo build
Possible Solution(s)
Cargo should catch the broken target symlink and print the same error message it would if target were an ordinary file.
Notes
No response
Version
cargo 1.74.0-nightly (2cc50bc0b 2023-08-22)
release: 1.74.0-nightly
commit-hash: 2cc50bc0b63ad20da193e002ba11d391af0104b7
commit-date: 2023-08-22
host: aarch64-apple-darwin
libgit2: 1.6.4 (sys:0.17.2 vendored)
libcurl: 8.1.2 (sys:0.4.65+curl-8.2.1 system ssl:(SecureTransport) LibreSSL/3.3.6)
ssl: OpenSSL 1.1.1u 30 May 2023
os: Mac OS 14.0.0 [64-bit]
Problem
When running
cargo build, Cargo tries to output totarget. Iftargetis an ordinary file, or a symlink that points to one, this (naturally) fails with$ cargo build error: failed to create directory `/path/to/crate/target/debug` Caused by: Not a directory (os error 20)However, if
targetis a broken symlink, Cargo prints a much less helpful error message:$ ln -s /a/b/c target # assuming /a/b/c doesn't exist on your machine $ cargo build error: Not a directory (os error 20)The
error: failed to create directorypart of the error message has been lost.Steps
cargo inittargetsymlink with e.g.,ln -s /a/b/c target(assuming you don't actually have/a/b/con your computer)cargo buildPossible Solution(s)
Cargo should catch the broken
targetsymlink and print the same error message it would iftargetwere an ordinary file.Notes
No response
Version