Rustler fails to build [because serde_rustler pinned to rustler v 0.21] (solved)

This may be better addressed in a Rust forum but I’m trying to use Rustler in a project and when trying to build the Rustler module I’m getting the error:

failed to run custom build command for erlang_nif-sys v0.6.4
— stdout
Unsupported Erlang version.

In the Cargo.toml for the rustler module in /my/project/native/rustler_module/ I have

rustler = { version = "0.31.0", features = ["nif_version_2_17"]}

My installed erlang version is 26.2.1-1.

Any suggestions?

So this was due to serde_rustler rather than rustler itself. serde_rustler has rustler 0.21.0 as a dependency. That old version of rustler does not support OTP 26.