-
Notifications
You must be signed in to change notification settings - Fork 31
Open
Description
When using Nix to build this crate the build fails due to L56-82 of libcamera/build.rs
copying files out of the versioned_files
directory
for file in ["controls.rs", "properties.rs"] {
std::fs::copy(selected_version.join(file), out_path.join(file)).unwrap();
print!(
"cargo:rerun-if-changed={}",
selected_version.join(file).to_string_lossy()
);
}
In Nix builds when these files are copied they are marked as read only so builds fail with a PermissionDenied
error from the build.rs
. I put in a quick print statement to check the permissions of the files that are copied and funnily enough the code panics on the first copy, log like so
> "/build/source/target/release/build/libcamera-2d766fdaf7b36810/out/controls.rs": Metadata { file_type: FileType { is_file: true, is_dir: false, is_symlink: false, .. }, permissions: Permissions(FilePermissions { mode: 0o100444 (-r--r--r--) }), len: 142653, modified: SystemTime { tv_sec: 1749933068, tv_nsec: 674107121 }, accessed: SystemTime { tv_sec: 1749933068, tv_nsec: 672993305 }, created: SystemTime { tv_sec: 1749933068, tv_nsec: 672993305 }, .. }
>
> thread 'main' panicked at /nix/store/0bbadl7ca4vzm995w6yq6ssfp7kdllcs-vendor-cargo-deps/e5a4648f290c8092361a1a1cff5593d691c5d86ef2e9c2fcb4ef194fd2f1fa72/libcamera-0.4.0/build.rs:81:73:
> called `Result::unwrap()` on an `Err` value: Os { code: 13, kind: PermissionDenied, message: "Permission denied" }
> note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Commit that generated this log
To get around this I added a call to std::fs::remove_file
to remove the pre-copied file and the build now seems to pass. I'm not sure if this is the best way to do it for this project, maybe just skipping the copy if the file exists is better, not sure.
Commit used as circumvention
Metadata
Metadata
Assignees
Labels
No labels