diesel: the trait bound `FieldAttr: ToTokens` is not satisfied (Installing the CLI)

Setup

Versions

  • Rust: 1.68.0 (2c8cc3432 2023-03-06)
  • Diesel: 2.0.0
  • Database: Postgres
  • Operating System MacOS arm64

Feature Flags

  • diesel:

Problem Description

I get an error while trying to install the CLI (as described on the setup guide at this link).

What are you trying to accomplish?

To setup diesel, to install the CLI tool.

What is the expected output?

A success message?

What is the actual output?

cargo install diesel_cli --no-default-features --features postgres
    Updating crates.io index
  Installing diesel_cli v2.0.1
   Compiling proc-macro2 v1.0.52
   Compiling unicode-ident v1.0.8
   Compiling quote v1.0.24
   Compiling syn v1.0.109
   Compiling autocfg v1.1.0
   Compiling serde_derive v1.0.155
   Compiling serde v1.0.155
   Compiling version_check v0.9.4
   Compiling memchr v2.5.0
   Compiling proc-macro-error-attr v1.0.4
   Compiling proc-macro-error v1.0.4
   Compiling libc v0.2.140
   Compiling num-traits v0.2.15
   Compiling indexmap v1.9.2
   Compiling tinyvec_macros v0.1.1
   Compiling pq-sys v0.4.7
   Compiling bitflags v1.3.2
   Compiling core-foundation-sys v0.8.3
   Compiling tinyvec v1.6.0
   Compiling num-integer v0.1.45
   Compiling hashbrown v0.12.3
   Compiling os_str_bytes v6.4.1
   Compiling clap_lex v0.2.4
   Compiling atty v0.2.14
   Compiling aho-corasick v0.7.20
   Compiling unicode-bidi v0.3.11
   Compiling unicode-normalization v0.1.22
   Compiling termcolor v1.2.0
   Compiling regex-syntax v0.6.28
   Compiling itoa v1.0.6
   Compiling byteorder v1.4.3
   Compiling textwrap v0.16.0
   Compiling overload v0.1.1
   Compiling percent-encoding v2.2.0
   Compiling strsim v0.10.0
   Compiling nu-ansi-term v0.46.0
   Compiling clap v3.2.23
   Compiling form_urlencoded v1.1.0
   Compiling idna v0.3.0
   Compiling iana-time-zone v0.1.53
   Compiling diffy v0.3.0
   Compiling regex v1.7.1
   Compiling chrono v0.4.24
   Compiling clap_complete v3.2.5
   Compiling url v2.3.1
   Compiling diesel_derives v2.0.1
error[E0277]: the trait bound `FieldAttr: ToTokens` is not satisfied
   --> /Users/harry/.cargo/registry/src/github.com-1ecc6299db9ec823/diesel_derives-2.0.1/src/attrs.rs:143:18
    |
143 | impl Spanned for FieldAttr {
    |                  ^^^^^^^^^ the trait `ToTokens` is not implemented for `FieldAttr`
    |
    = help: the following other types implement trait `ToTokens`:
              &'a T
              &'a mut T
              Abi
              Abstract
              AndAnd
              AndEq
              AngleBracketedGenericArguments
              Arm
            and 312 others
    = note: required for `FieldAttr` to implement `quote::spanned::private::Sealed`
note: required by a bound in `quote::spanned::Spanned`
   --> /Users/harry/.cargo/registry/src/github.com-1ecc6299db9ec823/quote-1.0.24/src/spanned.rs:6:20
    |
6   | pub trait Spanned: private::Sealed {
    |                    ^^^^^^^^^^^^^^^ required by this bound in `Spanned`

error[E0277]: the trait bound `StructAttr: ToTokens` is not satisfied
   --> /Users/harry/.cargo/registry/src/github.com-1ecc6299db9ec823/diesel_derives-2.0.1/src/attrs.rs:242:18
    |
242 | impl Spanned for StructAttr {
    |                  ^^^^^^^^^^ the trait `ToTokens` is not implemented for `StructAttr`
    |
    = help: the following other types implement trait `ToTokens`:
              &'a T
              &'a mut T
              Abi
              Abstract
              AndAnd
              AndEq
              AngleBracketedGenericArguments
              Arm
            and 312 others
    = note: required for `StructAttr` to implement `quote::spanned::private::Sealed`
note: required by a bound in `quote::spanned::Spanned`
   --> /Users/harry/.cargo/registry/src/github.com-1ecc6299db9ec823/quote-1.0.24/src/spanned.rs:6:20
    |
6   | pub trait Spanned: private::Sealed {
    |                    ^^^^^^^^^^^^^^^ required by this bound in `Spanned`

For more information about this error, try `rustc --explain E0277`.
error: could not compile `diesel_derives` due to 2 previous errors
warning: build failed, waiting for other jobs to finish...
error: failed to compile `diesel_cli v2.0.1`, intermediate artifacts can be found at `/var/folders/wx/y49q6sc950v5mhfvqkrc09100000gn/T/cargo-installYNdmN4`

Are you seeing any additional errors?

No

Steps to reproduce

The steps that are on the website.

Checklist

  • This issue can be reproduced on Rust’s stable channel. (Your issue will be closed if this is not the case)
  • This issue can be reproduced without requiring a third party crate

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 12
  • Comments: 17 (4 by maintainers)

Commits related to this issue

Most upvoted comments

I’ve published diesel_derives 2.0.2 to fix this issue. If you depend on diesel and hit this issue please run cargo update -p diesel_derives to update your diesel_derives version. If you want to install diesel_cli that should just work now.

cargo update -p quote --precise 1.0.23

This works in the meantime, in case people are currently blocked.

I’m getting the same thing trying to install diesel

Versions

  • Rust: 1.68.0 (2c8cc3432 2023-03-06)
  • Diesel: 2.0.3
  • Database: MySQL
  • Operating System: Windows 11

Looks to be caused by a Quote update https://github.com/dtolnay/quote

Please do not post other error messages to this issue. We are aware of the quote problem and working on a fix. Posting here that it is still broken does not help fixing the issue.

This is happening due to a breaking change in quote. It seems like diesel accidentally depends on an API they consider as not public. See https://github.com/dtolnay/quote/issues/241 for details. I will try to publish a patch release fixing this issues soon. In the mean time you can use the following workarounds:

For installing diesel_cli: cargo install diesel_cli --locked For projects depending on diesel add the following line to your Cargo.toml: quote = "=1.0.23".

Thanks a lot for the quick turnaround @weiznich, it’s very much appreciated.

Thank you ❤️ ❤️ ❤️ ❤️