avitex / mdbook-tera

Tera preprocessor for mdBook

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Build failure following tera 1.14.0 release

dureuill opened this issue · comments

Hello, and thank you for making mdbook-tera, it is really powerful to be able to combine mdbook with tera.

While cargo install mdbook-tera, I encountered the following errors reported at the end of this message. It appears to be caused by the new update of Tera (released Nov 1 2021) that changes the definition of the Context struct to add a type parameter, which AFAICT is a breaking change.

The issue has also been raised upstream.

That being said, I see the following options:

  1. Wait for the issue to be resolved upstream (by yanking 1.14 and releasing a 2.0.0)
  2. Change the Cargo.toml to specify an exact version of tera, rather than a compatible one. ("=1.12.0" should work)
  3. Modify the code to be compatible with release 1.14 (future 2.0).

Optionally, once the issue is resolved, we could add Cargo.lock into git, so that the build remains fully reproductible in the future, as is recommended for binary applications in the cargo book

Thank you again for mdbook-tera!

   Compiling mdbook-tera v0.4.0
error[E0107]: missing generics for struct `tera::Context`
  --> /home/tetrane/.cargo/registry/src/github.com-1ecc6299db9ec823/mdbook-tera-0.4.0/src/lib.rs:89:66
   |
89 | fn render_book_items(book: &mut Book, tera: &mut Tera, context: &Context) -> Result<(), Error> {
   |                                                                  ^^^^^^^ expected 1 generic argument
   |
note: struct defined here, with 1 generic parameter: `S`
  --> /home/tetrane/.cargo/registry/src/github.com-1ecc6299db9ec823/tera-1.14.0/src/context.rs:57:12
   |
57 | pub struct Context<S: ContextSafety> {
   |            ^^^^^^^ -
help: add missing generic argument
   |
89 | fn render_book_items(book: &mut Book, tera: &mut Tera, context: &Context<S>) -> Result<(), Error> {
   |                                                                  ^^^^^^^^^^

error[E0107]: missing generics for struct `tera::Context`
   --> /home/tetrane/.cargo/registry/src/github.com-1ecc6299db9ec823/mdbook-tera-0.4.0/src/lib.rs:122:15
    |
122 |     context: &Context,
    |               ^^^^^^^ expected 1 generic argument
    |
note: struct defined here, with 1 generic parameter: `S`
   --> /home/tetrane/.cargo/registry/src/github.com-1ecc6299db9ec823/tera-1.14.0/src/context.rs:57:12
    |
57  | pub struct Context<S: ContextSafety> {
    |            ^^^^^^^ -
help: add missing generic argument
    |
122 |     context: &Context<S>,
    |               ^^^^^^^^^^

error[E0107]: missing generics for struct `tera::Context`
  --> /home/tetrane/.cargo/registry/src/github.com-1ecc6299db9ec823/mdbook-tera-0.4.0/src/context.rs:20:14
   |
20 |     context: Context,
   |              ^^^^^^^ expected 1 generic argument
   |
note: struct defined here, with 1 generic parameter: `S`
  --> /home/tetrane/.cargo/registry/src/github.com-1ecc6299db9ec823/tera-1.14.0/src/context.rs:57:12
   |
57 | pub struct Context<S: ContextSafety> {
   |            ^^^^^^^ -
help: add missing generic argument
   |
20 |     context: Context<S>,
   |              ^^^^^^^^^^

error[E0107]: missing generics for struct `tera::Context`
  --> /home/tetrane/.cargo/registry/src/github.com-1ecc6299db9ec823/mdbook-tera-0.4.0/src/context.rs:14:26
   |
14 |     fn context(&self) -> Context;
   |                          ^^^^^^^ expected 1 generic argument
   |
note: struct defined here, with 1 generic parameter: `S`
  --> /home/tetrane/.cargo/registry/src/github.com-1ecc6299db9ec823/tera-1.14.0/src/context.rs:57:12
   |
57 | pub struct Context<S: ContextSafety> {
   |            ^^^^^^^ -
help: add missing generic argument
   |
14 |     fn context(&self) -> Context<S>;
   |                          ^^^^^^^^^^

error[E0107]: missing generics for struct `tera::Context`
  --> /home/tetrane/.cargo/registry/src/github.com-1ecc6299db9ec823/mdbook-tera-0.4.0/src/context.rs:24:26
   |
24 |     fn context(&self) -> Context {
   |                          ^^^^^^^ expected 1 generic argument
   |
note: struct defined here, with 1 generic parameter: `S`
  --> /home/tetrane/.cargo/registry/src/github.com-1ecc6299db9ec823/tera-1.14.0/src/context.rs:57:12
   |
57 | pub struct Context<S: ContextSafety> {
   |            ^^^^^^^ -
help: add missing generic argument
   |
24 |     fn context(&self) -> Context<S> {
   |                          ^^^^^^^^^^

error[E0107]: missing generics for struct `tera::Context`
  --> /home/tetrane/.cargo/registry/src/github.com-1ecc6299db9ec823/mdbook-tera-0.4.0/src/context.rs:31:25
   |
31 |     pub fn new(context: Context) -> Self {
   |                         ^^^^^^^ expected 1 generic argument
   |
note: struct defined here, with 1 generic parameter: `S`
  --> /home/tetrane/.cargo/registry/src/github.com-1ecc6299db9ec823/tera-1.14.0/src/context.rs:57:12
   |
57 | pub struct Context<S: ContextSafety> {
   |            ^^^^^^^ -
help: add missing generic argument
   |
31 |     pub fn new(context: Context<S>) -> Self {
   |                         ^^^^^^^^^^

For more information about this error, try `rustc --explain E0107`.
error: could not compile `mdbook-tera` due to 6 previous errors
warning: build failed, waiting for other jobs to finish...
error: failed to compile `mdbook-tera v0.4.0`, intermediate artifacts can be found at `/tmp/cargo-installvyhKA6`

Opened #8 to fix by implementing a variant of solution (2)

commented

Thank you very much for the detailed report, sorry for the delay in replying. I'll publish the crate with the latest version of tera with the breaking change when that comes out. I can see this issue has been resolved upstream for the time being. I'll commit Cargo.lock and look at making some binary releases too.

commented

Closing as this issue has been resolved upstream. Also have added Cargo.lock. Thank you!

I'll [...] look at making some binary releases too.

Ah yes, that would be much appreciated (would allow us to wget/curl the binary rather than rebuilding from cratesio on every CI run)! Thank you for your reply and for adding the Cargo.lock!

Thank you, I used this in tetrane/api-cookbook#6! Really shortens the CI time