Debian 11.2にRustをインストールしてHello Worldを出力する
環境
# cat /etc/debian_version
11.2
1.Rubyをインストールします
# 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:
/opt/rust
This can be modified with the RUSTUP_HOME environment variable.
The Cargo home directory located at:
/root/.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:
/root/.cargo/bin
This path will then be added to your PATH environment variable by
modifying the profile files located at:
/root/.profile
/root/.bashrc
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
> #ENTERを入力するとdefaultがインストールされます
略
Rust is installed now. Great!
To get started you may need to restart your current shell.
This would reload your PATH environment variable to include
Cargo's bin directory ($HOME/.cargo/bin).
To configure your current shell, run:
source $HOME/.cargo/env
# 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:
/opt/rust
This can be modified with the RUSTUP_HOME environment variable.
The Cargo home directory located at:
/root/.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:
/root/.cargo/bin
This path will then be added to your PATH environment variable by
modifying the profile files located at:
/root/.profile
/root/.bashrc
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
> #ENTERを入力するとdefaultがインストールされます
略
Rust is installed now. Great!
To get started you may need to restart your current shell.
This would reload your PATH environment variable to include
Cargo's bin directory ($HOME/.cargo/bin).
To configure your current shell, run:
source $HOME/.cargo/env
# 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: /opt/rust This can be modified with the RUSTUP_HOME environment variable. The Cargo home directory located at: /root/.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: /root/.cargo/bin This path will then be added to your PATH environment variable by modifying the profile files located at: /root/.profile /root/.bashrc 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 > #ENTERを入力するとdefaultがインストールされます 略 Rust is installed now. Great! To get started you may need to restart your current shell. This would reload your PATH environment variable to include Cargo's bin directory ($HOME/.cargo/bin). To configure your current shell, run: source $HOME/.cargo/env
2.シェルを再起動します
# exec $SHELL -l
# exec $SHELL -l
# exec $SHELL -l
3.cargoバージョンを確認します
# cargo --version
cargo 1.59.0 (49d8809dc 2022-02-10)
# cargo --version
cargo 1.59.0 (49d8809dc 2022-02-10)
# cargo --version cargo 1.59.0 (49d8809dc 2022-02-10)
rustcバージョンを確認します
# rustc -V
rustc 1.59.0 (9d1b2106e 2022-02-23)
# rustc -V
rustc 1.59.0 (9d1b2106e 2022-02-23)
# rustc -V rustc 1.59.0 (9d1b2106e 2022-02-23)
rustupバージョンを確認します
# rustup -V
rustup 1.24.3 (ce5817a94 2021-05-31)
info: This is the version for the rustup toolchain manager, not the rustc compiler.
info: The currently active `rustc` version is `rustc 1.59.0 (9d1b2106e 2022-02-23)`
# rustup -V
rustup 1.24.3 (ce5817a94 2021-05-31)
info: This is the version for the rustup toolchain manager, not the rustc compiler.
info: The currently active `rustc` version is `rustc 1.59.0 (9d1b2106e 2022-02-23)`
# rustup -V rustup 1.24.3 (ce5817a94 2021-05-31) info: This is the version for the rustup toolchain manager, not the rustc compiler. info: The currently active `rustc` version is `rustc 1.59.0 (9d1b2106e 2022-02-23)`
4.Rustプロジェクトを作成
# cargo new rust-cft
Created binary (application) `rust-cft` package
# cargo new rust-cft
Created binary (application) `rust-cft` package
# cargo new rust-cft Created binary (application) `rust-cft` package
# cd rust-cft
# cargo run
Compiling rust-cft v0.1.0 (/root/rust-cft)
Finished dev [unoptimized + debuginfo] target(s) in 1.66s
Running `target/debug/rust-cft`
Hello, world!
Compiling rust-cft v0.1.0 (/root/rust-cft)
Finished dev [unoptimized + debuginfo] target(s) in 1.66s
Running `target/debug/rust-cft`
Hello, world!
Compiling rust-cft v0.1.0 (/root/rust-cft) Finished dev [unoptimized + debuginfo] target(s) in 1.66s Running `target/debug/rust-cft` Hello, world!