Unable to solve Rust libc dependency

I’m trying to update ddnet package via pull request #59, but it is failing with:

error: no matching package named `libc` found
location searched: directory source `/usr/share/cargo/registry` (which is replacing registry `crates-io`)
required by package `ddnet-base v0.0.1 (/builddir/build/BUILD/ddnet-19.9-build/ddnet-19.9/src/base)`
help: packages with similar names: cc
note: offline mode (via `--offline`) can sometimes cause surprising resolution failures
help: if this error is too confusing you may wish to retry without `--offline`

I see Cargo.lock includes libc 0.2.183:

[[package]]
name = “libc”
version = “0.2.183”
source = “registry+https://github.com/rust-lang/crates.io-index”
checksum = “b5b646652bf6661599e1da8901b3b9522896f01e736bad5f723fe7a3a27f899d”

I tried specifying BuildRequires rust-libc, BuildRequires rust-libc-devel, but it didn’t work to find libc dependency

I also tried using %cargo_generate_buildrequires macro in the %generate_buildrequires scriptlet as per Rust Packaging Guidelines and it stops showing libc as not found, but it still fails with:

error: cannot create the lock file /builddir/build/BUILD/ddnet-19.9-build/ddnet-19.9/Cargo.lock because --locked was passed to prevent this
help: to generate the lock file without accessing the network, remove the --locked flag and use --offline instead.

How do I solve this issue?

I see this is packaged:

$ dnf info  rust-libc-devel
Updating and loading repositories:
Repositories loaded.
Available packages
Name           : rust-libc-devel
Epoch          : 0
Version        : 0.2.186
...

I cannot recall how cargo.lock works.

Try changing the version to 0.2.186 and see if that works.

--- a/ddnet.spec
+++ b/ddnet.spec
@@ -77,2 +77,3 @@
 BuildRequires:  (crate(cxx/default) >= 1.0.0 with crate(cxx/default) < 2.0.0~)
+BuildRequires:  crate(libc)
 BuildRequires:  gmock-devel
@@ -122,2 +123,4 @@
 sed '/Cargo.lock/d' -i CMakeLists.txt
+sed '/RUST_CARGO/s/--locked/--offline/' -i CMakeLists.txt
+sed '/foreach.*VULKAN_SHADER_/s/FILE_LIST/OUTPUT_PATHS/' -i CMakeLists.txt
 touch CMakeLists.txt

It still fails for me, now with the following error message:

build DDNET_TEST_NO_LINK=1 /usr/bin/cargo build --offline --manifest-path /builddir/build/BUILD/ddnet-19.9-build/ddnet-19.9/Cargo.toml --profile relwithdebinfo
error: failed to select a version for the requirement `cxx = "=1.0.194"`
candidate versions found which didn't match: 1.0.197
location searched: directory source `/usr/share/cargo/registry` (which is replacing registry `crates-io`)
required by package `ddnet-base v0.0.1 (/builddir/build/BUILD/ddnet-19.9-build/ddnet-19.9/src/base)`
note: perhaps a crate was updated and forgotten to be re-vendored?
note: offline mode (via `--offline`) can sometimes cause surprising resolution failures
help: if this error is too confusing you may wish to retry without `--offline`

See build.log from Making sure you're not a bot!

Thanks for debugging this. I opened an issue in the upstream: Fedora Rawhide requires Rust cxx 1.0.197 · Issue #12385 · ddnet/ddnet · GitHub

--- a/ddnet.spec
+++ b/ddnet.spec
@@ -75,6 +75,5 @@ BuildRequires:  spirv-tools
 #BuildRequires:  pkgconfig(libswresample)
 #BuildRequires:  pkgconfig(x264)
-BuildRequires:  (crate(cxx/default) >= 1.0.0 with crate(cxx/default) < 2.0.0~)
-BuildRequires:  crate(libc)
+BuildRequires:  cxxbridge
 BuildRequires:  gmock-devel
 
@@ -119,4 +118,8 @@ Standalone server for %{name}.
 find -type f -exec sed -i 's|engine/external/md5/md5.h|md5/md5.h|g' {} +
 find -type f -exec sed -i 's|engine/external/json-parser/json.h|json-parser/json.h|g' {} +
+find -type f -name Cargo.toml -exec sed -i '/^cxx\s=\s/s|"=|"|' {} +
+CXXBRIDGE_VERSION=$(cxxbridge --version | cut -d' ' -f2)
+sed -i "s|version=\".*\"|version=\"${CXXBRIDGE_VERSION}\"|" scripts/generate_rust_bridge.py
+python3 scripts/generate_rust_bridge.py
 
 %cargo_prep
@@ -129,4 +132,6 @@ touch CMakeLists.txt
 rm -rf src/engine/external
 
+%generate_buildrequires
+%cargo_generate_buildrequires
 
 %build

Thanks for your valuable help!