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

安装wasm-pack时编译time v0.3.34出现E0602错误如何解决?

问题:Ubuntu下执行cargo install wasm-pack编译失败

在Ubuntu系统上执行cargo install wasm-pack时,编译过程中出现大量编译提示后报错,使用的Cargo版本为1.75.0,错误信息如下:

Compiling time v0.3.34
error[E0602]: unknown lint: `invalid_reference_casting`
  |
  = note: requested on the command line with `-D invalid_reference_casting`

error[E0602]: unknown lint: `invalid_nan_comparisons`
  |
  = note: requested on the command line with `-D invalid_nan_comparisons`

error[E0602]: unknown lint: `invalid_from_utf8`
  |
  = note: requested on the command line with `-D invalid_from_utf8`

error[E0602]: unknown lint: `hidden_glob_reexports`
  |
  = note: requested on the command line with `-D hidden_glob_reexports`

   Compiling object v0.32.2
   Compiling pbkdf2 v0.11.0
For more information about this error, try `rustc --explain E0602`.
error: could not compile `time` (lib) due to 4 previous errors
warning: build failed, waiting for other jobs to finish...

原因分析

报错中提到的invalid_reference_casting、invalid_nan_comparisons等lint规则是Rust 1.77及以上版本才新增的检查项,而Cargo 1.75.0对应的Rust编译器版本为1.75.0,不支持这些新lint,导致编译依赖包time v0.3.34时失败。

解决方法

方法1:升级Rust到最新稳定版

执行以下命令升级Rust工具链,使其支持新的lint规则:

rustup update stable

升级完成后,重新运行安装命令即可:

cargo install wasm-pack

方法2:安装兼容旧Rust版本的wasm-pack

如果不想升级Rust,可以指定安装旧版本的wasm-pack,其依赖不会用到这些新lint规则:

cargo install wasm-pack --version 0.12.1

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.30 17:33:11