compile error with tokio 1.38
Closed this issue · 5 comments
Compile error is below:
cargo build --bin pqpt
Compiling sibyl v0.6.16
error[E0599]: no function or associated item named `new_multi_thread` found for struct `tokio::runtime::Builder` in the current scope
--> D:\rust\.cargo\registry\src\mirrors.tuna.tsinghua.edu.cn-df7c3c540f42cdbd\sibyl-0.6.16\src\task\tokio.rs:35:23
|
35 | runtime::Builder::new_multi_thread().enable_all().build().unwrap().block_on(async move {
| ^^^^^^^^^^^^^^^^ function or associated item not found in `Builder`
|
note: if you're trying to build a new `tokio::runtime::Builder` consider using one of the following associated functions:
tokio::runtime::Builder::new_current_thread
tokio::runtime::Builder::new
--> D:\rust\.cargo\registry\src\mirrors.tuna.tsinghua.edu.cn-df7c3c540f42cdbd\tokio-1.38.0\src\runtime\builder.rs:217:5
|
217 | pub fn new_current_thread() -> Builder {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
261 | pub(crate) fn new(kind: Kind, event_interval: u32) -> Builder {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: there is an associated function `new_current_thread` with a similar name
|
35 | runtime::Builder::new_current_thread().enable_all().build().unwrap().block_on(async move {
| ~~~~~~~~~~~~~~~~~~
For more information about this error, try `rustc --explain E0599`.
Any solution for this error ?
@quietboil Any kindly comment to solve this problem ?
I cannot reproduce this. Here is the current cargo tree
:
sibyl v0.6.16 (/home/alex/sibyl)
├── libc v0.2.155
├── once_cell v1.19.0
└── parking_lot v0.12.3
├── lock_api v0.4.12
│ └── scopeguard v1.2.0
│ [build-dependencies]
│ └── autocfg v1.3.0
└── parking_lot_core v0.9.10
├── cfg-if v1.0.0
├── libc v0.2.155
└── smallvec v1.13.2
[dev-dependencies]
└── tokio v1.38.1
├── num_cpus v1.16.0
│ └── libc v0.2.155
└── pin-project-lite v0.2.14
I also tried with Tokio 1.38.0. Everything still compiles and runs.
⚠ Note that for sibyl 0.6.16 the maximum supported rustc is 1.72.1. I'll have to make some changes in sibyl as 1.73.0 and later became stricter with unsafe
and some of the pointer conversions in sibyl are now being rejected.
Please provide a minimal example (Cargo.toml with main.rs should be sufficient) that fails to compile the same way as you reported.
⚡ One suspicion I have is that you have not included tokio in your project dependency, or included but did not enable features required for sibyl's nonblocking
feature to function. Check that you have at least:
[dependencies]
tokio = { version = "1.38", features = ["rt", "rt-multi-thread"] }
sibyl = { version = "0.6", features = ["nonblocking", "tokio"] }
Depending on how you use Tokio, you might want to add other features.
@quietboil Thanks a lot for your kindly help.
$ rustup update
info: syncing channel updates for 'stable-x86_64-pc-windows-msvc'
info: checking for self-update
stable-x86_64-pc-windows-msvc unchanged - rustc 1.79.0 (129f3b996 2024-06-10)
info: cleaning up downloads & tmp directories
I use the latest rustc (version 1.79) with tokio included in my project . Then I tried to compile with sibyl version .
[package]
name = "pqpt-rs"
version = "0.1.0"
edition = "2021"
[dependencies]
serde = { version = "1.0.204", features = ["derive"] }
serde_json = "1.0.120"
sibyl = { version = "=0.6.16", features = ["tokio", "nonblocking"] }
tokio = { version = "1.38.0", features = ["full"] }
[build-dependencies]
sibyl = { version = "=0.6.16", features = ["tokio", "nonblocking"] }
I also tried sibyl 0.6.15/0.6.14/ 0.6.10. But got the same compile error.
The cargo tree
outputs:
PS D:\workspace\pqpt-rs> cargo tree
pqpt-rs v0.1.0 (D:\workspace\pqpt-rs)
├── serde v1.0.204
│ └── serde_derive v1.0.204 (proc-macro)
│ ├── proc-macro2 v1.0.86
│ │ └── unicode-ident v1.0.12
│ ├── quote v1.0.36
│ │ └── proc-macro2 v1.0.86 (*)
│ └── syn v2.0.72
│ ├── proc-macro2 v1.0.86 (*)
│ ├── quote v1.0.36 (*)
│ └── unicode-ident v1.0.12
├── serde_json v1.0.120
│ ├── itoa v1.0.11
│ ├── ryu v1.0.18
│ └── serde v1.0.204 (*)
├── sibyl v0.6.14
│ ├── async-once-cell v0.4.4
│ ├── libc v0.2.155
│ ├── once_cell v1.19.0
│ ├── parking_lot v0.12.3
│ │ ├── lock_api v0.4.12
│ │ │ └── scopeguard v1.2.0
│ │ │ [build-dependencies]
│ │ │ └── autocfg v1.3.0
│ │ └── parking_lot_core v0.9.10
│ │ ├── cfg-if v1.0.0
│ │ ├── smallvec v1.13.2
│ │ └── windows-targets v0.52.6
│ │ └── windows_x86_64_msvc v0.52.6
│ └── tokio v1.38.1
│ ├── bytes v1.6.1
│ ├── mio v0.8.11
│ │ └── windows-sys v0.48.0
│ │ └── windows-targets v0.48.5
│ │ └── windows_x86_64_msvc v0.48.5
│ ├── num_cpus v1.16.0
│ ├── parking_lot v0.12.3 (*)
│ ├── pin-project-lite v0.2.14
│ ├── socket2 v0.5.7
│ │ └── windows-sys v0.52.0
│ │ └── windows-targets v0.52.6 (*)
│ ├── tokio-macros v2.3.0 (proc-macro)
│ │ ├── proc-macro2 v1.0.86 (*)
│ │ ├── quote v1.0.36 (*)
│ │ └── syn v2.0.72 (*)
│ └── windows-sys v0.48.0 (*)
└── tokio v1.38.1 (*)
[build-dependencies]
└── sibyl v0.6.14 (*)
So do I need to downgrade rustc verison to get rid of thie problem? Any other ways as workaround?
I need to downgrade rustc
Yes. To 1.72.1.
I'm still not sure about your specific build error. I added a minimal simple async example to provide a template of sorts for starting a project. See what's different between it and your implementation. The example compiles (with 1.72.1) and runs just fine.
rustc 1.72.1 works fine in my computer.
But after I reset default rustc to 1.79, the compile error disappears....
Even though cargo clean
or rm Cargo.lock
or re-create project in a diffrent path , I can't reproduce the same compile error. That's really weird....
Anyway, I can keep move on my project. Thanks again for your kindly help.