Solution to issue cannot be found in the documentation.
Issue
rust fails to compile the libc crate
Compiling libc v0.2.180
[libc 0.2.180] thread 'main' (1096078) panicked at $BUILD_PREFIX/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.180/build.rs:211:5:
[libc 0.2.180] failed to run rustc: $BUILD_PREFIX/bin/rustc: error while loading shared libraries: libz.so.1: cannot open shared object file: No such file or directory
workaround
export LD_LIBRARY_PATH="$BUILD_PREFIX/lib:$LD_LIBRARY_PATH"
# cargo auditable install ...
reproduce
cd $(mktemp -d)
git clone https://github.com/milahu/conda-recipes --branch debug-rqbit
cd conda-recipes
git checkout 2e86822ba1f2130ae22fdb9ab3b006618d4dedbb
rattler-build build -r recipes/rqbit/recipe.bad.yaml \
--variant-config recipes/rqbit/variant_config.yaml
recipes
build logs
docs
bug report by chatGPT
🐛 Rust toolchain fails in sanitized Cargo build environment due to missing libz.so.1
Summary
The conda-forge Rust toolchain (rustc) fails to run inside sanitized Cargo build-script environments because libz.so.1 is not found, even though:
rustc works when run directly
libz.so.1 is present in the conda prefix
rustc has valid RPATH ($ORIGIN/../lib)
ldd rustc resolves libz.so.1 correctly
The failure only occurs when Cargo runs build scripts with a restricted LD_LIBRARY_PATH.
Error
During compilation (e.g. libc v0.2.180 build script):
error: failed to run custom build command for `libc v0.2.180`
Caused by:
failed to run rustc: libz.so.1: cannot open shared object file: No such file or directory
Reproduction context
This happens in:
- conda-forge rust-feedstock toolchain
- rattler-build environments (and any Cargo build-script sandbox with sanitized env)
- Linux x86_64
Key observation
In failing cases, Cargo sets a restricted environment:
LD_LIBRARY_PATH=/etc/sane-libs:...
This removes the conda prefix library path, so:
$BUILD_PREFIX/lib is not visible
- RPATH alone is not sufficient for
libz.so.1 resolution in this context
Manually restoring it fixes the issue:
export LD_LIBRARY_PATH="$BUILD_PREFIX/lib:$LD_LIBRARY_PATH"
Evidence
rustc links against libz.so.1:
ldd $(which rustc) | grep libz
libz.so.1 => .../lib/libz.so.1
But fails in Cargo build scripts due to missing runtime search path.
Expected behavior
Rust toolchain binaries packaged by conda-forge should run in fully sanitized build environments without requiring LD_LIBRARY_PATH overrides, assuming:
- RPATH is correctly set
- all shared dependencies are properly discoverable at runtime
Question
Is this expected behavior for the current Rust feedstock packaging (i.e. requiring LD_LIBRARY_PATH in sanitized environments), or does this indicate an incomplete runtime dependency/RPATH setup (specifically around libz.so.1)?
related
similar issues
i tried to apply the workarounds from there, but nothing works
Installed packages
# packages in environment at /home/user/src/milahu/conda-recipes/.mamba/envs/conda-build:
#
# Name Version Build Channel
_openmp_mutex 4.5 20_gnu conda-forge
anyio 3.7.1 pyhd8ed1ab_0 conda-forge
archspec 0.2.5 pyhd8ed1ab_0 conda-forge
attrs 26.1.0 pyhcf101f3_0 conda-forge
backports.zstd 1.5.0 py312h90b7ffd_0 conda-forge
beautifulsoup4 4.14.3 pyha770c72_0 conda-forge
boa 0.17.0 pyhd8ed1ab_3 conda-forge
boltons 25.0.0 pyhd8ed1ab_0 conda-forge
brotli-python 1.2.0 py312hdb49522_1 conda-forge
bzip2 1.0.8 hda65f42_9 conda-forge
c-ares 1.34.6 hb03c661_0 conda-forge
ca-certificates 2026.5.14 h06a4308_0
certifi 2026.5.20 py312h06a4308_0
cffi 2.0.0 py312h460c074_1 conda-forge
chardet 7.4.3 pyhcf101f3_0 conda-forge
charset-normalizer 3.4.7 pyhd8ed1ab_0 conda-forge
click 8.4.0 pyhc90fa1f_0 conda-forge
conda 24.11.3 py312h06a4308_0
conda-build 24.5.1 py312h7900ff3_0 conda-forge
conda-index 0.7.0 pyhd8ed1ab_0 conda-forge
conda-libmamba-solver 24.9.0 pyhd8ed1ab_0 conda-forge
conda-package-handling 2.4.0 pyh7900ff3_2 conda-forge
conda-package-streaming 0.12.0 pyhd8ed1ab_0 conda-forge
distro 1.9.0 pyhd8ed1ab_1 conda-forge
exceptiongroup 1.3.1 pyhd8ed1ab_0 conda-forge
filelock 3.29.0 pyhd8ed1ab_0 conda-forge
fmt 11.1.4 h07f6e7f_1 conda-forge
frozendict 2.4.7 py312h4c3975b_0 conda-forge
h2 4.3.0 pyhcf101f3_0 conda-forge
hpack 4.1.0 pyhd8ed1ab_0 conda-forge
hyperframe 6.1.0 pyhd8ed1ab_0 conda-forge
icu 78.3 h33c6efd_0 conda-forge
idna 3.13 pyhcf101f3_0 conda-forge
jinja2 3.1.6 pyhcf101f3_1 conda-forge
joblib 1.5.3 pyhd8ed1ab_0 conda-forge
json5 0.14.0 pyhd8ed1ab_0 conda-forge
jsonpatch 1.33 pyhd8ed1ab_1 conda-forge
jsonpointer 3.1.1 pyhcf101f3_0 conda-forge
jsonschema 4.26.0 pyhcf101f3_0 conda-forge
jsonschema-specifications 2025.9.1 pyhcf101f3_0 conda-forge
keyutils 1.6.3 hb9d3cd8_0 conda-forge
krb5 1.22.2 ha1258a1_0 conda-forge
ld_impl_linux-64 2.45.1 default_hbd61a6d_102 conda-forge
libarchive 3.8.7 gpl_hc2c16d8_101 conda-forge
libcurl 8.20.0 hcf29cc6_0 conda-forge
libedit 3.1.20250104 pl5321h7949ede_0 conda-forge
libev 4.33 hd590300_2 conda-forge
libexpat 2.8.0 hecca717_0 conda-forge
libffi 3.5.2 h3435931_0 conda-forge
libgcc 15.2.0 he0feb66_19 conda-forge
libgcc-ng 15.2.0 h69a702a_19 conda-forge
libgomp 15.2.0 he0feb66_19 conda-forge
libiconv 1.18 h3b78370_2 conda-forge
liblief 0.14.1 h5888daf_2 conda-forge
liblzma 5.8.3 hb03c661_0 conda-forge
libmamba 1.5.12 h44b872a_2 conda-forge
libmambapy 1.5.12 py312h2549379_2 conda-forge
libnghttp2 1.68.1 h877daf1_0 conda-forge
libnsl 2.0.1 hb9d3cd8_1 conda-forge
libsolv 0.7.37 h9463b59_0 conda-forge
libsqlite 3.53.1 hf4e2dac_0 conda-forge
libssh2 1.11.1 hf672d98_0 conda-forge
libstdcxx 15.2.0 h934c35e_19 conda-forge
libstdcxx-ng 15.2.0 hdf11a46_19 conda-forge
libuuid 2.42.1 h5347b49_0 conda-forge
libxcrypt 4.4.36 hd590300_1 conda-forge
libxml2 2.15.3 h49c6c72_0 conda-forge
libxml2-16 2.15.3 hca6bf5a_0 conda-forge
libzlib 1.3.2 h25fd6f3_2 conda-forge
lz4-c 1.10.0 h5888daf_1 conda-forge
lzo 2.10 h280c20c_1002 conda-forge
markdown-it-py 4.2.0 pyhd8ed1ab_0 conda-forge
markupsafe 3.0.3 py312h8a5da7c_1 conda-forge
mdurl 0.1.2 pyhd8ed1ab_1 conda-forge
menuinst 2.4.2 py312h7900ff3_0 conda-forge
msgpack-python 1.1.2 py312hd9148b4_1 conda-forge
ncurses 6.6 hdb14827_0 conda-forge
openssl 3.6.2 h35e630c_0 conda-forge
packaging 26.2 pyhc364b38_0 conda-forge
patch 2.8 hb03c661_1002 conda-forge
patchelf 0.17.2 h58526e2_0 conda-forge
pip 26.1.1 pyh8b19718_0 conda-forge
pkginfo 1.12.1.2 pyhd8ed1ab_0 conda-forge
platformdirs 4.9.6 pyhcf101f3_0 conda-forge
pluggy 1.6.0 pyhf9edf01_1 conda-forge
prompt-toolkit 3.0.52 pyha770c72_0 conda-forge
prompt_toolkit 3.0.52 hd8ed1ab_0 conda-forge
psutil 7.2.2 py312h5253ce2_0 conda-forge
py-lief 0.14.1 py312h2ec8cdc_2 conda-forge
pybind11-abi 4 hd8ed1ab_3 conda-forge
pycosat 0.6.6 py312h4c3975b_3 conda-forge
pycparser 2.22 pyh29332c3_1 conda-forge
pygments 2.20.0 pyhd8ed1ab_0 conda-forge
pysocks 1.7.1 pyha55dd90_7 conda-forge
python 3.12.13 hd63d673_0_cpython conda-forge
python-libarchive-c 5.3 pyhe01879c_1 conda-forge
python_abi 3.12 8_cp312 conda-forge
pytz 2026.2 pyhcf101f3_0 conda-forge
pyyaml 6.0.3 py312h8a5da7c_1 conda-forge
rattler-build 0.55.1 h300ab14_0
readline 8.3 h853b02a_0 conda-forge
referencing 0.37.0 pyhcf101f3_0 conda-forge
reproc 14.2.7.post0 hb03c661_1 conda-forge
reproc-cpp 14.2.7.post0 hecca717_1 conda-forge
requests 2.34.2 pyhcf101f3_0 conda-forge
rich 15.0.0 pyhcf101f3_0 conda-forge
ripgrep 15.1.0 hdab8a38_0 conda-forge
rpds-py 0.30.0 py312h868fb18_0 conda-forge
ruamel.yaml 0.18.17 py312h5253ce2_2 conda-forge
ruamel.yaml.clib 0.2.15 py312h5253ce2_1 conda-forge
setuptools 82.0.1 pyh332efcf_0 conda-forge
sniffio 1.3.1 pyhd8ed1ab_2 conda-forge
soupsieve 2.8.3 pyhd8ed1ab_0 conda-forge
tk 8.6.13 noxft_ha0e22de_103 conda-forge
tqdm 4.67.3 pyh8f84b5b_0 conda-forge
truststore 0.10.4 pyhcf101f3_0 conda-forge
typing-extensions 4.15.0 h396c80c_0 conda-forge
typing_extensions 4.15.0 pyhcf101f3_0 conda-forge
tzdata 2025c hc9c84f9_1 conda-forge
urllib3 2.7.0 pyhd8ed1ab_0 conda-forge
watchgod 0.8.2 pyhd8ed1ab_1 conda-forge
wcwidth 0.7.0 pyhd8ed1ab_0 conda-forge
wheel 0.47.0 pyhd8ed1ab_0 conda-forge
yaml 0.2.5 h280c20c_3 conda-forge
yaml-cpp 0.8.0 h59595ed_0 conda-forge
zstandard 0.25.0 py312h5253ce2_1 conda-forge
zstd 1.5.7 hb78ec9c_6 conda-forge
Environment info
active environment : base
active env location : /home/user/src/milahu/conda-recipes/.mamba/envs/conda-build
shell level : 1
user config file : /home/user/.condarc
populated config files : /home/user/.condarc
conda version : 24.11.3
conda-build version : 24.5.1
python version : 3.12.13.final.0
solver : libmamba (default)
virtual packages : __archspec=1=zen3
__conda=24.11.3=0
__cuda=13.2=0
__glibc=2.42=0
__linux=6.18.25=0
__unix=0=0
base environment : /home/user/src/milahu/conda-recipes/.mamba/envs/conda-build (writable)
conda av data dir : /home/user/src/milahu/conda-recipes/.mamba/envs/conda-build/etc/conda
conda av metadata url : None
channel URLs : https://repo.anaconda.com/pkgs/main/linux-64
https://repo.anaconda.com/pkgs/main/noarch
https://repo.anaconda.com/pkgs/r/linux-64
https://repo.anaconda.com/pkgs/r/noarch
package cache : /home/user/src/milahu/conda-recipes/.mamba/envs/conda-build/pkgs
/home/user/.conda/pkgs
envs directories : /home/user/src/milahu/conda-recipes/.mamba/envs/conda-build/envs
/home/user/.conda/envs
platform : linux-64
user-agent : conda/24.11.3 requests/2.34.2 CPython/3.12.13 Linux/6.18.25 nixos/26.05 glibc/2.42 solver/libmamba conda-libmamba-solver/24.9.0 libmambapy/1.5.12
UID:GID : 1000:100
netrc file : None
offline mode : False
Solution to issue cannot be found in the documentation.
Issue
rustfails to compile thelibccrateworkaround
reproduce
recipes
build logs
docs
bug report by chatGPT
related
similar issues
i tried to apply the workarounds from there, but nothing works
Installed packages
Environment info