tox-rs / tox

toxcore implementation in Rust
GNU General Public License v3.0
448 stars 32 forks source link

Build fails when used as a cargo git dependency #475

Closed antis81 closed 10 months ago

antis81 commented 10 months ago

Situation: I added the crate as a git dependency (tox on crate.io is still 0.1.1).

[dependencies.tox] 
git = "https://github.com/tox-rs/tox.git"
branch = "master"
# tag = "v0.2.0"

With this cargo build fails… :frowning_face:

:question: :thinking: Is there a use tokio::spawn; missing in some files?

cargo build                                                                                                                                                                                                                      
…
…
Compiling tox_core v0.2.0 (https://github.com/tox-rs/tox.git?branch=master#5ab95a61)
error[E0425]: cannot find function `spawn` in crate `tokio`
   --> /home/nils/.cargo/git/checkouts/tox-a959b112c82f70eb/5ab95a6/tox_core/src/relay/client/client.rs:317:16
    |
317 |         tokio::spawn(async move { self.run(dht_sk, dht_pk).await });
    |                ^^^^^ not found in `tokio`
    |
note: found an item that was configured out
   --> /home/nils/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.34.0/src/lib.rs:546:19
    |
546 |     pub use task::spawn;
    |                   ^^^^^
    = note: the item is gated behind the `rt` feature
help: consider importing this function
    |
1   + use std::thread::spawn;
    |
help: if you import `spawn`, refer to it directly
    |
317 -         tokio::spawn(async move { self.run(dht_sk, dht_pk).await });
317 +         spawn(async move { self.run(dht_sk, dht_pk).await });
    |

error[E0425]: cannot find function `spawn` in crate `tokio`
   --> /home/nils/.cargo/git/checkouts/tox-a959b112c82f70eb/5ab95a6/tox_core/src/relay/server/server_ext.rs:130:24
    |
130 |                 tokio::spawn(async move {
    |                        ^^^^^ not found in `tokio`
    |
note: found an item that was configured out
   --> /home/nils/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.34.0/src/lib.rs:546:19
    |
546 |     pub use task::spawn;
    |                   ^^^^^
    = note: the item is gated behind the `rt` feature
help: consider importing this function
    |
4   + use std::thread::spawn;
    |
help: if you import `spawn`, refer to it directly
    |
130 -                 tokio::spawn(async move {
130 +                 spawn(async move {
    |

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

:information_source: Cloning and building the tox crate directly succeeds. Shouldn't it result in the same error… :thinking: :grey_question:

antis81 commented 10 months ago

Sorry my failure I guess… adding the rt, rt-multi-thread features to dev-dependencies should be enough, right? Closing the issue.