-
Notifications
You must be signed in to change notification settings - Fork 147
Description
Describe the bug
Under some Windows systems, an error in build.rs can cause cargo build to fail.
- Does this issue still occur in the master branch? (Required)
Expected behavior
When using cargo build, hyfetch should be built.
Environment & Logs
Environment: Azure's Windows CI VM.
A section of the build error:
[...more cargo logs omitted...]
│ Compiling terminal-colorsaurus v0.4.8
│ Compiling crossterm v0.27.0
│ Compiling tracing-subscriber v0.3.20
│ Compiling bpaf v0.9.20
│ Compiling same-file v1.0.6
│ Compiling enable-ansi-support v0.2.1
│ Compiling deranged v0.3.11
│ error: failed to run custom build command for `hyfetch v2.0.2 (%SRC_DIR%\crates\hyfetch)`
│ Caused by:
│ process didn't exit successfully: `%SRC_DIR%\target\debug\build\hyfetch-e025e940b46f6849\build-script-build` (exit code: 101)
│ --- stdout
│ cargo:rerun-if-changed=%SRC_DIR%\neofetch
│ cargo:rerun-if-changed=%SRC_DIR%\hyfetch
│ --- stderr
│ thread 'main' panicked at crates\hyfetch\build.rs:49:51:
│ Failed to copy directory to OUT_DIR: Error { kind: Io(Os { code: 123, kind: InvalidFilename, message: "The filename, directory name, or volume label syntax is incorrect." }), message: "Io error. Look inside err_kind for more details." }
│ note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
│ warning: build failed, waiting for other jobs to finish...
│ error: failed to compile `hyfetch v2.0.2 (%SRC_DIR%\crates\hyfetch)`, intermediate artifacts can be found at `%SRC_DIR%\target`.
│ To reuse those artifacts with a future compilation, set the environment variable `CARGO_TARGET_DIR` to that path.
Config file
N/A
Additional context
Related build.rs source code: here
Upon investigation, it is discovered that the error occurs in fs_extra::dir::copy, when attempting to copy hyfetch to $OUT_DIR. This function recursively copies files and subdirectories in a directory to a destination, similar to cp -r. When copying hyfetch/scripts/neowofetch, which is a symlink, fs_extra cannot handle it correctly, and omitted the error above. This only happens in Windows, because symlinks on POSIX systems are well-defined.
Further, fs_extra already has some unresolved issues regarding either Windows or symlinks: fs_extra#61 fs_extra#64 fs_extra#78.
Suggested remedies
- Drop the dependency on
fs_extra. It is outdated and unmaintained, with the latest commit in Feb 2023. The code quality is questionable (cc @SpriteOvO). The cratedircpyseems newer. - Only copy the necessary files in
build.rs. I believe the rest of the Rust code only depends on a small subset of the Python code, likehyfetch/data/font_logos.json. There doesn't seem to be a need to copy the entirehyfetch/*folder. - For packagers on Windows platforms with Windows-native build environments: As a workaround, just run
del hyfetch/scripts/neowofetchbefore runningcargo build. This file isn't needed anyways.