gpt4 book ai didi

ubuntu - Rust Ubuntu 20.04.1安装问题

转载 作者:行者123 更新时间:2023-12-03 11:46:47 24 4
gpt4 key购买 nike

我刚刚在系统中安装了Rust,这是Ubuntu 20.04.1 64x。最后,一切看起来都还不错,但是我无法运行rustc:

$ rustc --version
Command 'rustc' not found, but can be installed with:
sudo snap install rustup # version 1.23.1, or
sudo apt install rustc # version 1.47.0+dfsg1+llvm-1ubuntu1~20.04.1
See 'snap info rustup' for additional versions.
我对 rust 完全陌生,我想尝试一下,但是这个问题使学习过程变得复杂。有人会提示如何解决该问题吗?

我访问了网络
https://www.rust-lang.org/tools/install
并使用其中的命令:

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


一切都按照网络上的概述进行:

Welcome to Rust!

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

It will add the cargo, rustc, rustup and other commands to Cargo's bindirectory, located at:

/home/daygeek/.cargo/bin

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

/home/daygeek/.profile/home/daygeek/.bash_profile

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

Current installation options:

default host triple: x86_64-unknown-linux-gnudefault toolchain: stablemodify PATH variable: yes

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

在这里我选择1个选项

info: syncing channel updates for 'stable-x86_64-unknown-linux-gnu'info: latest update on 2018-12-06, rust version 1.31.0 (abe02cefd 2018-12-04)info: downloading component 'rustc'77.7 MiB / 77.7 MiB (100 %) 1.2 MiB/s ETA: 0 s
info: downloading component 'rust-std'

54.2 MiB / 54.2 MiB (100 %) 1.2 MiB/s ETA: 0 s info: downloading component 'cargo'4.7 MiB / 4.7 MiB (100 %) 1.2 MiB/s ETA: 0 s info: downloading component 'rust-docs'8.5 MiB / 8.5 MiB (100 %) 1.2 MiB/s ETA: 0 s info: installing component 'rustc' info: installing component'rust-std' info: in

stalling component 'cargo' info: installing component 'rust-docs'info: default toolchain set to 'stable'

stable

installed - rus

tc 1.31.0 (abe02cefd 2018-12-04)


最后出现此消息:

Rust is installed now. Great!

To get started you need Cargo's bin directory ($HOME/.cargo/bin) inyour PATH environment variable. Next time you log in this will bedone automatically.

To

configure your current shell run source $HOME/.cargo/env


我搞砸了,我知道。现在,我需要一个解决方案,或者也许我应该再试一次,但是使用其他方法?

最佳答案

根据https://www.rust-lang.org/tools/install(您引用的安装站点),您需要确保PATH变量已更新。

In the Rust development environment, all tools are installed to the~/.cargo/bin directory, and this is where you will find the Rusttoolchain, including rustc, cargo, and rustup.

Accordingly, it is customary for Rust developers to include thisdirectory in their PATH environment variable. During installationrustup will attempt to configure the PATH. Because of differencesbetween platforms, command shells, and bugs in rustup, themodifications to PATH may not take effect until the console isrestarted, or the user is logged out, or it may not succeed at all.

If, after installation, running rustc --version in the console fails,this is the most likely reason.


通过执行 ~/.cargo/bin来检查PATH中是否存在 echo $PATH
如果没有,请尝试重新登录。
(有关需要如何手动更改PATH的信息,请参见 this question。)
您还可以检查 rustc中是否实际存在 ~/.cargo/bin

关于ubuntu - Rust Ubuntu 20.04.1安装问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66074738/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com