Open
Description
Problem
cargo run
, when called after moving a simple repository to a non-UTF-8 path, fails with an internal error.
Steps
/tmp $ mkdir test
/tmp $ cd test
/tmp/test $ cargo new hello
Created binary (application) `hello` package
/tmp/test $ cd hello/
/tmp/test/hello $ cargo run
Compiling hello v0.1.0 (/tmp/test/hello)
Finished dev [unoptimized + debuginfo] target(s) in 0.39s
Running `target/debug/hello`
Hello, world!
/tmp/test/hello $ mv /tmp/test /tmp/$'\345'
/tmp/test/hello $ cd .
/tmp//hello $ cargo run
Finished dev [unoptimized + debuginfo] target(s) in 0.00s
error: path `"/tmp/\xE5/hello/src/main.rs"` not utf-8
note: this is an unexpected cargo internal error
note: we would appreciate a bug report: https://github.com/rust-lang/cargo/issues/
note: cargo 1.67.0-nightly (9286a1beb 2022-11-04)
Possible Solution(s)
Either non-UTF-8 paths should be permitted or a proper error message should be written.
Notes
If you run cargo run
for the first time on a non-UTF-8 path the results aren't great either:
/tmp//hello $ cargo run
Compiling hello v0.1.0 (file:///tmp/%E5/hello)
error: argument 19 is not valid Unicode: "/tmp/\xE5/hello/target/debug/deps"
error: could not compile `hello`
Version
cargo 1.67.0-nightly (9286a1beb 2022-11-04)
release: 1.67.0-nightly
commit-hash: 9286a1beba5b28b115bad67de2ae91fb1c61eb0b
commit-date: 2022-11-04
host: x86_64-unknown-linux-gnu
libgit2: 1.5.0 (sys:0.15.0 vendored)
libcurl: 7.86.0-DEV (sys:0.4.59+curl-7.86.0 vendored ssl:OpenSSL/1.1.1q)
os: Debian n/a (bookworm) [64-bit]