I am trying to compile an older version tide using a older version of rust compiler (1.45.2 2020-07-31). Current rustc version is 1.54. Current version is tide = "0.16.0", but I see that tide = 0.12.0 was released on 2020-07-17, so I think I must be able to compile the latter version with my older compiler. Tide 0.12.0 does not compile with my older compiler because one of the dependencies (socket2 0.4.1) uses match inside a const fn which I think was introduced after rustc 1.45.2.
How can I make cargo use older version of the socket2 dependency?
socket2 = "0.3" compiles with my older compiler. However, I can see using cargo tree that none of the versions of the dependencies change when I use tide 0.12.0 instead of tide 0.16.0.
The only crate in my project that directly depends on socket2 is async-io. If I look at the list of async-io versions, it looks like the latest version that does not depend on socket2 0.4.x is async-io 1.1.0, so I try to downgrade to this version with cargo update:
$ cargo update --package async-io --precise 1.1.0
Updating crates.io index
error: failed to select a version for the requirement `async-io = "^1.2"`
candidate versions found which didn't match: 1.1.0
location searched: crates.io index
required by package `async-global-executor v2.0.2`
... which is depended on by `async-std v1.9.0`
... which is depended on by `async-h1 v2.3.2`
... which is depended on by `tide v0.12.0`
Looks like I will also need to downgrade async-global-executor, but when I try to do that, I run into similar errors that lead me to also downgrade async-std. After doing that, I can finally dowgrade async-io:
You may need to repeat with any other dependencies that also fail to build with your old toolchain. Unfortunately, this manual process is the only solution I know. Perhaps someone could build a Cargo command that can automatically ignore versions newer than a specified date.
(Nightly Cargo has an experimental cargo update -Z minimal-versions command that could help with this in theory, though it downgrades more crates that necessary, and it also tends to break the build if any crates fail to specify accurate constraints on their dependencies.)
Thanks! I now understand that the process of finding the right version of dependencies is manual and needed to be done with a couple of cargo update commands to change the Cargo.lock file.
Once I have found the right versions of the dependencies, I can sometimes force the older dependencies to be generated from Cargo.toml in Cargo.lock. Adding this line in Cargo.toml made older tide compile with the older compiler: