Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replacing serde-yaml #214

Closed
mitsuhiko opened this issue Feb 6, 2022 · 5 comments
Closed

Replacing serde-yaml #214

mitsuhiko opened this issue Feb 6, 2022 · 5 comments

Comments

@mitsuhiko
Copy link
Owner

Currently insta is very dependent on serde-yaml and it's a default dependency. This is lately turning into an issue as serde-yaml no longer has any guarantees for supporting Rust versions below 1.56 which is too new for a testing tool.

The core of the issue is hashbrown upgrading: rust-lang/hashbrown#310

Which in turn causes indexmap to upgrade: indexmap-rs/indexmap#214

I also brought up this issue with serde-yaml here: dtolnay/serde-yaml#233

The latter issue is likely the only that matters. The issue was closed with wontfix which means that in the foreseeable future serde-yaml is going to move up. We currently unfortunately use the YAML format in two ways: read/write for the snapshot header and write only for the snapshots.

One option would be to make a hand written parser for the minimal header the snapshot files currently have and change the format to emit a simplified header in the future that does not require an external dependency. Then for the serialization implement the necessary YAML format pieces independently within the crate. This would make insta less dependent on the its dependencies.

@max-sixty
Copy link
Sponsor Contributor

How do you think about pinning an older version of dependencies that increase their lower bound quicker than ideal?

Or does force all dependencies to be old given cross-dependencies?

@mitsuhiko
Copy link
Owner Author

I'm not sure yet if there is a hack that can be used to pin serde-yaml to an older version. Potentially there could be a fake crate that has a hard pin to a specific version of serde-yaml, indexmap and co and then re-export this, but I have not investigated this. It also does not sound like a good long term option sadly.

@max-sixty
Copy link
Sponsor Contributor

Ah, I was thinking to just lock the version in Cargo.toml, which produces the following diff (but I imagine I am missing something):

diff --git a/Cargo.lock b/Cargo.lock
index af4f2ab..74dd88b 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -11,12 +11,6 @@ dependencies = [
  "memchr",
 ]
 
-[[package]]
-name = "autocfg"
-version = "1.0.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a"
-
 [[package]]
 name = "base64"
 version = "0.13.0"
@@ -124,6 +118,12 @@ dependencies = [
  "generic-array",
 ]
 
+[[package]]
+name = "dtoa"
+version = "0.4.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "56899898ce76aaf4a0f24d914c97ea6ed976d42fec6ad33fcbb0a1103e07b2b0"
+
 [[package]]
 name = "encode_unicode"
 version = "0.3.6"
@@ -164,22 +164,6 @@ dependencies = [
  "regex",
 ]
 
-[[package]]
-name = "hashbrown"
-version = "0.11.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e"
-
-[[package]]
-name = "indexmap"
-version = "1.8.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "282a6247722caba404c065016bbfa522806e51714c34f5dfc3e4a3a46fcb4223"
-dependencies = [
- "autocfg",
- "hashbrown",
-]
-
 [[package]]
 name = "insta"
 version = "1.12.0"
@@ -404,12 +388,12 @@ dependencies = [
 
 [[package]]
 name = "serde_yaml"
-version = "0.8.23"
+version = "0.7.5"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a4a521f2940385c165a24ee286aa8599633d162077a54bdcae2a6fd5a7bfa7a0"
+checksum = "ef8099d3df28273c99a1728190c7a9f19d444c941044f64adf986bee7ec53051"
 dependencies = [
- "indexmap",
- "ryu",
+ "dtoa",
+ "linked-hash-map",
  "serde",
  "yaml-rust",
 ]
diff --git a/Cargo.toml b/Cargo.toml
index ab93d93..9cdcb5c 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -39,7 +39,7 @@ backtrace = []
 [dependencies]
 csv = { version = "1.1.4", optional = true }
 serde = { version = "1.0.117", features = ["derive"] }
-serde_yaml = "0.8.14"
+serde_yaml = "0.7"
 console = { version = "0.15.0", optional = true, default-features = false }
 serde_json = "1.0.59"
 pest = { version = "2.1.3", optional = true }

@mitsuhiko
Copy link
Owner Author

You're right that it works with 0.7, but it does not work if you pin to a specific version of 0.8.

@mitsuhiko
Copy link
Owner Author

I don't have time for this sadly and had to move up the minimum rust version to 1.56.1 since everything is broken on older Rusts now. See #231

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants