Skip to content

Commit d3c2133

Browse files
committed
Ignore all UTF-8 errors
1 parent a931647 commit d3c2133

File tree

1 file changed

+13
-1
lines changed
  • crates/uv/src/commands/project

1 file changed

+13
-1
lines changed

crates/uv/src/commands/project/run.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1781,7 +1781,19 @@ fn copy_entrypoint(
17811781

17821782
let mut contents = String::new();
17831783
file.seek(std::io::SeekFrom::Start(0))?;
1784-
file.read_to_string(&mut contents)?;
1784+
match file.read_to_string(&mut contents) {
1785+
Ok(_) => {}
1786+
Err(err) if err.kind() == std::io::ErrorKind::InvalidData => {
1787+
// If the file is not valid UTF-8, we skip it in case it was a binary file with `#!` at
1788+
// the start (which seems pretty niche, but being defensive here seems safe)
1789+
trace!(
1790+
"Skipping copy of entrypoint `{}`: is not valid UTF-8",
1791+
source.user_display()
1792+
);
1793+
return Ok(());
1794+
}
1795+
Err(err) => return Err(err.into()),
1796+
}
17851797

17861798
let Some(contents) = contents
17871799
// Check for a relative path or relocatable shebang

0 commit comments

Comments
 (0)