leptos-rs / start-axum

Starter template for use with the Leptos web framework and Axum.
The Unlicense
141 stars 26 forks source link

Cannot start app due to compiler errors #24

Closed kwiat1990 closed 9 months ago

kwiat1990 commented 11 months ago

I have downloaded start-axum template today and executed setup all commands listed in README file but after that while running cargo leptos watch I get following errors and the app doesn’t show up in the browser:

leptos-axum git:(main) ✗ cargo leptos watch                      
   Compiling leptos_dom v0.5.2
error[E0609]: no field `children` on type `html::HtmlElement<El>`
   --> /Users/mateusz.kwiatkowski/.cargo/registry/src/index.crates.io-6f17d22bba15001f/leptos_dom-0.5.2/src/html.rs:593:30
    |
593 |             if matches!(self.children, ElementChildren::Chunks(_)) {
    |                              ^^^^^^^^ unknown field
    |
    = note: available fields are: `span`, `element`, `view_marker`

error[E0609]: no field `children` on type `html::HtmlElement<El>`
   --> /Users/mateusz.kwiatkowski/.cargo/registry/src/index.crates.io-6f17d22bba15001f/leptos_dom-0.5.2/src/html.rs:676:30
    |
676 |             if matches!(self.children, ElementChildren::Chunks(_)) {
    |                              ^^^^^^^^ unknown field
    |
    = note: available fields are: `span`, `element`, `view_marker`

error[E0609]: no field `children` on type `html::HtmlElement<El>`
   --> /Users/mateusz.kwiatkowski/.cargo/registry/src/index.crates.io-6f17d22bba15001f/leptos_dom-0.5.2/src/html.rs:740:30
    |
740 |             if matches!(self.children, ElementChildren::Chunks(_)) {
    |                              ^^^^^^^^ unknown field
    |
    = note: available fields are: `span`, `element`, `view_marker`

error[E0609]: no field `children` on type `html::HtmlElement<El>`
   --> /Users/mateusz.kwiatkowski/.cargo/registry/src/index.crates.io-6f17d22bba15001f/leptos_dom-0.5.2/src/html.rs:767:30
    |
767 |             if matches!(self.children, ElementChildren::Chunks(_)) {
    |                              ^^^^^^^^ unknown field
    |
    = note: available fields are: `span`, `element`, `view_marker`

error[E0609]: no field `children` on type `html::HtmlElement<El>`
   --> /Users/mateusz.kwiatkowski/.cargo/registry/src/index.crates.io-6f17d22bba15001f/leptos_dom-0.5.2/src/html.rs:882:30
    |
882 |             if matches!(self.children, ElementChildren::Chunks(_)) {
    |                              ^^^^^^^^ unknown field
    |
    = note: available fields are: `span`, `element`, `view_marker`

error[E0433]: failed to resolve: use of undeclared type `ElementChildren`
   --> /Users/mateusz.kwiatkowski/.cargo/registry/src/index.crates.io-6f17d22bba15001f/leptos_dom-0.5.2/src/html.rs:593:40
    |
593 |             if matches!(self.children, ElementChildren::Chunks(_)) {
    |                                        ^^^^^^^^^^^^^^^ use of undeclared type `ElementChildren`

error[E0433]: failed to resolve: use of undeclared type `ElementChildren`
   --> /Users/mateusz.kwiatkowski/.cargo/registry/src/index.crates.io-6f17d22bba15001f/leptos_dom-0.5.2/src/html.rs:676:40
    |
676 |             if matches!(self.children, ElementChildren::Chunks(_)) {
    |                                        ^^^^^^^^^^^^^^^ use of undeclared type `ElementChildren`

error[E0433]: failed to resolve: use of undeclared type `ElementChildren`
   --> /Users/mateusz.kwiatkowski/.cargo/registry/src/index.crates.io-6f17d22bba15001f/leptos_dom-0.5.2/src/html.rs:740:40
    |
740 |             if matches!(self.children, ElementChildren::Chunks(_)) {
    |                                        ^^^^^^^^^^^^^^^ use of undeclared type `ElementChildren`

error[E0433]: failed to resolve: use of undeclared type `ElementChildren`
   --> /Users/mateusz.kwiatkowski/.cargo/registry/src/index.crates.io-6f17d22bba15001f/leptos_dom-0.5.2/src/html.rs:767:40
    |
767 |             if matches!(self.children, ElementChildren::Chunks(_)) {
    |                                        ^^^^^^^^^^^^^^^ use of undeclared type `ElementChildren`

error[E0433]: failed to resolve: use of undeclared type `ElementChildren`
   --> /Users/mateusz.kwiatkowski/.cargo/registry/src/index.crates.io-6f17d22bba15001f/leptos_dom-0.5.2/src/html.rs:882:40
    |
882 |             if matches!(self.children, ElementChildren::Chunks(_)) {
    |                                        ^^^^^^^^^^^^^^^ use of undeclared type `ElementChildren`

Some errors have detailed explanations: E0433, E0609.
For more information about an error, try `rustc --explain E0433`.
error: could not compile `leptos_dom` (lib) due to 10 previous errors
      Notify watching paths public, style, src

On the other hand start-axum-workspace works fine and compiles without errors.

gbj commented 10 months ago

I'm not able to reproduce this with

 cargo leptos new --git leptos-rs/start-axum
 cargo leptos build
th3oth3rjak3 commented 10 months ago

I can confirm I am having the same issue but the version of leptos_dom is 0.5.4 in my case. I've tried using both nightly and stable rust but could not solve this. Rust versions all updated and cargo-leptos updated to latest. Running on Windows 11. Happy to provide more details if it helps solve this bug. I really like the full stack idea and I think this is the bread and butter of where Leptos shines.

gbj commented 10 months ago

@th3oth3rjak3 Like I said, I cannot reproduce this by creating a fresh project using this template. Have you made any changes to the starter that led to this issue? If so, sharing a reproduction or a diff relative to the template is useful.

th3oth3rjak3 commented 10 months ago

@gbj I think I figured out the problem and this could explain why the other template which uses a workspace doesn't have the issue. When I first loaded up the template, I was getting VSCode messages and the text was graying out because of the cfg macros. Thinking there was an issue, I did cargo add leptos --features ssr and cargo add leptos --features hydrate. This updated the Cargo.toml file which now (incorrectly) had extra features specified right next to the "nightly" feature on line 14. Once I removed those the app ran fine. I think all of these things are covered in the docs, but I didn't put two and two together because when I read the part about the Rust-Analyzer in the docs, I hadn't really even tried making a template yet and was still just interested in learning the syntax of the framework. I think maybe a section in the docs that describe the best way to add dependencies to the cargo.toml file would be helpful and maybe even a reminder in the template README about the Rust-Analyzer gray-out problem and a workaround.

Bottom line is that I don't think this is a bug, but I do think it is something that might trip people up from time to time. I did end up using the README to add the additional packages (lines 39-46) and that was very helpful. Thanks for all you do!

gbj commented 10 months ago

@gbj I think I figured out the problem and this could explain why the other template which uses a workspace doesn't have the issue. When I first loaded up the template, I was getting VSCode messages and the text was graying out because of the cfg macros. Thinking there was an issue, I did cargo add leptos --features ssr and cargo add leptos --features hydrate. This updated the Cargo.toml file which now (incorrectly) had extra features specified right next to the "nightly" feature on line 14. Once I removed those the app ran fine. I think all of these things are covered in the docs, but I didn't put two and two together because when I read the part about the Rust-Analyzer in the docs, I hadn't really even tried making a template yet and was still just interested in learning the syntax of the framework.

Yeah fair enough. The mutually exclusive feature flags are a real pain point, for many reasons, and I'm trying to remove them in as many places as possible for the next release. Sorry they bit you here.