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

WSL2 Ubuntu虚拟机安装Sui时编译diesel失败求助

问题:WSL2 Ubuntu中安装Sui时编译diesel失败(SIGKILL)

我首次提问,若信息不足请见谅。我正尝试在WSL2的Ubuntu虚拟机中安装Sui,使用Rust环境,对此也较为陌生。安装前已按要求安装所有前置依赖,执行命令:

cargo install --locked --git https://github.com/MystenLabs/sui.git --branch devnet sui

但Cargo在编译diesel时出错,进程终止,错误信息如下:

error: could not compile `diesel`

Caused by:
  process didn't exit successfully: `rustc --crate-name diesel --edition=2018 /home/antoine/.cargo/registry/src/github.com-1ecc6299db9ec823/diesel-2.0.3/src/lib.rs 
--error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat 
--diagnostic-width=120 --crate-type lib --emit=dep-info,metadata,link -C opt-level=3 -C panic=abort 
-C embed-bitcode=no -C split-debuginfo=packed -C debuginfo=1 --cfg 'feature="32-column-tables"' 
--cfg 'feature="64-column-tables"' --cfg 'feature="bitflags"' --cfg 'feature="byteorder"' 
--cfg 'feature="chrono"' --cfg 'feature="default"' 
--cfg 'feature="i-implement-a-third-party-backend-and-opt-into-breaking-changes"' --cfg 'feature="itoa"'
--cfg 'feature="postgres"' --cfg 'feature="postgres_backend"' --cfg 'feature="pq-sys"' 
--cfg 'feature="r2d2"' --cfg 'feature="serde_json"' --cfg 'feature="with-deprecated"' 
-C metadata=910cbefe446c683d -C extra-filename=-910cbefe446c683d 
--out-dir /tmp/cargo-installjxLb2t/release/deps -C strip=debuginfo 
-L dependency=/tmp/cargo-installjxLb2t/release/deps 
--extern bitflags=/tmp/cargo-installjxLb2t/release/deps/libbitflags-e5949a39186627ea.rmeta 
--extern byteorder=/tmp/cargo-installjxLb2t/release/deps/libbyteorder-2d235bc7037b2d93.rmeta 
--extern chrono=/tmp/cargo-installjxLb2t/release/deps/libchrono-2b0c9aaf0e3f3a01.rmeta 
--extern diesel_derives=/tmp/cargo-installjxLb2t/release/deps/libdiesel_derives-c7bad2300e3f2750.so 
--extern itoa=/tmp/cargo-installjxLb2t/release/deps/libitoa-353c8ba210cb8889.rmeta
--extern pq_sys=/tmp/cargo-installjxLb2t/release/deps/libpq_sys-48f4ec31a3125d17.rmeta 
--extern r2d2=/tmp/cargo-installjxLb2t/release/deps/libr2d2-e4794e946ea0d116.rmeta 
--extern serde_json=/tmp/cargo-installjxLb2t/release/deps/libserde_json-fc3f78b6b0c3ee9f.rmeta 
--cap-lints allow -L native=/usr/lib/x86_64-linux-gnu` (signal: 9, SIGKILL: kill)

我已为参数添加换行提升可读性。为排查问题,参考过其他编译diesel_cli的相关问题并安装对应依赖,但未解决;尝试单独安装diesel_cli:

cargo install diesel_cli

该操作成功,但仍无法完成Sui包的编译。


解决建议

1. 调整WSL2内存分配

SIGKILL大概率是编译进程因内存不足被系统终止。修改WSL2的内存配置:

  • 在Windows用户目录(C:\Users\<你的用户名>)下创建或编辑.wslconfig文件,写入:
    [wsl2]
    memory=8GB
    processors=4
    
  • 执行wsl --shutdown重启WSL后再尝试安装。

2. 降低编译优化级别

默认的opt-level=3优化会占用大量内存,临时降低优化级别编译:

CARGO_PROFILE_RELEASE_OPT_LEVEL=2 cargo install --locked --git https://github.com/MystenLabs/sui.git --branch devnet sui

3. 清理Cargo缓存

缓存损坏可能导致编译异常,清理后重试:

cargo clean

然后重新运行Sui安装命令。

4. 补全PostgreSQL开发依赖

Diesel的postgres特性需要完整的PostgreSQL开发库,执行以下命令安装:

sudo apt update && sudo apt install libpq-dev postgresql-client

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.20 01:05:04