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

Gracefully handle cargo version conflicts #3213

Merged
merged 6 commits into from
Mar 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,6 @@ def handle_cargo_errors(error)
raise Dependabot::GitDependencyReferenceNotFound, dependency_url
end

raise Dependabot::DependencyFileNotResolvable, error.message if resolvability_error?(error.message)

if workspace_native_library_update_error?(error.message)
# This happens when we're updating one part of a workspace which
# triggers an update of a subdependency that uses a native library,
Expand All @@ -237,6 +235,8 @@ def handle_cargo_errors(error)
return nil
end

raise Dependabot::DependencyFileNotResolvable, error.message if resolvability_error?(error.message)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is probably the right thing considering all existing specs pass but can't say I understand what all possible versions conflict actually means 😅

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was hoping that a failing test would guide me. I quick dive into the history lead me to a PR where the rubocop rule for line length changed from 80 to 120. I didn't go deeper than that. I'll do a deeper dive and see what source of additional context that I can discover.


raise error
end
# rubocop:enable Metrics/AbcSize
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -533,5 +533,16 @@
let(:dependency_files) { unprepared_dependency_files }
it { is_expected.to eq(Gem::Version.new("0.1.80")) }
end

context "when multiple packages have a version conflict with one another" do
let(:dependency_name) { "ructe" }
let(:dependency_version) { "0b8acfe5eea15713bc56c156f974fa05967d0353" }
let(:string_req) { nil }
let(:source) { { type: "git", url: "https://github.com/kaj/ructe" } }
let(:dependency_files) { project_dependency_files("version_conflict") }
let(:unprepared_dependency_files) { project_dependency_files("version_conflict") }

specify { expect(subject).to be_nil }
end
end
end
290 changes: 290 additions & 0 deletions cargo/spec/fixtures/projects/version_conflict/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions cargo/spec/fixtures/projects/version_conflict/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[package]
name = "version_conflict"
version = "0.1.0"
authors = ["[email protected]"]

[dependencies]
askama = { git = "https://github.com/djc/askama", branch = "main" }

[build-dependencies]
ructe = { git = "https://github.com/kaj/ructe" }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wondering, could we cut this down to just ructe and askma which seem to have the conflicting deps? Had a go at testing this locally and the first time the test ran it took over 2 mins to run so might be due to the large poject

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, yes. I remember you mentioned that we should whittle this down to just the important bits. I'll try to reduce this and the .lock file to just the relevant bits.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice one, you might be able to just edit the Cargo.toml and run cargo generate-lockfile

Empty file.