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

使用sudo构建Ubuntu镜像时遇scoped_threads编译错误求助

可行构建方案

方案1:让sudo继承rustup的环境变量

sudo默认不会加载用户的shell配置,因此无法识别rustup安装的nightly版本。可以通过两种方式解决:

  • 临时指定PATH执行构建:
    sudo env PATH=$PATH make image PROFILE=kstr-sama5d27
    
  • 永久配置sudo保留PATH:用visudo命令安全编辑/etc/sudoers,找到Defaults env_reset行,修改为:
    Defaults env_reset, env_keep += "PATH HOME"
    
    保存后重新登录,sudo即可识别rustup的nightly环境,之后直接运行原构建命令即可。

方案2:降级cargo-deb适配稳定版Rust

cargo-deb 1.41.3依赖的scoped_threads是Rust 1.63才稳定的特性,而你系统apt安装的rustc是1.61.0,可通过降级cargo-deb版本解决:

  1. 进入gpt-manipulator子模块目录:
    cd ubuntu-build/gpt-manipulator
    
  2. 编辑Cargo.toml,将cargo-deb的版本从1.41.3改为1.39.0(该版本不依赖scoped_threads,兼容1.61.0):
    cargo-deb = "1.39.0"
    
  3. 返回主目录重新执行构建:
    cd ..
    sudo make image PROFILE=kstr-sama5d27
    

方案3:预编译子模块再执行整体构建

既然单独编译gpt-manipulator无问题,可以先手动编译子模块,再让make跳过该模块的编译步骤:

  1. 单独编译gpt-manipulator:
    cd ubuntu-build/gpt-manipulator
    cargo build --release
    
  2. 将编译好的二进制文件复制到make预期的路径(可查看makefile中指定的gpt-manipulator输出位置,一般为target/release/gpt-manipulator):
    cp target/release/gpt-manipulator ../path/to/expected/location
    
  3. 执行make命令并跳过gpt-manipulator编译(若makefile支持跳过参数,比如SKIP_GPT_BUILD,或直接修改makefile注释掉该模块的编译逻辑):
    cd ..
    sudo make image PROFILE=kstr-sama5d27 SKIP_GPT_BUILD=1
    

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.09 23:01:37