thaw-ui / thaw

An easy to use leptos component library
https://thawui.vercel.app
MIT License
209 stars 23 forks source link

Unable to Run Thaw with Leptos-Axum on NixOS #105

Closed disbolog closed 2 months ago

disbolog commented 4 months ago

Hello,

I have a bit non-conventional setup with Leptos on NixOS.

I am getting the following error when trying to do cargo run:

[user@host:~/rust/leptos-ssr-thaw]$ cargo run --timings
   Compiling leptos-ssr-thaw v0.1.0 (/home/user/rust/leptos-ssr-thaw)
error[E0277]: the trait bound `&fn(ButtonProps) -> impl leptos_dom::IntoView {Button}: ComponentConstructor<_>` is not satisfied
   --> src/app.rs:47:5
    |
47  | /     view! {
48  | |         <h1>"Welcome to Leptos!"</h1>
49  | |         // <button on:click=on_click>"Click Me: " {count}</button>
50  | |
51  | |         <Button variant=ButtonVariant::Primary>"Click me" {count}</Button>
52  | |     }
    | |_____^ the trait `ComponentConstructor<_>` is not implemented for `&fn(ButtonProps) -> impl leptos_dom::IntoView {Button}`
    |
note: required by a bound in `component_view`
   --> /home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/leptos-0.6.5/src/lib.rs:325:34
    |
325 | pub fn component_view<P>(f: impl ComponentConstructor<P>, props: P) -> View {
    |                                  ^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `component_view`
    = note: this error originates in the macro `view` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0277]: the trait bound `fn(ButtonProps) -> impl leptos_dom::IntoView {Button}: leptos::Component<_>` is not satisfied
   --> src/app.rs:47:5
    |
47  | /     view! {
48  | |         <h1>"Welcome to Leptos!"</h1>
49  | |         // <button on:click=on_click>"Click Me: " {count}</button>
50  | |
51  | |         <Button variant=ButtonVariant::Primary>"Click me" {count}</Button>
52  | |     }
    | |_____^ the trait `leptos::Component<_>` is not implemented for fn item `fn(ButtonProps) -> impl leptos_dom::IntoView {Button}`
    |
help: trait impls with same name found
   --> /home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/leptos-0.5.7/src/lib.rs:309:1
    |
309 |   impl<F, R> Component<EmptyPropsBuilder> for F where F: FnOnce() -> R {}
    |   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
310 |
311 | / impl<P, F, R> Component<P> for F
312 | | where
313 | |     F: FnOnce(P) -> R,
314 | |     P: Props,
    | |_____________^
    = note: perhaps two different versions of crate `leptos` are being used?
note: required by a bound in `component_props_builder`
   --> /home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/leptos-0.6.5/src/lib.rs:319:15
    |
318 | pub fn component_props_builder<P: PropsOrNoPropsBuilder>(
    |        ----------------------- required by a bound in this function
319 |     _f: &impl Component<P>,
    |               ^^^^^^^^^^^^ required by this bound in `component_props_builder`
    = note: this error originates in the macro `view` (in Nightly builds, run with -Z macro-backtrace for more info)

For more information about this error, try `rustc --explain E0277`.
error: could not compile `leptos-ssr-thaw` (lib) due to 2 previous errors

Here's src/app.rs:

use crate::error_template::{AppError, ErrorTemplate};
use leptos::*;
use leptos_meta::*;
use leptos_router::*;
use thaw::{Button, ButtonVariant};

#[component]
pub fn App() -> impl IntoView {
    // Provides context that manages stylesheets, titles, meta tags, etc.
    provide_meta_context();

    view! {

        // injects a stylesheet into the document <head>
        // id=leptos means cargo-leptos will hot-reload this stylesheet
        <Stylesheet id="leptos" href="/pkg/leptos-ssr-thaw.css"/>

        // sets the document title
        <Title text="Welcome to Leptos"/>

        // content for this welcome page
        <Router fallback=|| {
            let mut outside_errors = Errors::default();
            outside_errors.insert_with_default_key(AppError::NotFound);
            view! {
                <ErrorTemplate outside_errors/>
            }
            .into_view()
        }>
            <main>
                <Routes>
                    <Route path="" view=HomePage/>
                </Routes>
            </main>
        </Router>
    }
}

/// Renders the home page of your application.
#[component]
fn HomePage() -> impl IntoView {
    // Creates a reactive value to update the button
    let (count, set_count) = create_signal(0);
    let on_click = move |_| set_count.update(|count| *count += 1);

    view! {
        <h1>"Welcome to Leptos!"</h1>
        // <button on:click=on_click>"Click Me: " {count}</button>

        <Button variant=ButtonVariant::Primary>"Click me" {count}</Button>
    }
}
[package]
name = "leptos-ssr-thaw"
version = "0.1.0"
edition = "2021"

[lib]
crate-type = ["cdylib", "rlib"]

[profile.dev]
incremental = false
debug = 0
lto = "thin"

[dependencies]
axum = { version = "0.7", optional = true }
console_error_panic_hook = "0.1"
leptos = { version = "0.6", features = ["nightly"] }
leptos_axum = { version = "0.6", optional = true }
leptos_meta = { version = "0.6", features = ["nightly"] }
leptos_router = { version = "0.6", features = ["nightly"] }
tokio = { version = "1", features = ["rt-multi-thread"], optional = true }
tower = { version = "0.4", optional = true }
tower-http = { version = "0.5", features = ["fs"], optional = true }
wasm-bindgen = "=0.2.91"
thiserror = "1"
tracing = { version = "0.1", optional = true }
http = "1"
thaw = { version = "0.1.10", features = ["csr", "ssr"] }

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

# Defines a size-optimized profile for the WASM bundle in release mode
[profile.wasm-release]
inherits = "release"
opt-level = 'z'
lto = true
codegen-units = 1
panic = "abort"
incremental = false

[package.metadata.leptos]
# The name used by wasm-bindgen/cargo-leptos for the JS/WASM bundle. Defaults to the crate name
output-name = "leptos-ssr-thaw"

# The site root folder is where cargo-leptos generate all output. WARNING: all content of this folder will be erased on a rebuild. Use it in your server setup.
site-root = "target/site"

# The site-root relative folder where all compiled output (JS, WASM and CSS) is written
# Defaults to pkg
site-pkg-dir = "pkg"

# [Optional] The source CSS file. If it ends with .sass or .scss then it will be compiled by dart-sass into CSS. The CSS is optimized by Lightning CSS before being written to <site-root>/<site-pkg>/app.css
style-file = "style/main.scss"
# Assets source dir. All files found here will be copied and synchronized to site-root.
# The assets-dir cannot have a sub directory with the same name/path as site-pkg-dir.
#
# Optional. Env: LEPTOS_ASSETS_DIR.
assets-dir = "public"

# The IP and port (ex: 127.0.0.1:3000) where the server serves the content. Use it in your server setup.
site-addr = "127.0.0.1:3000"

# The port to use for automatic reload monitoring
reload-port = 3001

# [Optional] Command to use when running end2end tests. It will run in the end2end dir.
#   [Windows] for non-WSL use "npx.cmd playwright test"
#   This binary name can be checked in Powershell with Get-Command npx
end2end-cmd = "npx playwright test"
end2end-dir = "end2end"

#  The browserlist query used for optimizing the CSS.
browserquery = "defaults"

# Set by cargo-leptos watch when building with that tool. Controls whether autoreload JS will be included in the head
watch = false

# The environment Leptos will run in, usually either "DEV" or "PROD"
env = "DEV"

# The features to use when compiling the bin target
#
# Optional. Can be over-ridden with the command line parameter --bin-features
bin-features = ["ssr"]

# If the --no-default-features flag should be used when compiling the bin target
#
# Optional. Defaults to false.
bin-default-features = false

# The features to use when compiling the lib target
#
# Optional. Can be over-ridden with the command line parameter --lib-features
lib-features = ["hydrate"]

# If the --no-default-features flag should be used when compiling the lib target
#
# Optional. Defaults to false.
lib-default-features = false

# The profile to use for the lib target when compiling for release
#
# Optional. Defaults to "release".
lib-profile-release = "wasm-release"
disbolog commented 4 months ago

Also created a discussion at the Leptos repo: https://github.com/leptos-rs/leptos/discussions/2300

luoxiaozero commented 4 months ago

There are a few questions:

Perform cargo leptos serve instead of cargo run. (install cargo-leptos)

Change the configuration to:

thaw = "0.2.0"

[features]
hydrate = ["leptos/hydrate", "leptos_meta/hydrate", "leptos_router/hydrate", "thaw/hydrate"]
ssr = [
    "dep:axum",
    "dep:tokio",
    "dep:tower",
    "dep:tower-http",
    "dep:leptos_axum",
    "leptos/ssr",
    "leptos_meta/ssr",
    "leptos_router/ssr",
    "thaw/ssr",
    "dep:tracing",
]
disbolog commented 4 months ago

Hi @luoxiaozero , thanks for the reply, and for the thawui.

I have updated thaw to 0.2.0. I now have thaw = { version = "0.2.0", features = ["csr", "ssr"] } in Cargo.toml, as well as added ssr = [ ... "thaw/ssr" ... ]

Your suggestion kinda pushed the needle forward, but I now experience a new error:

[user@host:~/rust/leptos-ssr-thaw]$ cargo leptos watch
   Compiling proc-macro2 v1.0.78
    # ...
    # omitted
    # ...
   Compiling leptos_dom v0.6.6
error[E0609]: no field `children` on type `html::HtmlElement<El>`
   --> /home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/leptos_dom-0.6.6/src/html.rs:601:30
    |
601 |             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>`
   --> /home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/leptos_dom-0.6.6/src/html.rs:684:30
    |
684 |             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>`
   --> /home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/leptos_dom-0.6.6/src/html.rs:748:30
    |
748 |             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>`
   --> /home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/leptos_dom-0.6.6/src/html.rs:775:30
    |
775 |             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>`
   --> /home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/leptos_dom-0.6.6/src/html.rs:890:30
    |
890 |             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`
   --> /home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/leptos_dom-0.6.6/src/html.rs:601:40
    |
601 |             if matches!(self.children, ElementChildren::Chunks(_)) {
    |                                        ^^^^^^^^^^^^^^^ use of undeclared type `ElementChildren`

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

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

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

error[E0433]: failed to resolve: use of undeclared type `ElementChildren`
   --> /home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/leptos_dom-0.6.6/src/html.rs:890:40
    |
890 |             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 style, src, public
^C      Leptos ctrl-c received

I have also tried thaw without extra features - thaw = "0.2.0"

That produces some other error:

[user@host:~/rust/leptos-ssr-thaw]$ cargo leptos watch
   Compiling server_fn_macro v0.6.6
   Compiling leptos_reactive v0.6.6
   Compiling server_fn_macro_default v0.6.6
   Compiling leptos_macro v0.6.6
   Compiling server_fn v0.6.6
   Compiling leptos_dom v0.6.6
   Compiling leptos_server v0.6.6
   Compiling leptos v0.6.6
   Compiling leptos_router v0.6.6
   Compiling leptos_meta v0.6.6
   Compiling thaw v0.2.0
error[E0277]: the trait bound `(dyn Subscriber + Send + std::marker::Sync + 'static): callback::NotRawCallback` is not satisfied in `{closure@/home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/thaw-0.2.0/src/modal/mod.rs:36:20: 36:28}`
    --> /home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/thaw-0.2.0/src/modal/mod.rs:56:5
     |
36   |       let on_enter = move |_| {
     |                      -------- within this `{closure@/home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/thaw-0.2.0/src/modal/mod.rs:36:20: 36:28}`
...
56   | /     view! {
57   | |         <Teleport>
58   | |             <div
59   | |                 class="thaw-modal-container"
...    |
80   | |                     on_enter
     | |                     --------
     | |                     |
     | |                     this tail expression is of type `{closure@mod.rs:36:20}`
     | |                     required by a bound introduced by this call
...    |
114  | |         </Teleport>
115  | |     }
     | |_____^ within `{closure@/home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/thaw-0.2.0/src/modal/mod.rs:36:20: 36:28}`, the trait `callback::NotRawCallback` is not implemented for `(dyn Subscriber + Send + std::marker::Sync + 'static)`, which is required by `{closure@/home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/thaw-0.2.0/src/modal/mod.rs:36:20: 36:28}: Into<leptos::Callback<()>>`
     |
     = note: required because it appears within the type `&'static (dyn Subscriber + Send + std::marker::Sync + 'static)`
note: required because it appears within the type `tracing_core::dispatcher::Kind<Arc<(dyn Subscriber + Send + std::marker::Sync + 'static)>>`
    --> /home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tracing-core-0.1.32/src/dispatcher.rs:183:6
     |
183  | enum Kind<T> {
     |      ^^^^
note: required because it appears within the type `Dispatch`
    --> /home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tracing-core-0.1.32/src/dispatcher.rs:155:12
     |
155  | pub struct Dispatch {
     |            ^^^^^^^^
note: required because it appears within the type `span::Inner`
    --> /home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tracing-0.1.40/src/span.rs:366:19
     |
366  | pub(crate) struct Inner {
     |                   ^^^^^
note: required because it appears within the type `std::option::Option<span::Inner>`
    --> /nix/store/sm9z36byql5p8kq9654hnzgbd3f9p230-rust-default-1.78.0-nightly-2024-02-13/lib/rustlib/src/rust/library/core/src/option.rs:571:10
     |
571  | pub enum Option<T> {
     |          ^^^^^^
note: required because it appears within the type `leptos::tracing::Span`
    --> /home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tracing-0.1.40/src/span.rs:348:12
     |
348  | pub struct Span {
     |            ^^^^
note: required because it appears within the type `leptos::HtmlElement<leptos::html::Div>`
    --> /home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/leptos_dom-0.6.6/src/html.rs:291:16
     |
291  |     pub struct HtmlElement<El: ElementDescriptor> {
     |                ^^^^^^^^^^^
note: required because it appears within the type `std::option::Option<leptos::HtmlElement<leptos::html::Div>>`
    --> /nix/store/sm9z36byql5p8kq9654hnzgbd3f9p230-rust-default-1.78.0-nightly-2024-02-13/lib/rustlib/src/rust/library/core/src/option.rs:571:10
     |
571  | pub enum Option<T> {
     |          ^^^^^^
note: required because it appears within the type `PhantomData<std::option::Option<leptos::HtmlElement<leptos::html::Div>>>`
    --> /nix/store/sm9z36byql5p8kq9654hnzgbd3f9p230-rust-default-1.78.0-nightly-2024-02-13/lib/rustlib/src/rust/library/core/src/marker.rs:740:12
     |
740  | pub struct PhantomData<T: ?Sized>;
     |            ^^^^^^^^^^^
note: required because it appears within the type `leptos::RwSignal<std::option::Option<leptos::HtmlElement<leptos::html::Div>>>`
    --> /home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/leptos_reactive-0.6.6/src/signal.rs:1203:12
     |
1203 | pub struct RwSignal<T>
     |            ^^^^^^^^
note: required because it appears within the type `leptos::NodeRef<leptos::html::Div>`
    --> /home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/leptos_dom-0.6.6/src/node_ref.rs:37:12
     |
37   | pub struct NodeRef<T: ElementDescriptor + 'static>(
     |            ^^^^^^^
note: required because it's used within this closure
    --> /home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/thaw-0.2.0/src/modal/mod.rs:36:20
     |
36   |     let on_enter = move |_| {
     |                    ^^^^^^^^
     = note: required for `leptos::Callback<()>` to implement `From<{closure@/home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/thaw-0.2.0/src/modal/mod.rs:36:20: 36:28}>`
     = note: required for `{closure@/home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/thaw-0.2.0/src/modal/mod.rs:36:20: 36:28}` to implement `Into<leptos::Callback<()>>`
note: required by a bound in `CSSTransitionPropsBuilder::<T, CF, IV, (__node_ref, __show, __name, (), __on_after_leave, __children)>::on_enter`
    --> /home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/thaw-0.2.0/src/components/css_transition/mod.rs:4:1
     |
4    | #[component]
     | ^^^^^^^^^^^^ required by this bound in `CSSTransitionPropsBuilder::<T, CF, IV, (__node_ref, __show, __name, (), __on_after_leave, __children)>::on_enter`
...
9    |     #[prop(optional, into)] on_enter: Option<Callback<()>>,
     |                             -------- required by a bound in this associated function
     = note: this error originates in the derive macro `::leptos::typed_builder_macro::TypedBuilder` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0277]: the trait bound `(dyn Callsite + 'static): callback::NotRawCallback` is not satisfied in `{closure@/home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/thaw-0.2.0/src/modal/mod.rs:36:20: 36:28}`
    --> /home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/thaw-0.2.0/src/modal/mod.rs:56:5
     |
36   |       let on_enter = move |_| {
     |                      -------- within this `{closure@/home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/thaw-0.2.0/src/modal/mod.rs:36:20: 36:28}`
...
56   | /     view! {
57   | |         <Teleport>
58   | |             <div
59   | |                 class="thaw-modal-container"
...    |
80   | |                     on_enter
     | |                     --------
     | |                     |
     | |                     this tail expression is of type `{closure@mod.rs:36:20}`
     | |                     required by a bound introduced by this call
...    |
114  | |         </Teleport>
115  | |     }
     | |_____^ within `{closure@/home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/thaw-0.2.0/src/modal/mod.rs:36:20: 36:28}`, the trait `callback::NotRawCallback` is not implemented for `(dyn Callsite + 'static)`, which is required by `{closure@/home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/thaw-0.2.0/src/modal/mod.rs:36:20: 36:28}: Into<leptos::Callback<()>>`
     |
     = note: required because it appears within the type `&'static (dyn Callsite + 'static)`
note: required because it appears within the type `Identifier`
    --> /home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tracing-core-0.1.32/src/callsite.rs:179:12
     |
179  | pub struct Identifier(
     |            ^^^^^^^^^^
note: required because it appears within the type `FieldSet`
    --> /home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tracing-core-0.1.32/src/field.rs:158:12
     |
158  | pub struct FieldSet {
     |            ^^^^^^^^
note: required because it appears within the type `leptos::tracing::Metadata<'static>`
    --> /home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tracing-core-0.1.32/src/metadata.rs:57:12
     |
57   | pub struct Metadata<'a> {
     |            ^^^^^^^^
     = note: required because it appears within the type `&'static leptos::tracing::Metadata<'static>`
note: required because it appears within the type `std::option::Option<&'static leptos::tracing::Metadata<'static>>`
    --> /nix/store/sm9z36byql5p8kq9654hnzgbd3f9p230-rust-default-1.78.0-nightly-2024-02-13/lib/rustlib/src/rust/library/core/src/option.rs:571:10
     |
571  | pub enum Option<T> {
     |          ^^^^^^
note: required because it appears within the type `leptos::tracing::Span`
    --> /home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tracing-0.1.40/src/span.rs:348:12
     |
348  | pub struct Span {
     |            ^^^^
note: required because it appears within the type `leptos::HtmlElement<leptos::html::Div>`
    --> /home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/leptos_dom-0.6.6/src/html.rs:291:16
     |
291  |     pub struct HtmlElement<El: ElementDescriptor> {
     |                ^^^^^^^^^^^
note: required because it appears within the type `std::option::Option<leptos::HtmlElement<leptos::html::Div>>`
    --> /nix/store/sm9z36byql5p8kq9654hnzgbd3f9p230-rust-default-1.78.0-nightly-2024-02-13/lib/rustlib/src/rust/library/core/src/option.rs:571:10
     |
571  | pub enum Option<T> {
     |          ^^^^^^
note: required because it appears within the type `PhantomData<std::option::Option<leptos::HtmlElement<leptos::html::Div>>>`
    --> /nix/store/sm9z36byql5p8kq9654hnzgbd3f9p230-rust-default-1.78.0-nightly-2024-02-13/lib/rustlib/src/rust/library/core/src/marker.rs:740:12
     |
740  | pub struct PhantomData<T: ?Sized>;
     |            ^^^^^^^^^^^
note: required because it appears within the type `leptos::RwSignal<std::option::Option<leptos::HtmlElement<leptos::html::Div>>>`
    --> /home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/leptos_reactive-0.6.6/src/signal.rs:1203:12
     |
1203 | pub struct RwSignal<T>
     |            ^^^^^^^^
note: required because it appears within the type `leptos::NodeRef<leptos::html::Div>`
    --> /home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/leptos_dom-0.6.6/src/node_ref.rs:37:12
     |
37   | pub struct NodeRef<T: ElementDescriptor + 'static>(
     |            ^^^^^^^
note: required because it's used within this closure
    --> /home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/thaw-0.2.0/src/modal/mod.rs:36:20
     |
36   |     let on_enter = move |_| {
     |                    ^^^^^^^^
     = note: required for `leptos::Callback<()>` to implement `From<{closure@/home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/thaw-0.2.0/src/modal/mod.rs:36:20: 36:28}>`
     = note: required for `{closure@/home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/thaw-0.2.0/src/modal/mod.rs:36:20: 36:28}` to implement `Into<leptos::Callback<()>>`
note: required by a bound in `CSSTransitionPropsBuilder::<T, CF, IV, (__node_ref, __show, __name, (), __on_after_leave, __children)>::on_enter`
    --> /home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/thaw-0.2.0/src/components/css_transition/mod.rs:4:1
     |
4    | #[component]
     | ^^^^^^^^^^^^ required by this bound in `CSSTransitionPropsBuilder::<T, CF, IV, (__node_ref, __show, __name, (), __on_after_leave, __children)>::on_enter`
...
9    |     #[prop(optional, into)] on_enter: Option<Callback<()>>,
     |                             -------- required by a bound in this associated function
     = note: this error originates in the derive macro `::leptos::typed_builder_macro::TypedBuilder` (in Nightly builds, run with -Z macro-backtrace for more info)

For more information about this error, try `rustc --explain E0277`.
error: could not compile `thaw` (lib) due to 2 previous errors
      Notify watching paths style, public, src
^C      Leptos ctrl-c received

[user@host:~/rust/leptos-ssr-thaw]$ 

Thanks in advance.

luoxiaozero commented 4 months ago

I have also tried thaw without extra features - thaw = "0.2.0"

That produces some other error:

thaw updates to 0.2.1. Try again.

garvanwalshe commented 4 months ago

I tried the same on MacOS with both Actix and Axum (and feature=ssr). Nightly rust. It produced the same HTMLElement error as above.

My cargo.toml for the Actix version follows. This minimal example includes only a single component in the HomePage component of app.rs.

[package]
name = "ld-actix"
version = "0.1.0"
edition = "2021"

[lib]
crate-type = ["cdylib", "rlib"]

[dependencies]
actix-files = { version = "0.6", optional = true }
actix-web = { version = "4", optional = true, features = ["macros"] }
console_error_panic_hook = "0.1"
http = { version = "0.2", optional = true }
leptos = { version = "0.6", features = ["nightly"] }
leptos_meta = { version = "0.6", features = ["nightly"] }
leptos_actix = { version = "0.6", optional = true }
leptos_router = { version = "0.6", features = ["nightly"] }
wasm-bindgen = "^0.2.89"
thaw = "0.2.1"

[features]
csr = ["leptos/csr", "leptos_meta/csr", "leptos_router/csr"]
hydrate = ["leptos/hydrate", "leptos_meta/hydrate", "leptos_router/hydrate"]
ssr = [
  "dep:actix-files",
  "dep:actix-web",
  "dep:leptos_actix",
  "leptos/ssr",
  "leptos_meta/ssr",
  "leptos_router/ssr",
]

# Defines a size-optimized profile for the WASM bundle in release mode
[profile.wasm-release]
inherits = "release"
opt-level = 'z'
lto = true
codegen-units = 1
panic = "abort"

[package.metadata.leptos]
# The name used by wasm-bindgen/cargo-leptos for the JS/WASM bundle. Defaults to the crate name   
output-name = "ld-actix"
# The site root folder is where cargo-leptos generate all output. WARNING: all content of this folder will be erased on a rebuild. Use it in your server setup.
site-root = "target/site"
# The site-root relative folder where all compiled output (JS, WASM and CSS) is written
# Defaults to pkg   
site-pkg-dir = "pkg"
# [Optional] The source CSS file. If it ends with .sass or .scss then it will be compiled by dart-sass into CSS. The CSS is optimized by Lightning CSS before being written to <site-root>/<site-pkg>/app.css
style-file = "style/main.scss"
# Assets source dir. All files found here will be copied and synchronized to site-root.
# The assets-dir cannot have a sub directory with the same name/path as site-pkg-dir.
#
# Optional. Env: LEPTOS_ASSETS_DIR.
assets-dir = "assets"
# The IP and port (ex: 127.0.0.1:3000) where the server serves the content. Use it in your server setup.
site-addr = "127.0.0.1:3000"
# The port to use for automatic reload monitoring
reload-port = 3001
# [Optional] Command to use when running end2end tests. It will run in the end2end dir.
#   [Windows] for non-WSL use "npx.cmd playwright test"
#   This binary name can be checked in Powershell with Get-Command npx
end2end-cmd = "npx playwright test"
end2end-dir = "end2end"
#  The browserlist query used for optimizing the CSS.
browserquery = "defaults"
# Set by cargo-leptos watch when building with that tool. Controls whether autoreload JS will be included in the head
watch = false
# The environment Leptos will run in, usually either "DEV" or "PROD"
env = "DEV"
# The features to use when compiling the bin target
#
# Optional. Can be over-ridden with the command line parameter --bin-features
bin-features = ["ssr"]

# If the --no-default-features flag should be used when compiling the bin target
#
# Optional. Defaults to false.
bin-default-features = false

# The features to use when compiling the lib target
#
# Optional. Can be over-ridden with the command line parameter --lib-features
lib-features = ["hydrate"]

# If the --no-default-features flag should be used when compiling the lib target
#
# Optional. Defaults to false.
lib-default-features = false

# The profile to use for the lib target when compiling for release
#
# Optional. Defaults to "release".
lib-profile-release = "wasm-release"
luoxiaozero commented 4 months ago

Change the configuration to:

thaw = "0.2.1"

[features]
csr = ["leptos/csr", "leptos_meta/csr", "leptos_router/csr", "thaw/csr"]
hydrate = ["leptos/hydrate", "leptos_meta/hydrate", "leptos_router/hydrate", "thaw/hydrate"]
ssr = [
  "dep:actix-files",
  "dep:actix-web",
  "dep:leptos_actix",
  "leptos/ssr",
  "leptos_meta/ssr",
  "leptos_router/ssr",
  "thaw/ssr"
]
garvanwalshe commented 4 months ago

Thank you for getting back so quickly. That works for me on both actix and Axum!

tdrozdowski commented 2 months ago

Hate to say it - but getting the same thing again with 0.3.0-beta and Leptos 0.6.11 (I can't seem to downgrade to 0.6.10). The suggestions above don't seem to help. Do we need a new build against 0.6.11?

luoxiaozero commented 2 months ago

Hi @tdrozdowski , I tried both 0.6.11 and 0.3.0-beta in my local area with no problems. Can you provide your Cargo.toml?

tdrozdowski commented 2 months ago
workspace = { members = [ "commons", "engmgr_dashboard_tests", "jira_client","team_assessment"] }
[package]
name = "engmgr-dashboard"
version = "0.1.0"
edition = "2021"

[lib]
crate-type = ["cdylib", "rlib"]

[dependencies]
axum = { version = "0.7", optional = true, features = ["macros"]}
chrono = "0.4"
console_error_panic_hook = "0.1"
console_log = "1"
leptos = { version = "0.6", features = ["nightly"] }
leptos_axum = { version = "0.6", optional = true }
leptos_meta = { version = "0.6", features = ["nightly"] }
leptos_router = { version = "0.6", features = ["nightly"] }
log = "0.4"
serde = {version = "1.0", features = ["derive"]}
simple_logger = "4"
tokio = { version = "1", optional = true }
tower = { version = "0.4", optional = true }
tower-http = { version = "0.5", features = ["fs"], optional = true }
wasm-bindgen = "^0.2.90"
thiserror = "1"
tracing = { version = "0.1", optional = true }
http = "1"
team_assessment = { path = "team_assessment", optional = true}

commons = { path = "./commons"}
uuid = { version = "1.7.0", features = ["v4"] }
thaw = "0.3.0-beta"

[features]
default = ["ssr"]
hydrate = ["leptos/hydrate", "leptos_meta/hydrate", "leptos_router/hydrate", "thaw/hydrate"]
ssr = [
    "dep:axum",
    "dep:tokio",
    "dep:tower",
    "dep:tower-http",
    "dep:leptos_axum",
    "leptos/ssr",
    "leptos_meta/ssr",
    "leptos_router/ssr",
    "thaw/ssr",
    "dep:team_assessment",
]

[package.metadata.cargo-all-features]
denylist = ["axum", "tower", "tower-http", "tokio", "sqlx", "leptos_axum"]
skip_feature_sets = [["ssr", "hydrate"]]

# Defines a size-optimized profile for the WASM bundle in release mode
[profile.wasm-release]
inherits = "release"
opt-level = 'z'
lto = true
codegen-units = 1
panic = "abort"

[package.metadata.leptos]
# The name used by wasm-bindgen/cargo-leptos for the JS/WASM bundle. Defaults to the crate name
output-name = "engmgr-dashboard"

# The site root folder is where cargo-leptos generate all output. WARNING: all content of this folder will be erased on a rebuild. Use it in your server setup.
site-root = "target/site"

# The site-root relative folder where all compiled output (JS, WASM and CSS) is written
# Defaults to pkg
site-pkg-dir = "pkg"

# [Optional] The source CSS file. If it ends with .sass or .scss then it will be compiled by dart-sass into CSS. The CSS is optimized by Lightning CSS before being written to <site-root>/<site-pkg>/app.css
#style-file = "style/main.scss"
# Tailwind input file; activates the tailwind build
tailwind-input-file = "style/tailwind.css"

# Assets source dir. All files found here will be copied and synchronized to site-root.
# The assets-dir cannot have a sub directory with the same name/path as site-pkg-dir.
#
# Optional. Env: LEPTOS_ASSETS_DIR.
assets-dir = "public"

# The IP and port (ex: 127.0.0.1:3000) where the server serves the content. Use it in your server setup.
site-addr = "127.0.0.1:3000"

# The port to use for automatic reload monitoring
reload-port = 3001

# [Optional] Command to use when running end2end tests. It will run in the end2end dir.
#   [Windows] for non-WSL use "npx.cmd playwright test"
#   This binary name can be checked in Powershell with Get-Command npx
end2end-cmd = "npx playwright test"
end2end-dir = "end2end"

#  The browserlist query used for optimizing the CSS.
browserquery = "defaults"

# Set by cargo-leptos watch when building with that tool. Controls whether autoreload JS will be included in the head
watch = false

# The environment Leptos will run in, usually either "DEV" or "PROD"
env = "DEV"

# The features to use when compiling the bin target
#
# Optional. Can be over-ridden with the command line parameter --bin-features
bin-features = ["ssr"]

# If the --no-default-features flag should be used when compiling the bin target
#
# Optional. Defaults to false.
bin-default-features = false

# The features to use when compiling the lib target
#
# Optional. Can be over-ridden with the command line parameter --lib-features
lib-features = ["hydrate"]

# If the --no-default-features flag should be used when compiling the lib target
#
# Optional. Defaults to false.
lib-default-features = false

# The profile to use for the lib target when compiling for release
#
# Optional. Defaults to "release".
lib-profile-release = "wasm-release"
luoxiaozero commented 2 months ago
team_assessment = { path = "team_assessment", optional = true}

commons = { path = "./commons"}

Are there leptos dependencies in team_assessment and commons libraries? If so, provide their Cargo.toml.


One of the reasons for the above problem is that multiple csr, ssr, and hydrate are opened at the same time in the project.

tdrozdowski commented 2 months ago

No - one of the reasons I split those out was to avoid complications with leptos and ssr during build time. So they both do not have any leptos dependencies.

luoxiaozero commented 2 months ago

Strange, can you provide the error log and run command?

Then execute the following rustup default.

tdrozdowski commented 2 months ago

So - I got around it. Looks like the core of it was that I needed to update my nightly rust binaries so that Axum 0.7.5 would build (uses diagnostic macro); once that built (which I missed in previous attempts) seems like everything else fell into place. Rust newbie and still feeling my way around. Apologies for wasting your time here. Appreciate the prompt response. Looking forward to using these components too. :)