libcnb.rs icon indicating copy to clipboard operation
libcnb.rs copied to clipboard

Detect mismatched `libcnb-cargo`, `libcnb-test` and `libcnb` versions

Open edmorley opened this issue 2 years ago • 2 comments

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:

  1. Have libcnb-cargo check for updates from time to time and output an "update available" message.
  2. Have libcnb-cargo check that the libcnb crate versions in the Cargo.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 the libcnb version being used (as they are peer deps not parent/child, there's a chance they might get out of sync).

edmorley avatar Feb 27 '22 20:02 edmorley

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)

edmorley avatar Feb 28 '22 09:02 edmorley

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

edmorley avatar Feb 28 '22 09:02 edmorley