Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Breakage in v1.10.0: multiple try_get_u32 found #767

Closed
snaggen opened this issue Feb 3, 2025 · 9 comments
Closed

Breakage in v1.10.0: multiple try_get_u32 found #767

snaggen opened this issue Feb 3, 2025 · 9 comments

Comments

@snaggen
Copy link

snaggen commented Feb 3, 2025

When I try to build russh-sftp I get

error[E0034]: multiple applicable items in scope
   --> /home/snaggen/.cargo/git/checkouts/russh-sftp-52ebce003cd3f693/d37c539/src/de.rs:216:30
    |
216 |         let len = self.input.try_get_u32()? as usize;
    |                              ^^^^^^^^^^^ multiple `try_get_u32` found

Setting bytes = "=1.9" solved this issue.... so I'm not sure if bytes is the problem here or cargo is resolving things wrong... but it is an issue anyway.

@seanmonstar
Copy link
Member

seanmonstar commented Feb 3, 2025

We added new methods to the Buf trait, try_get_* variants. It's likely that another trait is in scope as well that has the same method, and now the compiler is not able to determine which should be used.

@snaggen
Copy link
Author

snaggen commented Feb 3, 2025

Yes, I understand that, but that broke downstream, hence my bug report. But since you bumped the version to 1.10 I don't understand why it got pulled in since russh-sftp usesbytes = "1.9"

@seanmonstar
Copy link
Member

Cargo's understanding of semver is that non-breaking changes can be used eagerly. So when you see = "1.9", cargo understands that to really be >= 1.9.0, <2.0.0. Cargo didn't make a mistake, the version 1.10 is not considered a breaking change from 1.9.

While it does mess with inference, adding methods is not normally considered a breaking change, otherwise libraries could never add anything.

@snaggen
Copy link
Author

snaggen commented Feb 3, 2025

I see. Since cargos handing on semver, I realize that it would be impossible to bump major version everytime a change like this is done in a library. I guess downstream just have to adapt to these kind of changes.

@snaggen snaggen closed this as completed Feb 3, 2025
@Darksonn
Copy link
Contributor

Darksonn commented Feb 3, 2025

This is pretty sad :( It's true that adding methods to traits is often considered acceptable breakage, but it depends on how widespread the conflict is, and we might want to revert this is this is too common.

What library does the try_get_* methods that russh-sftp is using come from?

@snaggen
Copy link
Author

snaggen commented Feb 3, 2025

It seems to have been an internal generic impl. So, this seems to be limited to russh-sftp

@AspectUnk
Copy link

This is pretty sad :( It's true that adding methods to traits is often considered acceptable breakage, but it depends on how widespread the conflict is, and we might want to revert this is this is too common.

What library does the try_get_* methods that russh-sftp is using come from?

Actually, many people/projects use a similar custom implementation of try_get_* methods, but the error that occurred was my oversight. Therefore, I think you shouldn't consider a revert.

@Darksonn Darksonn changed the title Building russh-sftp fails Breakage in v1.10.0: multiple try_get_u32 found Feb 4, 2025
@Darksonn Darksonn pinned this issue Feb 4, 2025
@rukai
Copy link
Contributor

rukai commented Feb 4, 2025

this is unfortunate, I would really like to have these methods on BytesMut but this is definitely a breaking change. See: https://github.com/tychedelia/kafka-protocol-rs/blob/main/src/protocol/buf.rs which encounters the same issue as OP.

@rukai
Copy link
Contributor

rukai commented Feb 4, 2025

We found a way to compile kafka-protocol-rs both with and without this change: tychedelia/kafka-protocol-rs#108
So this specific crate will no longer be affected regardless of if you rollback this change or not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants