Skip to content

Octocrab doesn't compile with Yew (for me) #224

@NicMcPhee

Description

@NicMcPhee

I was hoping to use Octocrab on a Yew-based project that I'm working on, but when I added the octocrab dependency to my Cargo.toml file, octocrab failed to compile.

I created a small demo app that illustrates the issue: https://github.com/NicMcPhee/octocrab_test This is about the simplest possible Yew app, and if you uncomment the octocrab dependency in Cargo.toml and run trunk serve, you get a whole pile of compilation errors when it's trying to build the octocrab code (see below).

I'm guessing it's some kind of dependency conflict, but I really don't know.

Yew + Octocrab seems like an "obvious" combination, so it was definitely a bummer that this didn't work. Any suggestions or advice would definitely be appreciated.

Rust versions, etc.

rustup show provides the following output if that's helpful:

Default host: x86_64-apple-darwin
rustup home:  /Users/mcphee/.rustup

installed targets for active toolchain
--------------------------------------

wasm32-unknown-unknown
x86_64-apple-darwin

active toolchain
----------------

stable-x86_64-apple-darwin (default)
rustc 1.62.0 (a8314ef7d 2022-06-27)

The error text

   Compiling octocrab v0.16.0
error[E0599]: no method named `user_agent` found for struct `ClientBuilder` in the current scope
   --> /Users/mcphee/.cargo/registry/src/github.com-1ecc6299db9ec823/octocrab-0.16.0/src/lib.rs:338:14
    |
338 |             .user_agent("octocrab")
    |              ^^^^^^^^^^ method not found in `ClientBuilder`

error[E0599]: no method named `user_agent` found for struct `ClientBuilder` in the current scope
   --> /Users/mcphee/.cargo/registry/src/github.com-1ecc6299db9ec823/octocrab-0.16.0/src/lib.rs:432:18
    |
432 |                 .user_agent("octocrab")
    |                  ^^^^^^^^^^ method not found in `ClientBuilder`

error: future cannot be sent between threads safely
  --> /Users/mcphee/.cargo/registry/src/github.com-1ecc6299db9ec823/octocrab-0.16.0/src/from_response.rs:11:80
   |
11 |       async fn from_response(response: reqwest::Response) -> crate::Result<Self> {
   |  ________________________________________________________________________________^
12 | |         let text = response.text().await.context(crate::error::HttpSnafu)?;
13 | |
14 | |         let de = &mut serde_json::Deserializer::from_str(&text);
15 | |         serde_path_to_error::deserialize(de).context(crate::error::JsonSnafu)
16 | |     }
   | |_____^ future created by async block is not `Send`
   |
   = help: within `impl Future<Output = std::result::Result<T, error::Error>>`, the trait `Send` is not implemented for `*mut u8`
note: captured value is not `Send`
  --> /Users/mcphee/.cargo/registry/src/github.com-1ecc6299db9ec823/octocrab-0.16.0/src/from_response.rs:11:28
   |
11 |     async fn from_response(response: reqwest::Response) -> crate::Result<Self> {
   |                            ^^^^^^^^ has type `Response` which is not `Send`
   = note: required for the cast to the object type `dyn Future<Output = std::result::Result<T, error::Error>> + Send`

error: future cannot be sent between threads safely
  --> /Users/mcphee/.cargo/registry/src/github.com-1ecc6299db9ec823/octocrab-0.16.0/src/from_response.rs:11:80
   |
11 |       async fn from_response(response: reqwest::Response) -> crate::Result<Self> {
   |  ________________________________________________________________________________^
12 | |         let text = response.text().await.context(crate::error::HttpSnafu)?;
13 | |
14 | |         let de = &mut serde_json::Deserializer::from_str(&text);
15 | |         serde_path_to_error::deserialize(de).context(crate::error::JsonSnafu)
16 | |     }
   | |_____^ future created by async block is not `Send`
   |
   = help: within `impl Future<Output = std::result::Result<T, error::Error>>`, the trait `Send` is not implemented for `Rc<RefCell<wasm_bindgen_futures::Inner>>`
note: future is not `Send` as this value is used across an await
  --> /Users/mcphee/.cargo/registry/src/github.com-1ecc6299db9ec823/reqwest-0.11.11/src/wasm/mod.rs:22:41
   |
22 |     let js_val = JsFuture::from(promise).await.map_err(crate::error::wasm)?;
   |                  -----------------------^^^^^^ await occurs here, with `JsFuture::from(promise)` maybe used later
   |                  |
   |                  has type `wasm_bindgen_futures::JsFuture` which is not `Send`
note: `JsFuture::from(promise)` is later dropped here
  --> /Users/mcphee/.cargo/registry/src/github.com-1ecc6299db9ec823/reqwest-0.11.11/src/wasm/mod.rs:22:76
   |
22 |     let js_val = JsFuture::from(promise).await.map_err(crate::error::wasm)?;
   |                                                                            ^
   = note: required for the cast to the object type `dyn Future<Output = std::result::Result<T, error::Error>> + Send`

error: future cannot be sent between threads safely
   --> /Users/mcphee/.cargo/registry/src/github.com-1ecc6299db9ec823/octocrab-0.16.0/src/page.rs:88:80
    |
88  |       async fn from_response(response: reqwest::Response) -> crate::Result<Self> {
    |  ________________________________________________________________________________^
89  | |         let HeaderLinks {
90  | |             first,
91  | |             prev,
...   |
126 | |         }
127 | |     }
    | |_____^ future created by async block is not `Send`
    |
    = help: within `impl Future<Output = std::result::Result<page::Page<T>, error::Error>>`, the trait `Send` is not implemented for `*mut u8`
note: captured value is not `Send`
   --> /Users/mcphee/.cargo/registry/src/github.com-1ecc6299db9ec823/octocrab-0.16.0/src/page.rs:88:28
    |
88  |     async fn from_response(response: reqwest::Response) -> crate::Result<Self> {
    |                            ^^^^^^^^ has type `Response` which is not `Send`
    = note: required for the cast to the object type `dyn Future<Output = std::result::Result<page::Page<T>, error::Error>> + Send`

error: future cannot be sent between threads safely
   --> /Users/mcphee/.cargo/registry/src/github.com-1ecc6299db9ec823/octocrab-0.16.0/src/page.rs:88:80
    |
88  |       async fn from_response(response: reqwest::Response) -> crate::Result<Self> {
    |  ________________________________________________________________________________^
89  | |         let HeaderLinks {
90  | |             first,
91  | |             prev,
...   |
126 | |         }
127 | |     }
    | |_____^ future created by async block is not `Send`
    |
    = help: within `impl Future<Output = std::result::Result<page::Page<T>, error::Error>>`, the trait `Send` is not implemented for `Rc<RefCell<wasm_bindgen_futures::Inner>>`
note: future is not `Send` as this value is used across an await
   --> /Users/mcphee/.cargo/registry/src/github.com-1ecc6299db9ec823/reqwest-0.11.11/src/wasm/mod.rs:22:41
    |
22  |     let js_val = JsFuture::from(promise).await.map_err(crate::error::wasm)?;
    |                  -----------------------^^^^^^ await occurs here, with `JsFuture::from(promise)` maybe used later
    |                  |
    |                  has type `wasm_bindgen_futures::JsFuture` which is not `Send`
note: `JsFuture::from(promise)` is later dropped here
   --> /Users/mcphee/.cargo/registry/src/github.com-1ecc6299db9ec823/reqwest-0.11.11/src/wasm/mod.rs:22:76
    |
22  |     let js_val = JsFuture::from(promise).await.map_err(crate::error::wasm)?;
    |                                                                            ^
    = note: required for the cast to the object type `dyn Future<Output = std::result::Result<page::Page<T>, error::Error>> + Send`

error: future cannot be sent between threads safely
   --> /Users/mcphee/.cargo/registry/src/github.com-1ecc6299db9ec823/octocrab-0.16.0/src/models/repos.rs:119:80
    |
119 |       async fn from_response(response: reqwest::Response) -> crate::Result<Self> {
    |  ________________________________________________________________________________^
120 | |         let json: serde_json::Value = response.json().await.context(crate::error::HttpSnafu)?;
121 | |
122 | |         if json.is_array() {
...   |
132 | |         }
133 | |     }
    | |_____^ future created by async block is not `Send`
    |
    = help: within `impl Future<Output = std::result::Result<ContentItems, error::Error>>`, the trait `Send` is not implemented for `*mut u8`
note: captured value is not `Send`
   --> /Users/mcphee/.cargo/registry/src/github.com-1ecc6299db9ec823/octocrab-0.16.0/src/models/repos.rs:119:28
    |
119 |     async fn from_response(response: reqwest::Response) -> crate::Result<Self> {
    |                            ^^^^^^^^ has type `Response` which is not `Send`
    = note: required for the cast to the object type `dyn Future<Output = std::result::Result<ContentItems, error::Error>> + Send`

error: future cannot be sent between threads safely
   --> /Users/mcphee/.cargo/registry/src/github.com-1ecc6299db9ec823/octocrab-0.16.0/src/models/repos.rs:119:80
    |
119 |       async fn from_response(response: reqwest::Response) -> crate::Result<Self> {
    |  ________________________________________________________________________________^
120 | |         let json: serde_json::Value = response.json().await.context(crate::error::HttpSnafu)?;
121 | |
122 | |         if json.is_array() {
...   |
132 | |         }
133 | |     }
    | |_____^ future created by async block is not `Send`
    |
    = help: within `impl Future<Output = std::result::Result<ContentItems, error::Error>>`, the trait `Send` is not implemented for `Rc<RefCell<wasm_bindgen_futures::Inner>>`
note: future is not `Send` as this value is used across an await
   --> /Users/mcphee/.cargo/registry/src/github.com-1ecc6299db9ec823/reqwest-0.11.11/src/wasm/mod.rs:22:41
    |
22  |     let js_val = JsFuture::from(promise).await.map_err(crate::error::wasm)?;
    |                  -----------------------^^^^^^ await occurs here, with `JsFuture::from(promise)` maybe used later
    |                  |
    |                  has type `wasm_bindgen_futures::JsFuture` which is not `Send`
note: `JsFuture::from(promise)` is later dropped here
   --> /Users/mcphee/.cargo/registry/src/github.com-1ecc6299db9ec823/reqwest-0.11.11/src/wasm/mod.rs:22:76
    |
22  |     let js_val = JsFuture::from(promise).await.map_err(crate::error::wasm)?;
    |                                                                            ^
    = note: required for the cast to the object type `dyn Future<Output = std::result::Result<ContentItems, error::Error>> + Send`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions