jsontypedef / json-typedef-codegen

A CLI tool that generates code from JSON Typedef schemas
https://jsontypedef.com/docs/tools/jtd-codegen
MIT License
160 stars 31 forks source link

Rust: tests broken by shifting dependency versions #57

Open niko-dunixi opened 2 years ago

niko-dunixi commented 2 years ago

Problem

Cloning down the repository and utilizing the current default branch, tests are currently not passing.

$ cd ./crates/target_rust
$ cargo test

The error that occurs is

executor failed running [/bin/sh -c cargo build]: exit code: 101
[+] Building 0.0s (10/14)
 => [internal] load build definition from Dockerfile                     0.0s
 => => transferring dockerfile: 372B                                     0.0s
 => [internal] load .dockerignore                                        0.0s
 => => transferring context: 2B                                          0.0s
 => [internal] load metadata for docker.io/library/rust:1.49             0.0s
 => [internal] load build context                                        0.0s
 => => transferring context: 1.20kB                                      0.0s
 => [ 1/10] FROM docker.io/library/rust:1.49                             0.0s
 => CACHED [ 2/10] WORKDIR /work                                         0.0s
 => CACHED [ 3/10] COPY /Cargo.toml /work/Cargo.toml                     0.0s
 => CACHED [ 4/10] RUN mkdir /work/src                                   0.0s
 => CACHED [ 5/10] RUN echo 'fn main() {}' > /work/src/main.rs           0.0s
 => ERROR [ 6/10] RUN cargo build                                       51.0s
------
 > [ 6/10] RUN cargo build:
#10 0.906     Updating crates.io index
#10 50.29  Downloading crates ...
#10 50.82   Downloaded time v0.1.44
#10 50.86   Downloaded unicode-ident v1.0.3
#10 50.87   Downloaded quote v1.0.21
#10 50.89   Downloaded iana-time-zone v0.1.46
#10 50.94   Downloaded ryu v1.0.11
#10 50.96   Downloaded serde v1.0.143
#10 50.99 error: failed to parse manifest at `/usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/serde-1.0.143/Cargo.toml`
#10 50.99
#10 50.99 Caused by:
#10 50.99   feature `resolver` is required
#10 50.99
#10 50.99   this Cargo does not support nightly features, but if you
#10 50.99   switch to nightly channel you can add
#10 50.99   `cargo-features = ["resolver"]` to enable this feature

Cause

It seems that the problem is caused by a couple things. The Dockerfile uses rust at version 1.49, but the dependencies in the Cargo.toml aren't specific enough and the automatically pulled newer versions require a newer version of cargo

chrono = { version = "0.4", features = ["serde"] }
serde_json = "1"
serde = { version = "1.0", features = ["derive"] }