rust-url: Compilation error with url 2.5.3 / idna 1.0.3 with Rust < 1.81 and edition 2021 (resolver 2) when sqlx-core < 0.8.3 is in the dependency graph
Edited by @hsivonen to put resolution options at the top for folks who come here:
To resolve this compilation error, update SQLx to 0.8.3 and/or update Rust to 1.81 or later.
This compilation error is due to a combination of:
- SQLx unnecessarily turning off the default features of
url, and from a proc macro context specifically. (Request for SQLx not to do that: https://github.com/launchbadge/sqlx/issues/3589) url2.5.3 (andidna1.0.3) conditionally raising MSRV to 1.81 when default features are off (from #831). Conditionally raising MSRV to 1.81 is not a semver break, because raising MSRV isn’t a semver break.resolver = "2", which is implied byedition = "2021"performing feature resolution for proc macro dependencies separately from normal dependencies, so a normal dependency onurlwith default features enabled does not cause default features to be enabled for the proc macro case.
Original report follows:
- Note that this crate implements the URL Standard not RFC 1738 or RFC 3986
Describe the bug
After update to v1.0.3 wich is picked up automatically since its a patch upgrade, our code no longer compiles the same.
rust versions tested:
- rustc 1.80.1
- rustc 1.81.0
Compiling idna v1.0.3
error[E0658]: use of unstable library feature 'error_in_core'
--> /home/krille/.cargo/registry/src/index.crates.io-6f17d22bba15001f/idna-1.0.3/src/lib.rs:78:6
|
78 | impl core::error::Error for Errors {}
| ^^^^^^^^^^^^^^^^^^
|
= note: see issue #103765 <https://github.com/rust-lang/rust/issues/103765> for more information
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 16
- Comments: 32 (3 by maintainers)
Commits related to this issue
- Upgrade `url` crate from 2.5.0 to 2.5.3 Might fix CI failures caused by this: https://github.com/servo/rust-url/issues/992. Slack thread: https://posthog.slack.com/archives/C0113360FFV/p1730722228558... — committed to PostHog/posthog by Twixes 2 years ago
- Ensure idna 0.5 Fixes CI failures caused by this: servo/rust-url#992. Slack thread: https://posthog.slack.com/archives/C0113360FFV/p1730722228558389 — committed to PostHog/posthog by Twixes 2 years ago
- Remove `default-features = false` from the `url` crate https://github.com/servo/rust-url/issues/992 — committed to breard-r/libreauth by breard-r 2 years ago
- Update ureq to latest to address vulnerability in idna ID: RUSTSEC-2024-0421 ├ Advisory: https://rustsec.org/advisories/RUSTSEC-2024-0421 ├ `idna` 0.5.0 and earlier accepts Punycode labels that... — committed to google/automotive-design-compose by timothyfroehlich 2 years ago
- Update ureq to latest to address vulnerability in idna ID: RUSTSEC-2024-0421 ├ Advisory: https://rustsec.org/advisories/RUSTSEC-2024-0421 ├ `idna` 0.5.0 and earlier accepts Punycode labels that... — committed to google/automotive-design-compose by timothyfroehlich 2 years ago
- Update ureq to latest to address vulnerability in idna ID: RUSTSEC-2024-0421 ├ Advisory: https://rustsec.org/advisories/RUSTSEC-2024-0421 ├ `idna` 0.5.0 and earlier accepts Punycode labels that... — committed to google/automotive-design-compose by timothyfroehlich 2 years ago
- Update ureq to latest to address vulnerability in idna (#1848) ID: RUSTSEC-2024-0421 ├ Advisory: https://rustsec.org/advisories/RUSTSEC-2024-0421 ├ `idna` 0.5.0 and earlier accepts Punycode labels... — committed to google/automotive-design-compose by timothyfroehlich 2 years ago
- chore: update seaorm to latest (#4925) ### Description Updated `sea-orm` and `sea-orm-migration` to `1.1.1` (latest as of opening this PR) and resolved any issues that occurred due to the version bu... — committed to hyperlane-xyz/hyperlane-monorepo by Mantas-M 2 years ago
- Temporarily ignore RUSTSEC-2024-0421 ``` error[vulnerability]: `idna` accepts Punycode labels that do not produce any non-ASCII when decoded ┌─ /home/runner/work/openrr/openrr/Cargo.lock:260:1 ... — committed to openrr/openrr by taiki-e 2 years ago
- Temporarily ignore RUSTSEC-2024-0421 ``` error[vulnerability]: `idna` accepts Punycode labels that do not produce any non-ASCII when decoded ┌─ /home/runner/work/openrr/openrr/Cargo.lock:260:1 ... — committed to openrr/openrr by taiki-e 2 years ago
- Temporarily ignore RUSTSEC-2024-0421 ``` error[vulnerability]: `idna` accepts Punycode labels that do not produce any non-ASCII when decoded ┌─ /home/runner/work/openrr/openrr/Cargo.lock:260:1 ... — committed to openrr/openrr by taiki-e 2 years ago
- chore: update seaorm to latest (#4925) ### Description Updated `sea-orm` and `sea-orm-migration` to `1.1.1` (latest as of opening this PR) and resolved any issues that occurred due to the version bu... — committed to fmorency/hyperlane-agents by Mantas-M 2 years ago
- build(deps): bump sqlx to 0.8.3 We hit the same issue as https://github.com/servo/rust-url/issues/992, so I bumped the sqlx dependency to 0.8.3. — committed to juspay/hyperswitch by SanchithHegde 2 years ago
Not really sure why we had
default-features = falseto begin with on a crate that had no feature flags, but strictly speaking we’re being good citizens by doing this.Because of Cargo’s feature unification, it becomes very difficult to turn off default features for a crate that’s deep in your dependency tree, since any other crate in the tree that depends on it but neglects to set
default-features = falseforces on the default features for the whole dependency tree. It’s impossible to fix this without patching or overriding that dependency. We’ve run into this many times with other dependencies.I think one of the last times we ran into this we just added
default-features = falseto a bunch of dependencies. You can see that’s exactly what we did in the previously linked commit: https://github.com/launchbadge/sqlx/commit/d76b1357da21f777ee1cdab8bfd907ed66c7b3bdIt’s a really weird situation that disabling a feature leads to an increase in the MSRV. I would consider this an unintentional breakage of the
urlcrate, unless I missed the meeting where it was decided that settingdefault-features = falsemakes a dependency completely exempt from SemVer.I understand that as a more “fundamental” crate than SQLx,
urlhas different priorities, but issues like this are exactly why we decided not to guarantee an MSRV in the first place, because it’s a massive SemVer hazard and it’s really easy to make mistakes like this. Our current MSRV policy is a compromise between this sentiment and people not wanting random breakages in patch upgrades.(I edited the issue description to put solutions at the top of the page at this point in the thread.)
Just felt this through my direct dependency to
sqlx. I’m commenting here but I’m not sure who, sqlx or idna, is responsible in this case. (@hsivonen would appreciate your take here)minimal verifiable example:
And I get the same compilation error as @TotalKrill
The latest version of SQLx is
v0.8.2in the example, but in my original encounter itsv0.7.4.(for the benefit of solution-seekers pinning to
url = "=2.5.2"is the fix i am using for now.)cargo --version --verbose
rustc --version --verbose
Not sure if you need any more data but just wanted to add what i’m using to resolve the issue - as it just cameup today, and my fix seems to have resolved it for the time being. I just wanted to comment here because I ran into the same issue, and not sure if it’s resolved,
the error that i was getting trying to run this
cargo lambda build --release --arm64when using sqlx migrations,
was
error[E0658]: use of unstable library feature 'error_in_core' --> /Users/liamclancy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/idna-1.0.3/src/lib.rs:78:6I have resolved this locally by adding this to my dependencies.
idna = "=1.0.2"the issue only started happening today, so I assume it was the update to idna in the last week.
I see where you’re coming from, but I also slightly disagree: I think it’s pretty much a norm for crates to assume that splitting out code into a feature but including it in default is not a breaking change, so in this case you’re open to breakages.
It’s a tradeoff. There have been proposals for being able to say which version your feature spec is based on.
Posted a request for help with figuring out why Cargo is doing what it does: https://users.rust-lang.org/t/why-doesnt-cargo-compile-with-a-union-of-features/120716
Filed an sqlx issue: https://github.com/launchbadge/sqlx/issues/3589
Actually you are right, the
Cargo.tomlchange doesn’t help. It’s the--lockedarg ofcargo installthat’s the fix.For us, the issue was with this command:
cargo install sqlx-cli@0.7.3 --no-default-features --features native-tls,postgresUsed to work with Rust 1.77, but starting today it only works on 1.81+ – because ofidna1.0 getting installed. Our lockfile has already been specifyingidna0.5 though, now that I look at it.By appending
--lockedtocargo install sqlx-cli@0.7.3 --no-default-features --features native-tls,postgreswe make it so that the lockfile is respected, fixing installation. (It looks like there’s no alternative way to restrict transitive dependencies incargo install)@hsivonen I pinned
idnato0.5in Cargo.toml’s[dependencies]– seems to solve the issue. It also appears to be stemming from sqlx for usSo if you have
url2.5.3 without features andurl2.5.3 with the featurestd, Cargo should unify those to one copy ofurlwith the featurestd. Are you sure the edited comment aboutcargo treeis correct?Aside: This isn’t specific to idna. If I use Rust 1.80.1 with:
…
idnacompiles and the compilation ofurlfails with a complaint aboutimpl core::error::Error for ParseError {}inurl.url2.5.0 andurl2.5.2 depended onidna0.5.url2.5.1 depended onidna1.0.The introduction of
no_stdsupport tourlin 2.5.3 and the introduction ofcore::error::Errortoidnain 1.0.3 was intended not to change MSRV to 1.81 with default features but was expected to change MSRV to 1.81 fordefault-features = falseusers.Do you somehow have
url2.5.1 in your dependency graph? Can you force Cargo to takeurl2.5.3 in its place?running
cargo tree -i url -f "{p} {f}"this is what our tree ends up including, with two different versions of URL included, probably by one of our other deps.
Edit: I meant version 2.5.3, 2.5.0 is the version that compiles