oscartbeaumont / rspc

A framework for building typesafe web backends in Rust
https://rspc.dev
MIT License
1.11k stars 51 forks source link

create-rspc-app build error with Axum and Prisma #159

Open not-ani opened 1 year ago

not-ani commented 1 year ago

Hello :wave:

I was trying out rspc with create-rspc-app and am getting this error when I run cargo build

error[E0583]: file not found for module `prisma`
  --> api/src/main.rs:10:1
   |
10 | mod prisma;
   | ^^^^^^^^^^^
   |
   = help: to create the module `prisma`, create file "api/src/prisma.rs" or "api/src/prisma/mod.rs"

error[E0412]: cannot find type `PrismaClient` in module `prisma`
 --> api/src/api/mod.rs:9:29
  |
9 |     pub client: Arc<prisma::PrismaClient>,
  |                             ^^^^^^^^^^^^ not found in `prisma`

error[E0412]: cannot find type `PrismaClient` in module `prisma`
  --> api/src/main.rs:12:31
   |
12 | fn router(client: Arc<prisma::PrismaClient>) -> axum::Router {
   |                               ^^^^^^^^^^^^ not found in `prisma`

error[E0425]: cannot find function `new_client` in module `prisma`
  --> api/src/main.rs:35:35
   |
35 |     let client = Arc::new(prisma::new_client().await.unwrap());
   |                                   ^^^^^^^^^^ not found in `prisma`

error[E0271]: type mismatch resolving `<Router as Service<Request<Body>>>::Response == Response<UnsyncBoxBody<Bytes, Error>>`
   --> api/src/main.rs:19:13
    |
17  |           .route(
    |            ----- required by a bound introduced by this call
18  |               "/rspc/:id",
19  | /             router
20  | |                 .endpoint(move || api::Ctx {
21  | |                     client: Arc::clone(&client),
22  | |                 })
23  | |                 .axum(),
    | |_______________________^ expected struct `axum::Error`, found struct `axum_core::error::Error`
    |
    = note: struct `axum_core::error::Error` and struct `axum::Error` have similar names, but are actually distinct types
note: struct `axum_core::error::Error` is defined in crate `axum_core`
   --> /home/blue/.cargo/registry/src/github.com-1ecc6299db9ec823/axum-core-0.3.3/src/error.rs:6:1
    |
6   | pub struct Error {
    | ^^^^^^^^^^^^^^^^
note: struct `axum::Error` is defined in crate `axum_core`
   --> /home/blue/.cargo/registry/src/github.com-1ecc6299db9ec823/axum-core-0.2.9/src/error.rs:6:1
    |
6   | pub struct Error {
    | ^^^^^^^^^^^^^^^^
    = note: perhaps two different versions of crate `axum_core` are being used?
note: required by a bound in `axum::Router::<B>::route`
   --> /home/blue/.cargo/registry/src/github.com-1ecc6299db9ec823/axum-0.5.17/src/routing/mod.rs:127:32
    |
127 |         T: Service<Request<B>, Response = Response, Error = Infallible> + Clone + Send + 'static,
    |                                ^^^^^^^^^^^^^^^^^^^ required by this bound in `Router::<B>::route`

Some errors have detailed explanations: E0271, E0412, E0425, E0583.
For more information about an error, try `rustc --explain E0271`.
error: could not compile `rspc` due to 5 previous errors

I am very new to rust, I apologize if I could have done something to fix it myself.

erwijet commented 5 months ago

Try making sure you've run $ cargo run --bin primsa-cli -- generate dev from the prisma/ directory to generate the primsa.rs file. Note you will need to update the .env file with the correct DATABASE_URL prior to this.