listen icon indicating copy to clipboard operation
listen copied to clipboard

Listen-kit as a local dependecy, from sources, won't build in referencing project

Open dandagow3t opened this issue 10 months ago • 1 comments

Description

I've added listen-kit as a local dependency to my project Cargo.toml

listen-kit = { path = "../listen/listen-kit"}

but I'm unable to build through:

error: future cannot be sent between threads safely
   --> /listen/listen-kit/src/http/routes.rs:103:5
    |
103 | /     spawn_with_signer(signer, || async move {
104 | |         let reasoning_loop = ReasoningLoop::new(agent).with_stdout(false);
105 | |
106 | |         let mut initial_messages = messages;
...   |
160 | |         Ok(())
161 | |     })
    | |______^ future created by async block is not `Send`
    |
    = help: the trait `std::marker::Send` is not implemented for `dyn futures_util::Stream<Item = Result<StreamingChoice, rig::completion::CompletionError>>`
note: future is not `Send` as this value is used across an await
   --> /listen/listen-kit/src/reasoning_loop.rs:47:51
    |
43  |             let mut stream =
    |                 ---------- has type `Pin<Box<dyn futures_util::Stream<Item = Result<StreamingChoice, rig::completion::CompletionError>>>>` which is not `Send`
...
47  |             while let Some(chunk) = stream.next().await {
    |                                                   ^^^^^ await occurs here, with `mut stream` maybe used later
note: required by a bound in `spawn_with_signer`
   --> /listen/listen-kit/src/common.rs:30:39
    |
24  | pub async fn spawn_with_signer<F, Fut, T>(
    |              ----------------- required by a bound in this function
...
30  |     Fut: Future<Output = Result<T>> + Send + 'static,
    |                                       ^^^^ required by this bound in `spawn_with_signer`

error: could not compile `listen-kit` (lib) due to 1 previous error

Steps to Reproduce

  1. Create a new project cargo new test_listen_kit
  2. Add listen-kit as a new dependency in Cargo.toml
[dependencies]
listen-kit = { path = "../listen/listen-kit" }

also, tried with all combinations of features (http, solana, or both) 3. Run

cargo build

Additional Notes

No response

dandagow3t avatar Feb 10 '25 09:02 dandagow3t

The root cause here is how features are being handled across both crates. In listen-kit, the default feature is set to ["http"]. When you reference listen-kit from your project with the solana feature, both http and solana features end up being activated simultaneously. This combination is causing the compilation error you encountered. The solution is to modify listen-kit's default feature to be ["solana"] instead of ["http"]. This change would prevent both features from being activated unintentionally when you reference the crate in your project.

What's weird is that listen-kit compiles just fine on it's own with both features (http & solana) activated.

dandagow3t avatar Feb 10 '25 15:02 dandagow3t

cargo add rig-onchain-kit

piotrostr avatar Mar 02 '25 12:03 piotrostr