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

Cargo failed to select a version for dependencies, but problem is fixed when state is reset #9994

Closed
alice-i-cecile opened this issue Oct 21, 2021 · 4 comments
Labels
C-bug Category: bug

Comments

@alice-i-cecile
Copy link

Problem

Users use an old version of a library in one project, then create a new project with the updated version of our library.

The new project has dependency conflicts, reporting "failed to select a version for DEPENDENCY".

Bevy users report this problem on a near daily basis, but I can't reproduce it locally.

The workaround is to use cargo clean, cargo update and delete Cargo.lock, which invariably resolves the issue.

Steps

I have not been able to reproduce this from a clean slate.

Possible Solution(s)

Automatically check for stale dependencies in some fashion.

Failing that, supply an error message suggesting the workaround given.

Notes

No response

Version

cargo 1.53.0-nightly (f3e13226d 2021-04-30)
release: 1.53.0
commit-hash: f3e13226d6d17a2bc5f325303494b43a45f53b7f
commit-date: 2021-04-30
@alice-i-cecile alice-i-cecile added the C-bug Category: bug label Oct 21, 2021
@alice-i-cecile
Copy link
Author

alice-i-cecile commented Oct 21, 2021

Ha, I just got a reproduction locally.

Steps:

  1. Have a project that is on bevy = "0.5".
  2. Update the Cargo.toml to bevy = { git = "https://github.com/bevyengine/bevy", commit = "6a8a8c9d21f32e0e46623db9438813b009f9e014" }
  3. Run cargo build.
Blocking waiting for file lock on package cache
    Updating git repository `https://github.com/bevyengine/bevy`
    Updating crates.io index
error: failed to select a version for `web-sys`.
    ... required by package `wgpu v0.9.0`
    ... which is depended on by `bevy_wgpu v0.5.0 (https://github.com/bevyengine/bevy#6a8a8c9d)`
    ... which is depended on by `bevy_internal v0.5.0 (https://github.com/bevyengine/bevy#6a8a8c9d)`
    ... which is depended on by `bevy v0.5.0 (https://github.com/bevyengine/bevy#6a8a8c9d)`
    ... which is depended on by `bevy-scratchpad v0.1.0 (C:\Users\Alice\Documents\bevy-scratchpad)`
versions that meet the requirements `=0.3.50` are: 0.3.50

all possible versions conflict with previously selected packages.

  previously selected package `web-sys v0.3.46`
    ... which is depended on by `bevy_app v0.5.0 (https://github.com/bevyengine/bevy#6a8a8c9d)`
    ... which is depended on by `bevy_asset v0.5.0 (https://github.com/bevyengine/bevy#6a8a8c9d)`
    ... which is depended on by `bevy_audio v0.5.0 (https://github.com/bevyengine/bevy#6a8a8c9d)`
    ... which is depended on by `bevy_internal v0.5.0 (https://github.com/bevyengine/bevy#6a8a8c9d)`
    ... which is depended on by `bevy v0.5.0 (https://github.com/bevyengine/bevy#6a8a8c9d)`
    ... which is depended on by `bevy-scratchpad v0.1.0 (C:\Users\Alice\Documents\bevy-scratchpad)`

failed to select a version for `web-sys` which could resolve this conflict

No spooky cross-project nonsense, but it's a solid start. In this case, a simple cargo update solved things. In other cases I've seen though, this failed.

Diagnostics

cargo 1.56.0-nightly (e96bdb0c3 2021-08-17)
release: 1.56.0
commit-hash: e96bdb0c3d0a418e7fcd7fbd69be08abf830b4bc
commit-date: 2021-08-17

rustc 1.56.0-nightly (ad02dc46b 2021-08-26)

Complete Cargo.toml

[package]
name = "bevy-scratchpad"
version = "0.1.0"
authors = ["Alice Cecile <alice.i.cecile@gmail.com>"]
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
bevy = { git = "https://github.com/bevyengine/bevy", commit = "6a8a8c9d21f32e0e46623db9438813b009f9e014" }

Cargo.lock attached.

Cargo.lock.txt

@ehuss
Copy link
Contributor

ehuss commented Oct 21, 2021

Thanks for digging into a reproduction! I think this is almost certainly the same as #9240. When switching from a crates.io dep to a git dep, and the git dep has new dependency requirements, the dependencies in Cargo.lock remain locked, and cargo is not unlocking them when it should.

@alice-i-cecile
Copy link
Author

When switching from a crates.io dep to a git dep, and the git dep has new dependency requirements, the dependencies in Cargo.lock remain locked, and cargo is not unlocking them when it should.

FYI, the initial user report was switching from a Git version to a cargo release. The fact that this occurs across repositories is also suspicious.

Perhaps the problem is that the git version of Bevy also lists it's version as "0.5.0"?

@ehuss
Copy link
Contributor

ehuss commented Oct 22, 2021

I'm not sure if that'll help, but seems worth a shot to try.

I'm going to close as a duplicate of #9240, but we'll try to double-check this example gets fixed when that issue is addressed.

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

No branches or pull requests

2 participants