You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Rust工具链修复后出现futures-util编译依赖冲突问题求助

Rust工具链修复后futures-util编译依赖问题解决

问题描述

  • 原有Rust代码运行正常,突发工具链错误:

error: the 'rustc.exe' binary, normally provided by the 'rustc' component, is not applicable to the 'stable-x86_64-pc-windows-msvc' toolchain

  • 执行rustup toolchain install stable修复工具链后,运行cargo run出现futures-util编译失败,错误退出码1263094860,推测为Tokio与手动指定的futures版本不兼容导致依赖冲突。
  • 项目Cargo.toml配置如下:
[package]
name = "rusting"
version = "0.1.0"
edition = "2021"

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

[dependencies]
rand = "0.8.5"
schnorr_fun = "0.8.2"
chrono = "0.4.24"
tokio = { version = "1.27.0", features = ["full"] }
futures = "0.3.28"
schnorrkel = "0.10.2"
serde_json = "1.0.95"

解决步骤

  • 定位冲突细节:执行cargo tree -e features -p futures-util,该命令会列出所有依赖对futures-util的版本、特性要求,明确冲突根源。
  • 移除手动指定的futures依赖:Tokio 1.x内置兼容的futures 0.3版本,手动指定版本易引发冲突。代码中若使用futures API,直接通过Tokio间接引入的版本即可。
  • 清理缓存重新构建:执行cargo clean清除旧编译缓存,再运行cargo run重新编译。
  • 如需保留futures依赖:将版本改为与Tokio兼容的范围。先执行cargo tree -p tokio查看Tokio依赖的具体futures版本,再将Cargo.toml中的futures = "0.3.28"改为对应兼容版本(例如Tokio 1.27.0通常依赖futures 0.3.21,可写为futures = "0.3.21"或兼容范围futures = "^0.3.21")。

内容的提问来源于stack exchange,提问作者Zubayr

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.24 00:00:30