Compilation error: ErrorMessage

Hello. I’m trying to compile code which depends on sn_api = "0.24.0". I get an error in sn_api:

% cargo build  --target=i686-unknown-linux-gnu
   Compiling sn_api v0.24.0
error[E0532]: expected tuple struct or tuple variant, found struct variant `ClientError::ErrorMessage`
   --> /home/devel/.cargo/registry/src/github.com-1ecc6299db9ec823/sn_api-0.24.0/src/api/app/safe_client.rs:312:17
    |
312 |                 ClientError::ErrorMessage(ErrorMessage::AccessDenied(_pk))
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use struct pattern syntax instead: `ClientError::ErrorMessage { /* fields */ }`
    | 
   ::: /home/devel/.cargo/registry/src/github.com-1ecc6299db9ec823/sn_client-0.52.19/src/errors.rs:125:5
    |
125 |     ErrorMessage {
    |     ------------ `ClientError::ErrorMessage` defined here

error[E0532]: expected tuple struct or tuple variant, found struct variant `ClientError::ErrorMessage`
   --> /home/devel/.cargo/registry/src/github.com-1ecc6299db9ec823/sn_api-0.24.0/src/api/authenticator/mod.rs:424:21
    |
424 |                 Err(ClientError::ErrorMessage(NoSuchEntry)) => {
    |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use struct pattern syntax instead: `ClientError::ErrorMessage { /* fields */ }`
    | 
   ::: /home/devel/.cargo/registry/src/github.com-1ecc6299db9ec823/sn_client-0.52.19/src/errors.rs:125:5
    |
125 |     ErrorMessage {
    |     ------------ `ClientError::ErrorMessage` defined here

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0532`.
error: could not compile `sn_api`

To learn more, run the command again with --verbose.

I don’t understand, why I get it? Wouldn’t it stop sn_api to pass CI checks?

Have you checked you version of Rust? I think they use latest stable release.

I updated from 1.49 to 1.51, but the error is the same. Also, I noticed that I copy-pasted result from wrong sn_api version, although 0.24.0 is still the same as 0.22.0, same error which makes things additionally strange, that there is an error nobody has noticed for 2 versions. That makes me think it’s only error on my computer, but I have no idea where it can come from.

I think I nailed it:

In commit 8a4f1e2e there is change in sn_client errors.rs file, that makes version 0.52.19 incompatible with sn_api, which in Cagro.toml has sn_client = "~0.52.16". This allows 0.52.19 and somehow this is the version my compiler tries to compile.

1 Like

Fixed:

1 Like

Backwards compatibility isn’t strictly enforced at the moment so previous minor versions might break with incompatible dependent versions. If you are relying on a sn_api, I would recommend pinning on the latest version

1 Like