-
Notifications
You must be signed in to change notification settings - Fork 111
Closed as not planned
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
Attempting to build a package that depends on libz-sys
1.1.7 with crane results in the following error:
thread 'main' panicked at /nix/store/46npxq26b5hy0q80hclj8a9cx3qzfp1v-vendor-cargo-deps/c19b7c6f923b580ac259164a89f2577984ad5ab09ee9d583b888f934adbbe8d0/libz-sys-1.1.17/build.rs:150:61:
called `Result::unwrap()` on an `Err` value: Os { code: 13, kind: PermissionDenied, message: "Permission denied" }
The most recent version of libz-sys
introduced some lines to the build script that do fs::copy($path_in_src, $path_in_out_dir)
. Looking at the build log, it appears that the build script is being run twice: first as part of cargo check
and then as part of cargo build
. This looks very similar to the situation described here, where the first fs::copy
is preserving the -r
permissions on the file in the src directory, preventing the second fs::copy
from overwriting the output file.
Reproduction
Cargo.toml
:
[package]
name = "libz-sys-crane-bug"
version = "0.1.0"
edition = "2021"
[dependencies]
libz-sys = "1.1.17"
flake.nix
:
{
inputs = {
flake-utils.url = "github:numtide/flake-utils";
crane.url = "github:ipetkov/crane";
};
outputs = { self, crane, flake-utils }: flake-utils.lib.eachDefaultSystem (system: {
packages.default = crane.lib.${system}.buildDepsOnly {
src = ./.;
};
});
}
nix build .
Full log with CARGO_TERM_VERBOSE=true:
cargoArtifacts not set, will not reuse any cargo artifacts
@nix { "action": "setPhase", "phase": "unpackPhase" }
Running phase: unpackPhase
unpacking source archive /nix/store/rnh7pi267f4x3x26g3s9w2ya61nzaaqr-source
source root is source
@nix { "action": "setPhase", "phase": "patchPhase" }
Running phase: patchPhase
Executing configureCargoCommonVars
@nix { "action": "setPhase", "phase": "updateAutotoolsGnuConfigScriptsPhase" }
Running phase: updateAutotoolsGnuConfigScriptsPhase
@nix { "action": "setPhase", "phase": "configurePhase" }
Running phase: configurePhase
will append /build/source/.cargo-home/config.toml with contents of /nix/store/46npxq26b5hy0q80hclj8a9cx3qzfp1v-vendor-cargo-deps/config.toml
default configurePhase, nothing to do
@nix { "action": "setPhase", "phase": "buildPhase" }
Running phase: buildPhase
++ command cargo --version
cargo 1.77.1
++ command cargo check --release --locked --all-targets
Compiling vcpkg v0.2.15
Compiling pkg-config v0.3.30
Compiling cc v1.0.97
Compiling libc v0.2.153
Compiling libz-sys-crane-bug v0.1.0 (/build/source)
Running `rustc --crate-name vcpkg /nix/store/46npxq26b5hy0q80hclj8a9cx3qzfp1v-vendor-cargo-deps/c19b7c6f923b580ac259164a89f2577984ad5ab09ee9d583b888f934adbbe8d0/vcpkg-0.2.15/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C debug-assertions=off -C metadata=0bfebee6b84b6ce2 -C extra-filename=-0bfebee6b84b6ce2 --out-dir /build/source/target/release/deps -C strip=debuginfo -L dependency=/build/source/target/release/deps --cap-lints allow`
Running `rustc --crate-name pkg_config /nix/store/46npxq26b5hy0q80hclj8a9cx3qzfp1v-vendor-cargo-deps/c19b7c6f923b580ac259164a89f2577984ad5ab09ee9d583b888f934adbbe8d0/pkg-config-0.3.30/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C debug-assertions=off -C metadata=4cb3974717a39e20 -C extra-filename=-4cb3974717a39e20 --out-dir /build/source/target/release/deps -C strip=debuginfo -L dependency=/build/source/target/release/deps --cap-lints allow`
Running `rustc --crate-name cc --edition=2018 /nix/store/46npxq26b5hy0q80hclj8a9cx3qzfp1v-vendor-cargo-deps/c19b7c6f923b580ac259164a89f2577984ad5ab09ee9d583b888f934adbbe8d0/cc-1.0.97/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C debug-assertions=off -C metadata=a2f01b939bb3aeda -C extra-filename=-a2f01b939bb3aeda --out-dir /build/source/target/release/deps -C strip=debuginfo -L dependency=/build/source/target/release/deps --cap-lints allow`
Running `rustc --crate-name build_script_build /nix/store/46npxq26b5hy0q80hclj8a9cx3qzfp1v-vendor-cargo-deps/c19b7c6f923b580ac259164a89f2577984ad5ab09ee9d583b888f934adbbe8d0/libc-0.2.153/build.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C debug-assertions=off --cfg 'feature="default"' --cfg 'feature="std"' -C metadata=b6acb41a731ed5bb -C extra-filename=-b6acb41a731ed5bb --out-dir /build/source/target/release/build/libc-b6acb41a731ed5bb -C strip=debuginfo -L dependency=/build/source/target/release/deps --cap-lints allow`
Running `rustc --crate-name build_script_xf39gqci9kcnzvymgn233kj7r357kkzz_dummy --edition=2021 /nix/store/xf39gqci9kcnzvymgn233kj7r357kkzz-dummy.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C debug-assertions=off -C metadata=faa16ac49b4fccdc -C extra-filename=-faa16ac49b4fccdc --out-dir /build/source/target/release/build/libz-sys-crane-bug-faa16ac49b4fccdc -C strip=debuginfo -L dependency=/build/source/target/release/deps`
Running `/build/source/target/release/build/libc-b6acb41a731ed5bb/build-script-build`
Running `rustc --crate-name libc /nix/store/46npxq26b5hy0q80hclj8a9cx3qzfp1v-vendor-cargo-deps/c19b7c6f923b580ac259164a89f2577984ad5ab09ee9d583b888f934adbbe8d0/libc-0.2.153/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type lib --emit=dep-info,metadata -C opt-level=3 -C embed-bitcode=no --cfg 'feature="default"' --cfg 'feature="std"' -C metadata=4b610319f6281d7e -C extra-filename=-4b610319f6281d7e --out-dir /build/source/target/release/deps -C strip=debuginfo -L dependency=/build/source/target/release/deps --cap-lints allow --cfg freebsd11 --cfg libc_priv_mod_use --cfg libc_union --cfg libc_const_size_of --cfg libc_align --cfg libc_int128 --cfg libc_core_cvoid --cfg libc_packedN --cfg libc_cfg_target_vendor --cfg libc_non_exhaustive --cfg libc_long_array --cfg libc_ptr_addr_of --cfg libc_underscore_const_names --cfg libc_const_extern_fn`
Compiling libz-sys v1.1.17
Running `rustc --crate-name build_script_build --edition=2018 /nix/store/46npxq26b5hy0q80hclj8a9cx3qzfp1v-vendor-cargo-deps/c19b7c6f923b580ac259164a89f2577984ad5ab09ee9d583b888f934adbbe8d0/libz-sys-1.1.17/build.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C debug-assertions=off --cfg 'feature="default"' --cfg 'feature="libc"' --cfg 'feature="stock-zlib"' -C metadata=b98da9ebef3d3957 -C extra-filename=-b98da9ebef3d3957 --out-dir /build/source/target/release/build/libz-sys-b98da9ebef3d3957 -C strip=debuginfo -L dependency=/build/source/target/release/deps --extern cc=/build/source/target/release/deps/libcc-a2f01b939bb3aeda.rlib --extern pkg_config=/build/source/target/release/deps/libpkg_config-4cb3974717a39e20.rlib --extern vcpkg=/build/source/target/release/deps/libvcpkg-0bfebee6b84b6ce2.rlib --cap-lints allow`
Running `/build/source/target/release/build/libz-sys-b98da9ebef3d3957/build-script-build`
Running `rustc --crate-name libz_sys --edition=2018 /nix/store/46npxq26b5hy0q80hclj8a9cx3qzfp1v-vendor-cargo-deps/c19b7c6f923b580ac259164a89f2577984ad5ab09ee9d583b888f934adbbe8d0/libz-sys-1.1.17/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type lib --emit=dep-info,metadata -C opt-level=3 -C embed-bitcode=no --cfg 'feature="default"' --cfg 'feature="libc"' --cfg 'feature="stock-zlib"' -C metadata=789a182718e7ac7b -C extra-filename=-789a182718e7ac7b --out-dir /build/source/target/release/deps -C strip=debuginfo -L dependency=/build/source/target/release/deps --extern libc=/build/source/target/release/deps/liblibc-4b610319f6281d7e.rmeta --cap-lints allow -L native=/build/source/target/release/build/libz-sys-f0f9f0dd863b51a6/out/lib -L native=/build/source/target/release/build/libz-sys-f0f9f0dd863b51a6/out/lib -l static=z`
Running `/build/source/target/release/build/libz-sys-crane-bug-faa16ac49b4fccdc/build-script-xf39gqci9kcnzvymgn233kj7r357kkzz-dummy`
Running `rustc --crate-name libz_sys_crane_bug --edition=2021 src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type lib --emit=dep-info,metadata -C opt-level=3 -C embed-bitcode=no -C metadata=187f1512519eaf89 -C extra-filename=-187f1512519eaf89 --out-dir /build/source/target/release/deps -C strip=debuginfo -L dependency=/build/source/target/release/deps --extern libz_sys=/build/source/target/release/deps/liblibz_sys-789a182718e7ac7b.rmeta -L native=/build/source/target/release/build/libz-sys-f0f9f0dd863b51a6/out/lib -L native=/build/source/target/release/build/libz-sys-f0f9f0dd863b51a6/out/lib`
Running `rustc --crate-name libz_sys_crane_bug --edition=2021 src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --emit=dep-info,metadata -C opt-level=3 -C embed-bitcode=no --test -C metadata=d7f2e94c62dcdc36 -C extra-filename=-d7f2e94c62dcdc36 --out-dir /build/source/target/release/deps -C strip=debuginfo -L dependency=/build/source/target/release/deps --extern libz_sys=/build/source/target/release/deps/liblibz_sys-789a182718e7ac7b.rmeta -L native=/build/source/target/release/build/libz-sys-f0f9f0dd863b51a6/out/lib -L native=/build/source/target/release/build/libz-sys-f0f9f0dd863b51a6/out/lib`
Running `rustc --crate-name crane_dummy_libz_sys_crane_bug --edition=2021 src/bin/crane-dummy-libz-sys-crane-bug/main.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --emit=dep-info,metadata -C opt-level=3 -C embed-bitcode=no --test -C metadata=7f7431a958494109 -C extra-filename=-7f7431a958494109 --out-dir /build/source/target/release/deps -C strip=debuginfo -L dependency=/build/source/target/release/deps --extern libz_sys=/build/source/target/release/deps/liblibz_sys-789a182718e7ac7b.rmeta --extern libz_sys_crane_bug=/build/source/target/release/deps/liblibz_sys_crane_bug-187f1512519eaf89.rmeta -L native=/build/source/target/release/build/libz-sys-f0f9f0dd863b51a6/out/lib -L native=/build/source/target/release/build/libz-sys-f0f9f0dd863b51a6/out/lib`
Running `rustc --crate-name crane_dummy_libz_sys_crane_bug --edition=2021 src/bin/crane-dummy-libz-sys-crane-bug/main.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type bin --emit=dep-info,metadata -C opt-level=3 -C embed-bitcode=no -C metadata=22954ab386a79cfe -C extra-filename=-22954ab386a79cfe --out-dir /build/source/target/release/deps -C strip=debuginfo -L dependency=/build/source/target/release/deps --extern libz_sys=/build/source/target/release/deps/liblibz_sys-789a182718e7ac7b.rmeta --extern libz_sys_crane_bug=/build/source/target/release/deps/liblibz_sys_crane_bug-187f1512519eaf89.rmeta -L native=/build/source/target/release/build/libz-sys-f0f9f0dd863b51a6/out/lib -L native=/build/source/target/release/build/libz-sys-f0f9f0dd863b51a6/out/lib`
Finished release [optimized] target(s) in 5.89s
++ command cargo build --release --locked
Fresh cc v1.0.97
Fresh pkg-config v0.3.30
Fresh vcpkg v0.2.15
Dirty libz-sys v1.1.17: the file `/nix/store/46npxq26b5hy0q80hclj8a9cx3qzfp1v-vendor-cargo-deps/c19b7c6f923b580ac259164a89f2577984ad5ab09ee9d583b888f934adbbe8d0/libz-sys-1.1.17/zng/cmake.rs` is missing
Compiling libz-sys v1.1.17
Compiling libc v0.2.153
Running `rustc --crate-name libc /nix/store/46npxq26b5hy0q80hclj8a9cx3qzfp1v-vendor-cargo-deps/c19b7c6f923b580ac259164a89f2577984ad5ab09ee9d583b888f934adbbe8d0/libc-0.2.153/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type lib --emit=dep-info,metadata,link -C opt-level=3 -C embed-bitcode=no --cfg 'feature="default"' --cfg 'feature="std"' -C metadata=227eedb24747651c -C extra-filename=-227eedb24747651c --out-dir /build/source/target/release/deps -C strip=debuginfo -L dependency=/build/source/target/release/deps --cap-lints allow --cfg freebsd11 --cfg libc_priv_mod_use --cfg libc_union --cfg libc_const_size_of --cfg libc_align --cfg libc_int128 --cfg libc_core_cvoid --cfg libc_packedN --cfg libc_cfg_target_vendor --cfg libc_non_exhaustive --cfg libc_long_array --cfg libc_ptr_addr_of --cfg libc_underscore_const_names --cfg libc_const_extern_fn`
Running `/build/source/target/release/build/libz-sys-b98da9ebef3d3957/build-script-build`
error: failed to run custom build command for `libz-sys v1.1.17`
Caused by:
process didn't exit successfully: `/build/source/target/release/build/libz-sys-b98da9ebef3d3957/build-script-build` (exit status: 101)
--- stdout
cargo:rerun-if-env-changed=LIBZ_SYS_STATIC
cargo:rerun-if-changed=build.rs
cargo:rerun-if-changed=zng/cmake.rs
cargo:rerun-if-changed=zng/cc.rs
cargo:rerun-if-env-changed=ZLIB_NO_PKG_CONFIG
cargo:rerun-if-env-changed=PKG_CONFIG_x86_64-unknown-linux-gnu
cargo:rerun-if-env-changed=PKG_CONFIG_x86_64_unknown_linux_gnu
cargo:rerun-if-env-changed=HOST_PKG_CONFIG
cargo:rerun-if-env-changed=PKG_CONFIG
cargo:rerun-if-env-changed=ZLIB_STATIC
cargo:rerun-if-env-changed=ZLIB_DYNAMIC
cargo:rerun-if-env-changed=PKG_CONFIG_ALL_STATIC
cargo:rerun-if-env-changed=PKG_CONFIG_ALL_DYNAMIC
cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64-unknown-linux-gnu
cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64_unknown_linux_gnu
cargo:rerun-if-env-changed=HOST_PKG_CONFIG_PATH
cargo:rerun-if-env-changed=PKG_CONFIG_PATH
cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64-unknown-linux-gnu
cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64_unknown_linux_gnu
cargo:rerun-if-env-changed=HOST_PKG_CONFIG_LIBDIR
cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64-unknown-linux-gnu
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64_unknown_linux_gnu
cargo:rerun-if-env-changed=HOST_PKG_CONFIG_SYSROOT_DIR
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR
cargo:rerun-if-env-changed=ZLIB_STATIC
cargo:rerun-if-env-changed=ZLIB_DYNAMIC
cargo:rerun-if-env-changed=PKG_CONFIG_ALL_STATIC
cargo:rerun-if-env-changed=PKG_CONFIG_ALL_DYNAMIC
cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64-unknown-linux-gnu
cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64_unknown_linux_gnu
cargo:rerun-if-env-changed=HOST_PKG_CONFIG_PATH
cargo:rerun-if-env-changed=PKG_CONFIG_PATH
cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64-unknown-linux-gnu
cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64_unknown_linux_gnu
cargo:rerun-if-env-changed=HOST_PKG_CONFIG_LIBDIR
cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64-unknown-linux-gnu
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64_unknown_linux_gnu
cargo:rerun-if-env-changed=HOST_PKG_CONFIG_SYSROOT_DIR
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR
cargo-warning=Could not run `PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1 pkg-config --libs --cflags zlib`
The pkg-config command could not be found.
Most likely, you need to install a pkg-config package for your OS.
Try `apt install pkg-config`, or `yum install pkg-config`,
or `pkg install pkg-config`, or `apk add pkgconfig` depending on your distribution.
If you've already installed it, ensure the pkg-config command is one of the
directories in the PATH environment variable.
If you did not expect this build to link to a pre-installed system library,
then check documentation of the libz-sys crate for an option to
build the library from source, or disable features or dependencies
that require pkg-config.
OPT_LEVEL = Some("3")
TARGET = Some("x86_64-unknown-linux-gnu")
HOST = Some("x86_64-unknown-linux-gnu")
cargo:rerun-if-env-changed=CC_x86_64-unknown-linux-gnu
CC_x86_64-unknown-linux-gnu = None
cargo:rerun-if-env-changed=CC_x86_64_unknown_linux_gnu
CC_x86_64_unknown_linux_gnu = None
cargo:rerun-if-env-changed=HOST_CC
HOST_CC = None
cargo:rerun-if-env-changed=CC
CC = Some("gcc")
cargo:rerun-if-env-changed=CC_ENABLE_DEBUG_OUTPUT
cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
CRATE_CC_NO_DEFAULTS = None
DEBUG = Some("false")
CARGO_CFG_TARGET_FEATURE = Some("fxsr,sse,sse2")
cargo:rerun-if-env-changed=CFLAGS_x86_64-unknown-linux-gnu
CFLAGS_x86_64-unknown-linux-gnu = None
cargo:rerun-if-env-changed=CFLAGS_x86_64_unknown_linux_gnu
CFLAGS_x86_64_unknown_linux_gnu = None
cargo:rerun-if-env-changed=HOST_CFLAGS
HOST_CFLAGS = None
cargo:rerun-if-env-changed=CFLAGS
CFLAGS = None
running "gcc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-m64" "-Wall" "-Wextra" "src/smoke.c" "-g0" "-o" "/dev/null" "-lz"
cargo:rerun-if-env-changed=AR_x86_64-unknown-linux-gnu
AR_x86_64-unknown-linux-gnu = None
cargo:rerun-if-env-changed=AR_x86_64_unknown_linux_gnu
AR_x86_64_unknown_linux_gnu = None
cargo:rerun-if-env-changed=HOST_AR
HOST_AR = None
cargo:rerun-if-env-changed=AR
AR = Some("ar")
cargo:rerun-if-env-changed=ARFLAGS_x86_64-unknown-linux-gnu
ARFLAGS_x86_64-unknown-linux-gnu = None
cargo:rerun-if-env-changed=ARFLAGS_x86_64_unknown_linux_gnu
ARFLAGS_x86_64_unknown_linux_gnu = None
cargo:rerun-if-env-changed=HOST_ARFLAGS
HOST_ARFLAGS = None
cargo:rerun-if-env-changed=ARFLAGS
ARFLAGS = None
cargo:rustc-link-lib=static=z
cargo:rustc-link-search=native=/build/source/target/release/build/libz-sys-f0f9f0dd863b51a6/out/lib
--- stderr
src/smoke.c:1:10: fatal error: zlib.h: No such file or directory
1 | #include <zlib.h>
| ^~~~~~~~
compilation terminated.
thread 'main' panicked at /nix/store/46npxq26b5hy0q80hclj8a9cx3qzfp1v-vendor-cargo-deps/c19b7c6f923b580ac259164a89f2577984ad5ab09ee9d583b888f934adbbe8d0/libz-sys-1.1.17/build.rs:150:61:
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
x86pup
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working