Conversation
The optional feature syntax (`package-name?/feature`) doesn't seem to work
properly while vendoring a (sub-)dependency.
POC below:
FROM rust:alpine
WORKDIR /tmp
RUN apk add git
RUN git clone --depth=1 https://github.com/rust-lang/log vendor/log
RUN git clone --depth=1 https://github.com/rust-cli/env_logger vendor/env_logger
RUN <<EOR
cat<<EOF > vendor/env_logger/fix.patch
diff --git a/crates/env_filter/Cargo.toml b/crates/env_filter/Cargo.toml
--- a/crates/env_filter/Cargo.toml
+++ b/crates/env_filter/Cargo.toml
@@ -28,11 +28,11 @@ pre-release-replacements = [
[features]
default = ["std", "regex"]
regex = ["dep:regex"]
-std = ["log/std", "regex?/std"]
+std = ["log/std"]
[dependencies]
log = { version = "0.4.29" }
-regex = { version = "1.12.3", optional = true, default-features=false, features=["perf"] }
+regex = { version = "1.12.3", optional = true, default-features=false, features=["std", "perf"] }
[dev-dependencies]
snapbox = "1.0"
EOF
cd vendor/env_logger&&git apply fix.patch
EOR
RUN cat vendor/env_logger/crates/env_filter/Cargo.toml
RUN <<EOR
mkdir src
echo "fn main() {}" > src/main.rs
cat<<EOF > Cargo.toml
[package]
name = "bug"
edition = "2024"
[dependencies]
env_logger = { version = "0.11.11", default-features = false, features = [] }
log = { version = "0.4.34", default-features = false }
# note: happens even if not specified here
env_filter = { version = "2.0.0", default-features = false, features = [] }
[patch.crates-io]
env_logger = { path = "vendor/env_logger" }
env_filter = { path = "vendor/env_logger/crates/env_filter" }
log = { path = "vendor/log" }
EOF
EOR
RUN <<EOR
rustc --version
cargo --version
cargo build --offline --no-default-features --verbose
EOR
Contributor
|
I can't imagine what this would be the root cause for, rather than a workaround. I'd prefer to focus on the root cause. The only vendor issue I'm aware of is rust-lang/cargo#10801. Going to close this in favor of whereever the root cause Issue is opened. Note that If reverting somethìng, then likely this isn' t so straightforward that you can skip an issue. An Issue would have better encouraged describing the problem, more than the PR template does. |
Author
|
@epage I believe that's the bug I'm experiencing! Thanks |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hey 👋
I read the guide but I'm not sure whether this revert would justify creating a separate issue, so I made a PR instead. Feel free to close/convert if needed.
What does this PR try to solve?
I'm experiencing an issue when vendoring caused by 132fe86 (
package-name?/featurespecifically). I'm not sure whether this is a bug in Cargo potentially opened elsewhere, however I reverted the problematic parts locally this way. The commit also contains a POC which might also be useful as a CI test for vendoring in case such change happens again in the future, so it's caught before releasing.POC below:
Notes to reviewers
POC above and in the commit message.
LLM involvement: Zero