Inconsistent dependency versions from weird cargo behaviours
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 25/100
- issue の種類
- バグ
- 明瞭さ
- 説明が足りない
- 活発さ
- 停滞
- 技術スタック
- rust
- 領域
- build-system, testing
調査の方向性
workspace の Cargo.lock と target/tests/trybuild/derive-deftly-tests/Cargo.lock を比較し、合成 crate derive-deftly-tests-tests がどのように組み立てられているかを調べます。run_pass_expand テストをオフラインで再現し、生成された lockfile が呼び出し元 crate の依存関係のバージョンを使用し、予期しない toml 0.5.11 のダウンロードを必要としなくなっていることを確認します。
索引モデルが issue の本文から書いたものです。
説明
Hi.
I found this strange issue while working on derive-deftly, which uses multiple crates in the workspace, with various cargo features; and also has quite relaxed dependency specifications.
In https://gitlab.torproject.org/Diziet/rust-derive-deftly/-/jobs/507457 it appears that cargo concluded it didn't need to download toml 0.5.11 for the proposed test run:
Running `/builds/Diziet/rust-derive-deftly/target/debug/deps/trybuild-27b1d08daa9c16ae`
running 1 test
error: failed to download `toml v0.5.11`
Caused by:
attempting to make an HTTP request, but --offline was specified
test run_pass_expand ... FAILED
failures:
---- run_pass_expand stdout ----
thread 'run_pass_expand' panicked at /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/trybuild-1.0.90/src/run.rs:61:13:
Looking at the dependencies there, cargo is (as far as it could tell) correct: the requested test run does not enable the features that pull in macrotest and it's macrotest that wants toml 0.5.11. The lockfile says to use toml 0.8.2 for derive-deftly-tests, which is the crate containing the trybuild calls.
But when cargo tries to build trybuild's test crate derive-deftly-tests-tests, cargo chooses to use toml 0.5.11 to satisfy the dependency. (I have observed this locally by looking in target/tests/trybuild/derive-deftly-tests/Cargo.lock.) This may be because macrotest demands 0.5 and nothing else in that crate tree demands 0.8, so cargo thinks it can save on duplication this way. (I think because the synthetic crate isn't part of the workspace, the other crates in the workspace that would bring in 0.8 aren't there.)
As a result, that build needs toml 0.5.11 which hasn't been downloaded. I'm working around this for now with an additional call to cargo fetch. That fetches toml 0.5.11 so the test passes.
But that's not really right: what we want is for the syntehtic test crate to use the same versions as the crate containing the trybuild calls. I haven't tested it, but:
I think a big part of the reason this is happening is that cargo is forced to make up a whole new lockfile entry for the synthetic crate. So I suggest the following strategy: after copying the workspace Cargo.lock, add an additional [[package]] entry for the synthetic crate, which is simply a copy of the invoking crate's entry (with changed name and version). Maybe if we did that cargo would leave it alone.
I think we would still need cargo fetch.
Another option might be to try to avoid this situation where the synthetic crate isn't part of the workspace. If the other workspace members were present to influence dependency selection, we could hope that cargo would do the same for the synthetic crate as for the invoking crate, and then everything would be fine. I think?
- 主要言語
- Rust
- スター
- 1k
- フォーク
- 87
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
dtolnay/trybuild のほかの issue
-
難易度 4/5 3〜5日 初心者へのやさしさ 32/100
-
難易度 3/5 1〜2日 初心者へのやさしさ 55/100
-
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
-
難易度 3/5 1〜2日 初心者へのやさしさ 50/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 42/100
dtolnay/trybuild の issue をすべて見る
似ている issue
-
priority: low
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
storytold/photocraft#15350 ·
メンテナーはふだん 1 日以内に返信
-
area:davinci
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
ubugeeei-prod/vize#13167 ·
メンテナーはふだん 1 日以内に返信
-
area:ui enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
transit-audio/transit#738 ·
メンテナーはふだん 1 日以内に返信
-
enhancement good first issue help wanted
難易度 2/5 1〜3時間 初心者へのやさしさ 91/100
hocinehacherouf/liberarr#78 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信