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

Unable to Run Leptonic with Leptos-Axum on NixOS #38

Open
disbolog opened this issue Feb 13, 2024 · 4 comments
Open

Unable to Run Leptonic with Leptos-Axum on NixOS #38

disbolog opened this issue Feb 13, 2024 · 4 comments

Comments

@disbolog
Copy link

Hello,

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

What I have done is used the latest leptos template with cargo leptos new and then rsync -a the contents of src, style, and public of https://github.com/lpotthast/leptonic-template-ssr to leptos project dir.

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

error[E0119]: conflicting implementations of trait `From<leptos::Callback<_>>` for type `Out<_>`
   --> /home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/leptonic-0.5.0/src/lib.rs:382:1
    |
370 | impl<T: 'static, F: Fn(T) + 'static> From<F> for Out<T> {
    | ------------------------------------------------------- first implementation here
...
382 | impl<O: 'static> From<Callback<O, ()>> for Out<O> {
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `Out<_>`

error[E0119]: conflicting implementations of trait `From<leptos::WriteSignal<_>>` for type `Out<_>`
   --> /home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/leptonic-0.5.0/src/lib.rs:388:1
    |
370 | impl<T: 'static, F: Fn(T) + 'static> From<F> for Out<T> {
    | ------------------------------------------------------- first implementation here
...
388 | impl<O: 'static> From<WriteSignal<O>> for Out<O> {
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `Out<_>`

error[E0277]: the trait bound `O: leptos::callback::NotRawCallback` is not satisfied in `{closure@/home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/leptonic-0.5.0/src/select.rs:763:49: 763:69}`
   --> /home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/leptonic-0.5.0/src/select.rs:756:25
    |
756 | /                          view! {
757 | |                              <leptonic-select-option>
758 | |                                  <Chip
759 | |                                      color=ChipColor::Secondary
...   |
763 | |                                      dismissible=move |e: MouseEvent| {
    | |                                      ----------- --------------------
    | |                                      |           |
    | | _____________________________________|___________within this `{closure@/home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/leptonic-0.5.0/src/select.rs:763:49: 763:69}`
    | ||                                     |
    | ||                                     required by a bound introduced by this call
764 | ||                                         e.stop_propagation();
765 | ||                                         deselect.get_value().call(clone.clone());
766 | ||                                     }>
    | ||_____________________________________- this tail expression is of type `{[email protected]:763:49}`
...   |
769 | |                              </leptonic-select-option>
770 | |                          }}).collect_view()
    | |__________________________^ within `{closure@/home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/leptonic-0.5.0/src/select.rs:763:49: 763:69}`, the trait `leptos::callback::NotRawCallback` is not implemented for `O`, which is required by `{closure@/home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/leptonic-0.5.0/src/select.rs:763:49: 763:69}: Into<leptos::Callback<MouseEvent>>`
    |
note: required because it's used within this closure
   --> /home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/leptonic-0.5.0/src/select.rs:763:49
    |
763 | ...                   dismissible=move |e: MouseEvent| {
    |                                   ^^^^^^^^^^^^^^^^^^^^
    = note: required for `leptos::Callback<MouseEvent>` to implement `From<{closure@/home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/leptonic-0.5.0/src/select.rs:763:49: 763:69}>`
    = note: required for `{closure@/home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/leptonic-0.5.0/src/select.rs:763:49: 763:69}` to implement `Into<leptos::Callback<MouseEvent>>`
note: required by a bound in `ChipPropsBuilder::<(__color, (), __id, __class, __style, __children)>::dismissible`
   --> /home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/leptonic-0.5.0/src/chip.rs:38:1
    |
38  | #[component]
    | ^^^^^^^^^^^^ required by this bound in `ChipPropsBuilder::<(__color, (), __id, __class, __style, __children)>::dismissible`
...
41  |     #[prop(into, optional)] dismissible: Option<Callback<MouseEvent>>,
    |                             ----------- 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)
help: consider further restricting this bound
    |
585 |     O: SelectOption + PartialOrd + Ord + 'static + leptos::callback::NotRawCallback,
    |                                                  ++++++++++++++++++++++++++++++++++

error[E0277]: the trait bound `leptos::Callback<O>: leptos::callback::NotRawCallback` is not satisfied in `{closure@/home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/leptonic-0.5.0/src/select.rs:763:49: 763:69}`
   --> /home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/leptonic-0.5.0/src/select.rs:756:25
    |
756 | /                          view! {
757 | |                              <leptonic-select-option>
758 | |                                  <Chip
759 | |                                      color=ChipColor::Secondary
...   |
763 | |                                      dismissible=move |e: MouseEvent| {
    | |                                      ----------- --------------------
    | |                                      |           |
    | | _____________________________________|___________within this `{closure@/home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/leptonic-0.5.0/src/select.rs:763:49: 763:69}`
    | ||                                     |
    | ||                                     required by a bound introduced by this call
764 | ||                                         e.stop_propagation();
765 | ||                                         deselect.get_value().call(clone.clone());
766 | ||                                     }>
    | ||_____________________________________- this tail expression is of type `{[email protected]:763:49}`
...   |
769 | |                              </leptonic-select-option>
770 | |                          }}).collect_view()
    | |__________________________^ within `{closure@/home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/leptonic-0.5.0/src/select.rs:763:49: 763:69}`, the trait `leptos::callback::NotRawCallback` is not implemented for `leptos::Callback<O>`, which is required by `{closure@/home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/leptonic-0.5.0/src/select.rs:763:49: 763:69}: Into<leptos::Callback<MouseEvent>>`
    |
note: required because it appears within the type `PhantomData<leptos::Callback<O>>`
   --> /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::StoredValue<leptos::Callback<O>>`
   --> /home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/leptos_reactive-0.6.5/src/stored_value.rs:24:12
    |
24  | pub struct StoredValue<T>
    |            ^^^^^^^^^^^
note: required because it's used within this closure
   --> /home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/leptonic-0.5.0/src/select.rs:763:49
    |
763 | ...                   dismissible=move |e: MouseEvent| {
    |                                   ^^^^^^^^^^^^^^^^^^^^
    = note: required for `leptos::Callback<MouseEvent>` to implement `From<{closure@/home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/leptonic-0.5.0/src/select.rs:763:49: 763:69}>`
    = note: required for `{closure@/home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/leptonic-0.5.0/src/select.rs:763:49: 763:69}` to implement `Into<leptos::Callback<MouseEvent>>`
note: required by a bound in `ChipPropsBuilder::<(__color, (), __id, __class, __style, __children)>::dismissible`
   --> /home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/leptonic-0.5.0/src/chip.rs:38:1
    |
38  | #[component]
    | ^^^^^^^^^^^^ required by this bound in `ChipPropsBuilder::<(__color, (), __id, __class, __style, __children)>::dismissible`
...
41  |     #[prop(into, optional)] dismissible: Option<Callback<MouseEvent>>,
    |                             ----------- 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)

Some errors have detailed explanations: E0119, E0277.
For more information about an error, try `rustc --explain E0119`.
error: could not compile `leptonic` (lib) due to 4 previous errors

And here is the Cargo.toml:

[package]
name = "leptos-proper"
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"
leptonic = "0.5.0"

[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-proper"

# 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"

Thanks in advance.

@disbolog
Copy link
Author

disbolog commented Feb 13, 2024

Also created a discussion at the Leptos repo: leptos-rs/leptos#2300

@garvanwalshe
Copy link

I get the same error running on Mac OS with both Axum and Actix.

@shadr
Copy link

shadr commented Mar 25, 2024

I had the same problem, I'm also on NixOS. Adding leptonic features and/or updating leptonic version to the latest commit fixed it for me.
Try to enable leptonic/ssr and leptonic/hydrate features when compiling server and frontend respectively.

[features]
ssr = [
    # ...
    "leptonic/ssr"
]
hydrate = [
    # ...
    "leptonic/hydrate"
]

If after this, compiler still spits out an error, try to change leptonic version to main branch and enable nightly feature if you are using the nightly toolchain

leptonic = { git = "https://github.com/lpotthast/leptonic",  features = ["nightly"] }

Note: leptonic/nightly not available on 0.5 version so that's why I tried to use latest version from github rather than from crates.io, if when you are reading this 0.6 came out then I think you will be able to use that instead of fetching from github

@jccampagne
Copy link

I had the same problem, I'm also on NixOS. Adding leptonic features and/or updating leptonic version to the latest commit fixed it for me. Try to enable leptonic/ssr and leptonic/hydrate features when compiling server and frontend respectively.

Thanks for the tips. It helped.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants