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

Use tokio::runtime::Builder::new_current_thread #117

Merged
merged 1 commit into from
Nov 26, 2024

Conversation

vintitres
Copy link
Contributor

When using cargo install cargo-aoc cargo doesn’t use the Cargo.lock file (see rust-lang/cargo#7169 ) and installs newer tokio which results in a build error of cargo-aoc as tokio has hidden the Runtime::new function under rt-multi-thread feature in this commit tokio-rs/tokio@9ed5957 .

This is the error I am seeing:


    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
…

Using tokio::runtime::Builder::new_current_thread to create the runtime fixes the build error.

Tested by running

cargo-aoc    $ cargo install —path cargo-aoc

myaocrepo  $ cargo aoc credentials $TOKEN
myaocrepo  $ cargo aoc input -d 2023 -d 23

@vintitres vintitres closed this Jun 3, 2024
@vintitres vintitres deleted the runtime branch June 3, 2024 01:57
@vintitres vintitres restored the runtime branch June 3, 2024 02:02
@vintitres vintitres reopened this Jun 3, 2024
@Chris--B
Copy link

Chris--B commented Nov 1, 2024

It's now November and in getting myself setup for the annual tradition in under 30 days, I am hitting this issue too. :(

Can we prioritize PRs like this one? 🙏

A workaround for folks finding this on Google, use --locked:

cargo install cargo-aoc --force --locked

@gobanos gobanos merged commit b2d0030 into gobanos:v0.3 Nov 26, 2024
@vintitres vintitres deleted the runtime branch November 26, 2024 19:10
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.

3 participants