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

Doesnt compile problems with serveDIR/servodeExt #51

Closed
NicTanghe opened this issue Sep 30, 2024 · 4 comments
Closed

Doesnt compile problems with serveDIR/servodeExt #51

NicTanghe opened this issue Sep 30, 2024 · 4 comments

Comments

@NicTanghe
Copy link

Ok so all the way back the first time i ran it worked and if i wanted to use this i just copied that one over becouse:

the default one doesn't compile:

these 2 are trowing errors.

use crate::app::App;
use tower::ServiceExt;

IDE:
1 : trait service servriceEXT which provides one-shot is implemented but not in scope

testimg on  main [?] is  v0.1.0 via  v1.82.0-nightly  cargo leptos build --release
    Finished `wasm-release` profile [optimized] target(s) in 0.16s
       Cargo finished cargo build --package=testimg --lib --target-dir=/home/fucker/dev/leptos/testimg/target/front --target=wasm32-unknown-unknown --no-default-features --features=
hydrate --profile=wasm-release
       Front compiling WASM
[swc_ecma_transforms_optimization] tree-shaker; pass=0
   Compiling testimg v0.1.0 (/home/fucker/dev/leptos/testimg)
error[E0432]: unresolved import `tower::ServiceExt`
   --> src/fileserv.rs:10:5
    |
10  | use tower::ServiceExt;
    |     ^^^^^^^^^^^^^^^^^ no `ServiceExt` in the root
    |
note: found an item that was configured out
   --> /home/fucker/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tower-0.4.13/src/lib.rs:223:34
    |
223 | pub use self::util::{service_fn, ServiceExt};
    |                                  ^^^^^^^^^^
note: the item is gated behind the `util` feature
   --> /home/fucker/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tower-0.4.13/src/lib.rs:220:7
    |
220 | #[cfg(feature = "util")]
    |       ^^^^^^^^^^^^^^^^
help: a similar name exists in the module
    |
10  | use tower::Service;
    |            ~~~~~~~
help: consider importing this trait instead
    |
10  | use axum::ServiceExt;
    |     ~~~~~~~~~~~~~~~~

error[E0599]: no method named `oneshot` found for struct `ServeDir` in the current scope
  --> src/fileserv.rs:51:10
   |
48 |       match ServeDir::new(root)
   |  ___________-
49 | |         .precompressed_gzip()
50 | |         .precompressed_br()
51 | |         .oneshot(request)
   | |_________-^^^^^^^
   |
  ::: /home/fucker/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tower-0.5.1/src/util/mod.rs:85:8
   |
85 |       fn oneshot(self, req: Request) -> Oneshot<Self, Request>
   |          ------- the method is available for `ServeDir` here
   |
   = help: items from traits can only be used if the trait is in scope
help: there is a method `ready_oneshot` with a similar name, but with different arguments
  --> /home/fucker/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tower-0.5.1/src/util/mod.rs:77:5
   |
77 | /     fn ready_oneshot(self) -> ReadyOneshot<Self, Request>
78 | |     where
79 | |         Self: Sized,
   | |____________________^
help: trait `ServiceExt` which provides `oneshot` is implemented but not in scope; perhaps you want to import it
   |
1  + use tower::util::ServiceExt;
   |
@NicTanghe
Copy link
Author

Thats probably fixed By this
https://github.com/leptos-rs/start-axum/pull/47

@NicTanghe
Copy link
Author

I apllied the changes in #47 and I`m getting the same error

@georgethoppil
Copy link

👋 New to leptos here and I am running into the same issue as well.
I added the util features in cargo.toml

tower = { version = "0.4", optional = true, features = ["util"] }

and in fileserve.rs, I change the import to:

use tower::util::ServiceExt;

seems to compile for me

@gbj
Copy link
Contributor

gbj commented Sep 30, 2024

Looks like tower maybe made a breaking change in a patch release, which is a bummer.

@georgethoppil is correct that it just requires add , features = ["util"] to tower in Cargo.toml -- even with only that change it compiles.

@gbj gbj closed this as completed in d688fe7 Sep 30, 2024
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

3 participants