specta-rs / rspc

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

specta: expected path. Eg. `String` or `std::string::String` #258

Closed gustawdaniel closed 7 months ago

gustawdaniel commented 8 months ago

I follow quick start steps:

https://www.rspc.dev/quickstart

and getting error:

cargo build         
   Compiling specta v2.0.0-rc.1
error: specta: expected path. Eg. `String` or `std::string::String`
   --> /home/daniel/.cargo/registry/src/index.crates.io-6f17d22bba15001f/specta-2.0.0-rc.1/src/type/impls.rs:193:19
    |
193 | #[specta(remote = "SystemTime", crate = "crate", export = false)]
    |                   ^^^^^^^^^^^^

error: specta: expected path. Eg. `String` or `std::string::String`
   --> /home/daniel/.cargo/registry/src/index.crates.io-6f17d22bba15001f/specta-2.0.0-rc.1/src/type/impls.rs:201:19
    |
201 | #[specta(remote = "Duration", crate = "crate", export = false)]
    |                   ^^^^^^^^^^

error[E0432]: unresolved import `specta_macros::RSPCType`
   --> /home/daniel/.cargo/registry/src/index.crates.io-6f17d22bba15001f/specta-2.0.0-rc.1/src/lib.rs:112:9
    |
112 | pub use specta_macros::RSPCType;
    |         ^^^^^^^^^^^^^^^^^^^^^^^ no `RSPCType` in the root

For more information about this error, try `rustc --explain E0432`.
error: could not compile `specta` (lib) due to 3 previous errors

Exact steps to reproduce

cargo new rspc-demo

go to catalog

cd rspc-demo

Now cargo run works as we expect

cargo run                         
   Compiling rspc-demo v0.1.0 (/home/daniel/pro/rspc-demo)
    Finished dev [unoptimized + debuginfo] target(s) in 0.11s
     Running `target/debug/rspc-demo`
Hello, world!

Let's add rspc

echo 'rspc = "=1.0.0-rc.5"' >> Cargo.toml 

we can check it

cat Cargo.toml
[package]
name = "rspc-demo"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
rspc = "=1.0.0-rc.5"

and we have error that I mentioned

cargo run     
    Updating crates.io index
   Compiling proc-macro2 v1.0.78
   Compiling unicode-ident v1.0.12
   Compiling autocfg v1.1.0
   Compiling serde v1.0.197
   Compiling futures-sink v0.3.30
   Compiling syn v1.0.109
   Compiling futures-core v0.3.30
   Compiling thiserror v1.0.57
   Compiling pin-utils v0.1.0
   Compiling pin-project-lite v0.2.13
   Compiling futures-task v0.3.30
   Compiling serde_json v1.0.114
   Compiling paste v1.0.14
   Compiling itoa v1.0.10
   Compiling Inflector v0.11.4
   Compiling ryu v1.0.17
   Compiling litrs v0.4.1
   Compiling futures-io v0.3.30
   Compiling indoc v1.0.9
   Compiling once_cell v1.19.0
   Compiling futures-channel v0.3.30
   Compiling slab v0.4.9
   Compiling document-features v0.2.8
   Compiling quote v1.0.35
   Compiling syn v2.0.52
   Compiling specta-macros v2.0.0-rc.7
   Compiling futures-macro v0.3.30
   Compiling serde_derive v1.0.197
   Compiling thiserror-impl v1.0.57
   Compiling futures-util v0.3.30
   Compiling streamunordered v0.5.3
   Compiling futures v0.3.30
   Compiling specta v2.0.0-rc.1
error: specta: expected path. Eg. `String` or `std::string::String`
   --> /home/daniel/.cargo/registry/src/index.crates.io-6f17d22bba15001f/specta-2.0.0-rc.1/src/type/impls.rs:193:19
    |
193 | #[specta(remote = "SystemTime", crate = "crate", export = false)]
    |                   ^^^^^^^^^^^^

error: specta: expected path. Eg. `String` or `std::string::String`
   --> /home/daniel/.cargo/registry/src/index.crates.io-6f17d22bba15001f/specta-2.0.0-rc.1/src/type/impls.rs:201:19
    |
201 | #[specta(remote = "Duration", crate = "crate", export = false)]
    |                   ^^^^^^^^^^

error[E0432]: unresolved import `specta_macros::RSPCType`
   --> /home/daniel/.cargo/registry/src/index.crates.io-6f17d22bba15001f/specta-2.0.0-rc.1/src/lib.rs:112:9
    |
112 | pub use specta_macros::RSPCType;
    |         ^^^^^^^^^^^^^^^^^^^^^^^ no `RSPCType` in the root

For more information about this error, try `rustc --explain E0432`.
error: could not compile `specta` (lib) due to 3 previous errors
warning: build failed, waiting for other jobs to finish...

I checked that tokio instalation will not change anything and specta without rspc seems to work.

oscartbeaumont commented 7 months ago

I suspect this is due to a mistake I made with not correctly locking the specta_macros version in early releases of the specta v1.0.0.x releases which will be fixed when I make a future release.

Maybe try adding the following to your Cargo.toml:

specta_macros = "=2.0.0-rc.1"