ikatson/rqbit

NixOS Build Difficulties

Closed this issue · 7 comments

This might be entirely on my side but would appreciate any tips on how to resolve this build error.

   Compiling librqbit v4.0.0 (/build/source/crates/librqbit)
error[E0277]: the trait bound `Vec<u8>: From<&[u8; 31]>` is not satisfied
   --> crates/librqbit/src/session.rs:452:86
    |
452 |                     .unwrap_or_else(|| ByteString(b"http://retracker.local/anno>
    |                                                                                >
    |
    = note: required for `&[u8; 31]` to implement `Into<Vec<u8>>`
help: consider dereferencing here
    |
452 |                     .unwrap_or_else(|| ByteString((*b"http://retracker.local/an>
    |                                                   ++                           >

error: future cannot be sent between threads safely
   --> crates/librqbit/src/session.rs:382:17
    |
382 | /                 async move {
383 | |                     // Populate initial from the state filename
384 | |                     if let Err(e) = session.populate_from_stored().await {
385 | |                         error!("could not populate session from stored file: >
...   |
401 | |                     Ok(())
402 | |                 },
    | |_________________^ future created by async block is not `Send`
    |
note: opaque type is declared here
   --> crates/librqbit/src/session.rs:428:56
    |
428 |     async fn populate_from_stored(self: &Arc<Self>) -> anyhow::Result<()> {
    |                                                        ^^^^^^^^^^^^^^^^^^
note: this item depends on auto traits of the hidden type, but may also be registerin>
   --> crates/librqbit/src/session.rs:334:18
    |
334 |     pub async fn new_with_opts(
    |                  ^^^^^^^^^^^^^
note: future is not `Send` as it awaits another future which is not `Send`
   --> crates/librqbit/src/session.rs:384:37
    |
384 |                     if let Err(e) = session.populate_from_stored().await {
    |                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ await occurs>
note: required by a bound in `spawn_utils::spawn`
   --> crates/librqbit/src/spawn_utils.rs:6:66
    |
3   | pub fn spawn(
    |        ----- required by a bound in this function
...
6   |     fut: impl std::future::Future<Output = anyhow::Result<()>> + Send + 'static,
    |                                                                  ^^^^ required >

For more information about this error, try `rustc --explain E0277`.
error: could not compile `librqbit` (lib) due to 2 previous errors
warning: build failed, waiting for other jobs to finish...
(END)

Hey, maybe it's trying to use some older rust version? Do you know the rust version being used?

I just pushed this one can you see if it works now? 9481ffc

Well it's different :)

rustc 1.73.0 (cc66ad468 2023-10-03) (built from a source tarball)

   Compiling librqbit v4.0.0 (/build/source/crates/librqbit)
error[E0446]: crate-private type `BlockingSpawner` in public interface
   --> crates/librqbit/src/peer_connection.rs:105:5
    |
105 | /     pub fn new(
106 | |         addr: SocketAddr,
107 | |         info_hash: Id20,
108 | |         peer_id: Id20,
...   |
111 | |         spawner: BlockingSpawner,
112 | |     ) -> Self {
    | |_____________^ can't leak crate-private type
    |
   ::: crates/librqbit/src/spawn_utils.rs:12:1
    |
12  |   pub(crate) struct BlockingSpawner {
    |   --------------------------------- `BlockingSpawner` declared as crate-private

error[E0446]: crate-private type `BlockingSpawner` in public interface
  --> crates/librqbit/src/peer_info_reader/mod.rs:27:1
   |
27 | / pub async fn read_metainfo_from_peer(
28 | |     addr: SocketAddr,
29 | |     peer_id: Id20,
30 | |     info_hash: Id20,
31 | |     peer_connection_options: Option<PeerConnectionOptions>,
32 | |     spawner: BlockingSpawner,
33 | | ) -> anyhow::Result<TorrentMetaV1Info<ByteString>> {
   | |__________________________________________________^ can't leak crate-private type
   |
  ::: crates/librqbit/src/spawn_utils.rs:12:1
   |
12 |   pub(crate) struct BlockingSpawner {
   |   --------------------------------- `BlockingSpawner` declared as crate-private

error[E0446]: crate-private type `BlockingSpawner` in public interface
   --> crates/librqbit/src/torrent_state/mod.rs:455:5
    |
455 |     pub fn spawner(&mut self, spawner: BlockingSpawner) -> &mut Self {
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak crate-private type
    |
   ::: crates/librqbit/src/spawn_utils.rs:12:1
    |
12  | pub(crate) struct BlockingSpawner {
    | --------------------------------- `BlockingSpawner` declared as crate-private

For more information about this error, try `rustc --explain E0446`.
error: could not compile `librqbit` (lib) due to 3 previous errors
warning: build failed, waiting for other jobs to finish...
error: builder for '/nix/store/5ika7sph8dlfxslwzwxhmm9nihgdfxxs-rqbit-4.0.0.drv' failed with exit code 101;
       last 10 log lines:
       >     |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak crate-private type
       >     |
       >    ::: crates/librqbit/src/spawn_utils.rs:12:1
       >     |
       > 12  | pub(crate) struct BlockingSpawner {
       >     | --------------------------------- `BlockingSpawner` declared as crate-private
       >
       > For more information about this error, try `rustc --explain E0446`.
       > error: could not compile `librqbit` (lib) due to 3 previous errors
       > warning: build failed, waiting for other jobs to finish...
       For full logs, run 'nix log /nix/store/5ika7sph8dlfxslwzwxhmm9nihgdfxxs-rqbit-4.0.0.drv'.

Yeah, I can repro on 1.73, works fine on 1.74. Will fix in a moment

Fixed here 215bccb, builds fine on 1.73 now, thanks for reporting

[nix-shell:/data/nixpkgs]$ rqbit --version
rqbit 4.0.0

Huge thanks for the rapid fix. I'll port it into nixpkgs (the package library) once the fix is in a release version.

Created 4.0.1 with this, published on crates.io too. It's being built by GitHub actions now