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

Update lock_api and instant to most recent versions #254

Closed

Conversation

j-vanderstoep
Copy link

lock_api is updated from 0.4.0 to 0.4.1.
instant is upsated from 0.1.4 to 0.1.7.

lock_api is updated from 0.4.0 to 0.4.1.
instant is upsated from 0.1.4 to 0.1.7.
@j-vanderstoep
Copy link
Author

Thanks for maintaining this crate. Some additional context for this change:

We're considering parking_lot for use in the Android open source project [1]. For Android, it's important that we limit the number of crate versions that are used because that reduces both memory and disk usage, both of critical importance on resource-constrained Android devices. Generally we try to achieve that by only depending on the latest version of each crate that we directly or indirectly use. This change moves us to the most recent version of lock_api and instant crates.

[1] https://android-review.googlesource.com/c/platform/external/rust/crates/parking_lot/+/1460364

@CryZe
Copy link
Contributor

CryZe commented Oct 19, 2020

This should not be necessary, cargo will never select both 0.1.4 and 0.1.7 as incompatible crates were it would compile in both versions.

@j-vanderstoep
Copy link
Author

This should not be necessary, cargo will never select both 0.1.4 and 0.1.7 as incompatible crates were it would compile in both versions.

I'm not sure I understand what you mean. If project A depends in 0.1.4, and project B depends on version 0.1.7, cargo will pull in 0.1.4 for project A and 0.1.7 for project B. Which would result in two versions of the same dylib on my device. If instead they both depend on 0.1.7, then I can have both projects depend on the same compiled output.

@CryZe
Copy link
Contributor

CryZe commented Oct 19, 2020

That's not the case, if both 0.1.4 and 0.1.7 are depended on cargo will only pull in 0.1.7, unless they both specify them as "=0.1.4" and "=0.1.7" respectively. Unless of course these two projects are separate projects (i.e. two different cargo projects with their own Cargo.lock files) and you are linking them together in some custom way.

@j-vanderstoep
Copy link
Author

Isn't that only true if 0.1.4 and 0.1.7 are depended on by the same project (e.g. a single "cargo build" command)? I'm not just concerned about a single project and its dependencies. I want separate/independent projects to rely on the same version of the crate if possible. Or does cargo always pull in the most recent minor version?

@bjorn3
Copy link
Contributor

bjorn3 commented Oct 19, 2020

The Cargo.lock file is used to ensure that the used version of dependencies doesn't change between builds. You can use cargo update to update all dependencies or cargo update -p lock_api to only update lock_api.

@faern
Copy link
Collaborator

faern commented Oct 19, 2020

@j-vanderstoep When you do cargo update it will automatically upgrade all crates to their latest semver compatible versions, depending on how the version in specified in Cargo.toml. Here in parking_lot the version is specified as version = "0.4.0" (one example). This is equivalent to writing version = "^0.4.0". It's called a caret requirement. This allows cargo to pull in any version in this range: >=0.4.0, <0.5.0. Please see the relevant cargo documentation: https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html

So yes, the change the PR makes should not be needed. You should just be able to do cargo update to get the latest versions. As pointed out above you can run it with -p <crate> to only update some crates.

@j-vanderstoep
Copy link
Author

Thanks everyone for the explanation. I confirmed locally exactly what you're describing - Even if 0.1.4 is specified, if 0.1.7 exists, Cargo will use that instead.

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

Successfully merging this pull request may close these issues.

None yet

5 participants