libcnb.rs
libcnb.rs copied to clipboard
Detect mismatched `libcnb-cargo`, `libcnb-test` and `libcnb` versions
As part of getting set up with a libcnb.rs powered buildpack, users will run cargo install libcnb-cargo
, which installs the latest libcnb-cargo
available at the time.
Over time we will end up adding new features to the libcnb related crates, that require corresponding support in libcnb-cargo
.
However, whilst users will have Dependabot to tell them to update their libcnb deps in Cargo.toml
, they won't have anything to remind them to update the globally installed libcnb-cargo
.
This may mean they see unexpected errors, or missing features, when trying to use their older version of libcnb-cargo
with the newer libcnb deps. For example that seen in #357.
There are a few ways we can deal with this:
- Have
libcnb-cargo
check for updates from time to time and output an "update available" message. - Have
libcnb-cargo
check that the libcnb crate versions in theCargo.toml
of the project being packaged match an allowlist of supported libcnb versions.
I feel like (2) might be the best approach, since:
- it handles both the forwards and backwards compatibility cases (whereas encouraging users to update libcnb-cargo via "update available" messages might actually mean they update to a version that's too new for that project)
- it would be the simplest to implement, given
libcnb-cargo
already loads cargo metadata - it would also benefit
libcnb-test
, since it also needs to be compatible with thelibcnb
version being used (as they are peer deps not parent/child, there's a chance they might get out of sync).
Hmm though I can now see a bunch of issues with (2), since how can libcnb-cargo
know in advance which future releases of libcnb
will/won't be compatible, without making every major release incompatible by default? (Which wouldn't be great for UX)
Have
libcnb-cargo
check for updates from time to time and output an "update available" message.
There are a couple of crates than can do this (though neither have very many downloads): https://crates.io/crates/update-informer https://crates.io/crates/update-notifier
Some CLIs also roll their own (in cargo-make's case they use the trick of using the cargo
CLI to check for updates):
https://github.com/sagiegurari/cargo-make/blob/0.35.9/src/lib/version.rs