leptos icon indicating copy to clipboard operation
leptos copied to clipboard

Unable to build example todo-app-sqlite-axum

Open abhemanyus opened this issue 2 years ago • 2 comments

I have tried to re-create the example on system, but it does not work. Command: cargo run --no-default-features --features=ssr Output: ```warning: unused import: leptos::* --> src/lib.rs:2:5 | 2 | use leptos::*; | ^^^^^^^^^ | = note: #[warn(unused_imports)] on by default

warning: unused variable: row --> src/todo.rs:73:12 | 73 | Ok(row) => Ok(()), | ^^^ help: if this is intentional, prefix it with an underscore: _row | = note: #[warn(unused_variables)] on by default

warning: unused Result that must be used --> src/todo.rs:15:13 | 15 | GetTodos::register(); | ^^^^^^^^^^^^^^^^^^^^ | = note: this Result may be an Err variant, which should be handled = note: #[warn(unused_must_use)] on by default

warning: unused Result that must be used --> src/todo.rs:16:13 | 16 | AddTodo::register(); | ^^^^^^^^^^^^^^^^^^^ | = note: this Result may be an Err variant, which should be handled

warning: unused Result that must be used --> src/todo.rs:17:13 | 17 | DeleteTodo::register(); | ^^^^^^^^^^^^^^^^^^^^^^ | = note: this Result may be an Err variant, which should be handled

warning: full-stack-axum (lib) generated 5 warnings (run cargo fix --lib -p full-stack-axum to apply 2 suggestions) error[E0277]: the trait bound fn(axum::extract::path::Path<std::string::String>, HeaderMap, axum::body::Bytes) -> impl Future<Output = impl axum_core::response::into_response::IntoResponse> {handle_server_fns}: Handler<_, _, _> is not satisfied --> src/main.rs:50:38 | 50 | .route("/api/*fn_name", post(leptos_axum::handle_server_fns)) | ---- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait Handler<_, _, _> is not implemented for fn item fn(axum::extract::path::Path<std::string::String>, HeaderMap, axum::body::Bytes) -> impl Future<Output = impl axum_core::response::into_response::IntoResponse> {handle_server_fns} | | | required by a bound introduced by this call | = note: Consider using #[axum::debug_handler] to improve the error message = help: the trait Handler<T, S, B2> is implemented for Layered<L, H, T, S, B, B2> note: required by a bound in post --> /home/sanndy/.cargo/registry/src/github.com-1ecc6299db9ec823/axum-0.6.1/src/routing/method_routing.rs:407:1 | 407 | top_level_handler_fn!(post, POST); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in post = note: this error originates in the macro top_level_handler_fn (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0277]: the trait bound impl (Fn(http::Request<Body>) -> Pin<Box<(dyn Future<Output = axum::body::stream_body::StreamBody<Pin<Box<(dyn futures_core::stream::Stream<Item = Result<axum::body::Bytes, std::io::Error>> + Send + 'static)>>>> + Send + 'static)>>) + Clone + Send + 'static: Handler<_, _, _> is not satisfied --> src/main.rs:53:19 | 53 | .fallback(leptos_axum::render_app_to_stream("todo_app_sqlite_axum", |cx| view! { cx, <TodoApp/> })); | -------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait Handler<_, _, _> is not implemented for impl (Fn(http::Request<Body>) -> Pin<Box<(dyn Future<Output = axum::body::stream_body::StreamBody<Pin<Box<(dyn futures_core::stream::Stream<Item = Result<axum::body::Bytes, std::io::Error>> + Send + 'static)>>>> + Send + 'static)>>) + Clone + Send + 'static | | | required by a bound introduced by this call | = note: Consider using #[axum::debug_handler] to improve the error message = help: the trait Handler<T, S, B2> is implemented for Layered<L, H, T, S, B, B2> note: required by a bound in Router::<S, B>::fallback --> /home/sanndy/.cargo/registry/src/github.com-1ecc6299db9ec823/axum-0.6.1/src/routing/mod.rs:377:12 | 377 | H: Handler<T, S, B>, | ^^^^^^^^^^^^^^^^ required by this bound in Router::<S, B>::fallback

For more information about this error, try rustc --explain E0277. error: could not compile full-stack-axum due to 2 previous errors``` Repository: https://github.com/abhemanyus/rust-axum-leptos

I am unable to debug the cause with axum_macros::debug_handler What am I missing?

abhemanyus avatar Dec 03 '22 15:12 abhemanyus

It looks like you are trying to run examples/hackernews-axum.

Try following steps:

  1. rustup toolchain install nightly --allow-downgrade - make sure you have Rust nightly
  2. rustup default nightly - setup nightly as default, alternatively you can use rust-toolchain file
  3. rustup target add wasm32-unknown-unknown - add wasm Rust target
  4. cargo install wasm-pack - install wasm-pack

After that you should be able to build & run the example.

  1. wasm-pack build --target=web --no-default-features --features=hydrate - build for SSR with hydration
  2. cargo run --no-default-features --features=ssr

michalvavra avatar Dec 03 '22 17:12 michalvavra

Can you show us your Cargo.toml? I may need to release some new versions.

gbj avatar Dec 03 '22 17:12 gbj

@michalvavra @gbj I have uploaded all my source code to this repository https://github.com/abhemanyus/rust-axum-leptos

abhemanyus avatar Dec 04 '22 02:12 abhemanyus

Hey sorry about the inconvenience. I've published a new leptos_axum 0.0.3 so if you update you should be all set. Tested it on a clone of your repo and it's fine.

We just pushed the changes to get compatibility with Axum 0.6 and I hadn't published a new release yet.

Enjoy!

gbj avatar Dec 04 '22 03:12 gbj

It is working now, thanks a lot!

abhemanyus avatar Dec 04 '22 07:12 abhemanyus