[1. 개요]
Windows 와 Linux 에서 Rust 개발환경 구축 방법을 기술한다.
[2. Windows]
아래 웹사이트에 접속해서 운영체제에 맞는 버전으로 설치파일을 다운 받는다.
https://www.rust-lang.org/en-US/install.html
다운받은 파일을 실행한다.
- rustup-init.exe
- Rustup metadata and toolchains will be installed into the Rustup home directory, located at: " ~~~ "
- This can be modified with the RUSTUP_HOME environment variable.
- The Cargo home directory is located at: " ~~~ "
- This can be modified with the CARGO_HOME environment variable.
1 을 입력하면 defaut 로 설치가 진행되며,
최초 설치시 기준으로 환경변수 RUSTUP_HOME 이 C:\Users\<user id>\.rustup 으로 설정된다.
다른 곳에 rust 를 설치하기를 원한다면
RUSTUP_HOME 과 CARGO_HOME 환경 변수를 먼저 설정 할 수 있도록 한다.
CARGO_HOME 에 rust 실행을 위한 바이너리 파일이 설치되고,
RUSTUP_HOME 에는 Rustup metadata 와 toolchains 이 설치된다.
설치 후 새로 cmd 창을 열어서 아래 명령어 동작을 확인한다.
$ rustc --version
$ cargo --version
[3. Linux]
curl 패키지를 먼저 설치 후, 아래 명령어를 실행한다.
$ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
이 후 과정은 설치 방법은 windows 와 동일하다.
다만, 리눅스의 경우 디폴트로 rust 바이너리 파일이 특정 사용자의 home 디렉터리 밑에 설치되므로,
시스템의 모든 계정에서 사용이 안될 수 있다.
다른 계정에서 rust 를 사용하기 위해서는
/usr/local/bin 등에 설치하는 것 이 좋을 듯 하다.
설치 후 환경 변수 값을 업데이트 할 수 있게 아래 명령어를 실행한다.
$ source "$HOME/.cargo/env"
이후 windows 와 마찬가지로 아래 명령어 동작을 확인한다.
(동작이 안될 경우 로그아웃 후 재접속 해보도록 한다.)
$ rustc --version
$ cargo --version
[4. 기타 error]
error: rustup could not choose a version of rustc to run, because one wasn't specified explicitly, and no default is configured. help: run 'rustup default stable' to download the latest stable release of Rust and set it as your default toolchain. |
=> execute "rustup default stable" |
info: default toolchain set to 'stable-x86_64-pc-windows-msvc' |