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

does not work with cargo leptos #86

Open
KhaledHosseini opened this issue Jun 26, 2024 · 4 comments
Open

does not work with cargo leptos #86

KhaledHosseini opened this issue Jun 26, 2024 · 4 comments
Labels
Answered Someone Solved this and its Left open so others can see the Answer.

Comments

@KhaledHosseini
Copy link

KhaledHosseini commented Jun 26, 2024

when it is added to leptos project, and after running cargo leptos watch, the following error rises:

Compiling mio v0.8.11
 unresolved import `crate::sys::IoSourceState`
  --> /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/mio-0.8.11/src/io_source.rs:12:5
   |
12 | use crate::sys::IoSourceState;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^ no `IoSourceState` in `sys`

error[E0432]: unresolved import `crate::sys::tcp`
  --> /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/mio-0.8.11/src/net/tcp/listener.rs:15:17
   |
15 | use crate::sys::tcp::{bind, listen, new_for_addr};
   |                 ^^^ could not find `tcp` in `sys`

error[E0432]: unresolved import `crate::sys::tcp`
  --> /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/mio-0.8.11/src/net/tcp/stream.rs:13:17
   |
13 | use crate::sys::tcp::{connect, new_for_addr};
   |                 ^^^ could not find `tcp` in `sys`

error[E0433]: failed to resolve: could not find `Selector` in `sys`
   --> /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/mio-0.8.11/src/poll.rs:312:18
    |
312 |             sys::Selector::new().map(|selector| Poll {
    |                  ^^^^^^^^ could not find `Selector` in `sys`

error[E0433]: failed to resolve: could not find `event` in `sys`
  --> /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/mio-0.8.11/src/event/event.rs:24:14
   |
24 |         sys::event::token(&self.inner)
   |              ^^^^^ could not find `event` in `sys`

Any suggestion on how to resolve this?

@genusistimelord
Copy link
Member

I have asked benwise to take a look at this issue. As I have no idea why this is occurring. But from the Error, it seems to be some issue with Mio? Are you using Axum with Leptos? If not, my Session library will not currently work for anything but Axum. I have been planning to expand access to other systems that Leptos supports, but have not found the time to get around to it yet.

@KhaledHosseini
Copy link
Author

I have asked benwise to take a look at this issue. As I have no idea why this is occurring. But from the Error, it seems to be some issue with Mio? Are you using Axum with Leptos? If not, my Session library will not currently work for anything but Axum. I have been planning to expand access to other systems that Leptos supports, but have not found the time to get around to it yet.

Yes, I use axum. I created my project using: cargo leptos new --git leptos-rs/start-axum.

@KhaledHosseini
Copy link
Author

For anyone who comes up with this problem, you can solve it by making the crate optional inside leptos project Cargo.toml. many crates have limited WASM support and you need to make them optional and only enable them in the server feature(ssr). so instead of

axum_session = { version = "0.14.0", features = ["advanced"] }
axum_session_auth = { version = "0.14.0", features = ["advanced"]}
axum_session_sqlx = { version= "0.1.0"}

use the following: (add optional=true):

axum_session = { version = "0.14.0", features = ["advanced"], optional = true }
axum_session_auth = { version = "0.14.0", features = ["advanced"], optional = true}
axum_session_sqlx = { version= "0.1.0", optional = true}

[features]
hydrate = ["leptos/hydrate", "leptos_meta/hydrate", "leptos_router/hydrate"]
ssr = [
    "dep:axum",
    "dep:tokio",
    "dep:sqlx",
    "dep:axum_session",
    "dep:axum_session_auth",
    "dep:axum_session_sqlx",
    "dep:tower",
    "dep:tower-http",
    "dep:leptos_axum",
    "leptos/ssr",
    "leptos_meta/ssr",
    "leptos_router/ssr",
    "dep:tracing",
]

@genusistimelord
Copy link
Member

ahh so that was the issue. Thank you for letting us know. We will leave this Open for other people to See the answer too.

@genusistimelord genusistimelord added the Answered Someone Solved this and its Left open so others can see the Answer. label Jun 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Answered Someone Solved this and its Left open so others can see the Answer.
Projects
None yet
Development

No branches or pull requests

2 participants