Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Cargo.toml][tokio] Switch to rt-multi-thread feature on tokio #116

Closed
wants to merge 1 commit into from

Conversation

vintitres
Copy link
Contributor

@vintitres vintitres commented Jun 2, 2024

I am getting following error when trying to instal from crates.io

$ cargo install cargo-aoc

(note that cargo install ignores the lock file so newer tokio is installed than on cargo build rust-lang/cargo#7169 )

    Updating crates.io index
  Installing cargo-aoc v0.3.7
    Updating crates.io index
…
   Compiling tokio v1.38.0
…
   Compiling cargo-aoc v0.3.7
error[E0599]: no function or associated item named `new` found for struct `Runtime` in the current scope
   --> /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/cargo-aoc-0.3.7/src/app.rs:61:47
    |
61  |             let rt = tokio::runtime::Runtime::new().unwrap();
    |                                               ^^^ function or associated item not found in `Runtime`
    |
note: if you're trying to build a new `Runtime`, consider using `Runtime::from_parts` which returns `Runtime`
   --> /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.38.0/src/runtime/runtime.rs:138:5
    |
138 | /     pub(super) fn from_parts(
139 | |         scheduler: Scheduler,
140 | |         handle: Handle,
141 | |         blocking_pool: BlockingPool,
142 | |     ) -> Runtime {
    | |________________^

For more information about this error, try `rustc --explain E0599`.
error: could not compile `cargo-aoc` (bin "cargo-aoc") due to 1 previous error
error: failed to compile `cargo-aoc v0.3.7`, intermediate artifacts can be found at `/tmp/cargo-installYFL5GA`.
To reuse those artifacts with a future compilation, set the environment variable `CARGO_TARGET_DIR` to that path.

Using the rt-multi-thread feature on tokio fixes the build.

@vintitres
Copy link
Contributor Author

tokio-rs/tokio@9ed5957

This commit in tokio has removed the cfg_not_wasi! which was guarding the #[cfg(feature = "rt-multi-thread")] on the Runtime::new function.

@vintitres
Copy link
Contributor Author

I think it will be better to use runtime builder instead

runtime::Builder::new_current_thread().build().unwrap();

@vintitres vintitres closed this Jun 2, 2024
@vintitres
Copy link
Contributor Author

#117

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant