WSL1安装rust报错thread ‘main‘ panicked的解决方法

根据https://www.rust-lang.org/tools/install,WSL安装rust使用命令

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

报错

info: downloading installer

Welcome to Rust!

This will download and install the official compiler for the Rust
programming language, and its package manager, Cargo.

Rustup metadata and toolchains will be installed into the Rustup
home directory, located at:

  /home/ayka_tsuzuki/.rustup

This can be modified with the RUSTUP_HOME environment variable.

The Cargo home directory located at:

  /home/ayka_tsuzuki/.cargo

This can be modified with the CARGO_HOME environment variable.

The cargo, rustc, rustup and other commands will be added to
Cargo's bin directory, located at:

  /home/ayka_tsuzuki/.cargo/bin

This path will then be added to your PATH environment variable by
modifying the profile files located at:

  /home/ayka_tsuzuki/.profile
  /home/ayka_tsuzuki/.zprofile

You can uninstall at any time with rustup self uninstall and
these changes will be reverted.

Current installation options:


   default host triple: x86_64-unknown-linux-gnu
     default toolchain: stable (default)
               profile: default
  modify PATH variable: yes

1) Proceed with installation (default)
2) Customize installation
3) Cancel installation
>1

info: profile set to 'default'
info: default host triple is x86_64-unknown-linux-gnu
info: syncing channel updates for 'stable-x86_64-unknown-linux-gnu'
462.8 KiB / 462.8 KiB (100 %) 108.0 KiB/s in  4s ETA:  0s
info: latest update on 2020-08-03, rust version 1.45.2 (d3fb005a3 2020-07-31)
info: downloading component 'cargo'
info: downloading component 'clippy'
info: downloading component 'rust-docs'
info: downloading component 'rust-std'
info: downloading component 'rustc'
info: downloading component 'rustfmt'
info: installing component 'cargo'
info: Defaulting to 500.0 MiB unpack ram
thread 'main' panicked at 'assertion failed: `(left == right)`
  left: `22`,
 right: `4`', src/libstd/sys/unix/thread.rs:179:21
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'main' panicked at 'assertion failed: `(left == right)`
  left: `22`,
 right: `4`', src/libstd/sys/unix/thread.rs:179:21
stack backtrace:
   0:     0x7f0f95edaffd - backtrace::backtrace::libunwind::trace::h812748238d609e46
                               at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/libunwind.rs:86
   1:     0x7f0f95edaffd - backtrace::backtrace::trace_unsynchronized::h7c97e818aebf09c8
                               at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/mod.rs:66
   2:     0x7f0f95edaffd - std::sys_common::backtrace::_print_fmt::h60d914263b0ccd71
                               at src/libstd/sys_common/backtrace.rs:78
   3:     0x7f0f95edaffd - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hf78227137afc7565
                               at src/libstd/sys_common/backtrace.rs:59
   4:     0x7f0f95b6524c - core::fmt::write::h543cdf60775f89bf
                               at src/libcore/fmt/mod.rs:1069
   5:     0x7f0f95eda904 - std::io::Write::write_fmt::h0c7f3ce24c679426
                               at src/libstd/io/mod.rs:1504
   6:     0x7f0f95eda105 - std::sys_common::backtrace::_print::h80e55e24be231368
                               at src/libstd/sys_common/backtrace.rs:62
   7:     0x7f0f95eda105 - std::sys_common::backtrace::print::h3b197b9c1261c865
                               at src/libstd/sys_common/backtrace.rs:49
   8:     0x7f0f95eda105 - std::panicking::default_hook::{{closure}}::ha6c807149ce20f8f
                               at src/libstd/panicking.rs:198
   9:     0x7f0f95ed98f4 - std::panicking::default_hook::he49a9c12e358cc45
                               at src/libstd/panicking.rs:218
  10:     0x7f0f95ed93b6 - std::panicking::rust_panic_with_hook::h93f74f5ef2f71f31
                               at src/libstd/panicking.rs:515
  11:     0x7f0f95ed9198 - rust_begin_unwind
                               at src/libstd/panicking.rs:419
  12:     0x7f0f95ed9140 - std::panicking::begin_panic_fmt::hfa6ef29ba81f400e
                               at src/libstd/panicking.rs:373
  13:     0x7f0f95e11671 - <rustup::diskio::threaded::Threaded as rustup::diskio::Executor>::join::habf6ee901a47a8a4
  14:     0x7f0f95e10c78 - core::ptr::drop_in_place::h0b1b0dcb4b07c267
  15:     0x7f0f95d76c40 - core::ptr::drop_in_place::h09572fbec04e583f
  16:     0x7f0f95e2842e - rustup::dist::component::package::unpack_without_first_dir::h99f4b0c2cae349ff
  17:     0x7f0f95de559f - rustup::dist::manifestation::Manifestation::update::hacf67fad3b44f03a
  18:     0x7f0f95dd563c - rustup::dist::dist::update_from_dist_::h1462627f9c58c494
  19:     0x7f0f95dd227a - rustup::install::InstallMethod::install::hbb6430b2dfaf5792
  20:     0x7f0f95dd0d21 - rustup::toolchain::DistributableToolchain::install_from_dist::h7b9bf9317c9aa2c5
  21:     0x7f0f95ec5aa2 - rustup::cli::self_update::install::h8ca0f61a773526a9
  22:     0x7f0f95ecbd3d - rustup::cli::setup_mode::main::h4d335e1871435d70
  23:     0x7f0f95adf42a - rustup_init::main::h22da971c634937a2
  24:     0x7f0f95ef3e83 - std::rt::lang_start_internal::{{closure}}::{{closure}}::h4ed4ab1fb893cc93
                               at src/libstd/rt.rs:52
  25:     0x7f0f95ef3e83 - std::sys_common::backtrace::__rust_begin_short_backtrace::h1f01c818c00c4f70
                               at src/libstd/sys_common/backtrace.rs:130
  26:     0x7f0f95ae053f - main
  27:     0x7f0f956a70b3 - __libc_start_main
  28:     0x7f0f95adb029 - <unknown>
thread panicked while panicking. aborting.
Illegal instruction (core dumped)

参考GitHub库rust-lang/rustup的issue #2245:rustup panic with WSLv1 + glibc 2.31,一种办法是将WSL1升级到WSL2:

wsl --set-default-version 2
wsl --list --verbose
wsl --set-version Ubuntu-20.04 2

然后再执行安装命令;另一种办法是在.bashrc或.bash_profile(如果用的Shell是ZSH则在.zshrc)中插入

export RUSTUP_IO_THREADS=1

然后source .zshrc,或直接在命令行中输入该命令执行,然后再执行安装rust命令,即可成功安装:

info: downloading installer

Welcome to Rust!

This will download and install the official compiler for the Rust
programming language, and its package manager, Cargo.

Rustup metadata and toolchains will be installed into the Rustup
home directory, located at:

  /home/ayka_tsuzuki/.rustup

This can be modified with the RUSTUP_HOME environment variable.

The Cargo home directory located at:

  /home/ayka_tsuzuki/.cargo

This can be modified with the CARGO_HOME environment variable.

The cargo, rustc, rustup and other commands will be added to
Cargo's bin directory, located at:

  /home/ayka_tsuzuki/.cargo/bin

This path will then be added to your PATH environment variable by
modifying the profile files located at:

  /home/ayka_tsuzuki/.profile
  /home/ayka_tsuzuki/.zprofile

You can uninstall at any time with rustup self uninstall and
these changes will be reverted.

Current installation options:


   default host triple: x86_64-unknown-linux-gnu
     default toolchain: stable (default)
               profile: default
  modify PATH variable: yes

1) Proceed with installation (default)
2) Customize installation
3) Cancel installation
>1

info: profile set to 'default'
info: default host triple is x86_64-unknown-linux-gnu
info: syncing channel updates for 'stable-x86_64-unknown-linux-gnu'
462.8 KiB / 462.8 KiB (100 %) 416.0 KiB/s in  1s ETA:  0s
info: latest update on 2020-08-03, rust version 1.45.2 (d3fb005a3 2020-07-31)
info: downloading component 'cargo'
info: downloading component 'clippy'
info: downloading component 'rust-docs'
info: downloading component 'rust-std'
info: downloading component 'rustc'
info: downloading component 'rustfmt'
info: installing component 'cargo'
info: Defaulting to 500.0 MiB unpack ram
info: installing component 'clippy'
info: installing component 'rust-docs'
 12.2 MiB /  12.2 MiB (100 %) 459.2 KiB/s in 16s ETA:  0s
info: installing component 'rust-std'
 15.9 MiB /  15.9 MiB (100 %)  11.8 MiB/s in  1s ETA:  0s
info: installing component 'rustc'
 47.1 MiB /  47.1 MiB (100 %)  11.6 MiB/s in  4s ETA:  0s
info: installing component 'rustfmt'
info: default toolchain set to 'stable'

  stable installed - rustc 1.45.2 (d3fb005a3 2020-07-31)

【注意:使用Vundle安装vim插件YCM(YouCompleteMe)时需要使用Rust编译安装会自动安装Rust也会出现该问题,也需使用该方法解决】

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
要在WSL2上安装Rust,您可以按照以下步骤进行操作: 1. 首先,确保您已经安装WSL2并配置好了开发环境。如果您还没有安装WSL2,请按照引用或引用中的文章指南来安装和设置WSL2。 2. 打开WSL2终端(Ubuntu),运行以下命令来更新软件包列表: ``` sudo apt update ``` 3. 接下来,安装构建工具和依赖项,可以使用以下命令: ``` sudo apt install build-essential ``` 4. 然后,您可以通过下载和运行Rust安装脚本来安装Rust。在终端中运行以下命令: ``` curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh ``` 这将自动下载并运行Rust安装脚本。按照提示选择默认选项进行安装。 5. 安装完成后,您需要将Rust工具链添加到您的环境变量中。在终端中运行以下命令: ``` source $HOME/.cargo/env ``` 这将使您能够在WSL2中使用Rust命令。 6. 最后,您可以验证Rust是否成功安装。在终端中运行以下命令: ``` rustc --version ``` 如果您成功安装Rust,您将看到Rust的版本信息。 现在,您已经在WSL2上成功安装Rust,并可以开始使用它进行开发了。祝您使用愉快!<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [Rust : WSL下编程](https://download.csdn.net/download/weixin_38604951/14042184)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *2* *3* [wsl 安装 rust_在wsl2上调试rust代码](https://blog.csdn.net/weixin_26755331/article/details/108898821)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Ayka

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值