Rust는 현재 개발중인 언어이며 지속적으로 바뀌고 있습니다. 따라서 새로운 기능이 필요하거나 컴파일러 버그를 덜 겪으려면 최대한 최근의 버전을 사용하는 게 좋습니다.
0.8, 0.9와 같은 버전이 붙은 릴리스는 개발 일정 관리를 위해서만 존재하기 때문에 3개월에 한 번씩만 만들어집니다. 그래서 최신 버전(master 버전이라고 부릅니다)의 소스를 받아서 컴파일하는 게 가장 좋습니다. 하지만 컴파일이 어렵거나 시간이 많이 걸린다면 비교적 최근(1~2주 이내)의 master를 미리 컴파일해 놓은 나이틀리 스냅샷(nightly snapshot)을 사용하는 것도 한 방법입니다.
주의: 이 문서에서 언급하는 모든 나이틀리 스냅샷은 Rust 개발팀이 관여하지 않는 비공식 버전입니다. 이 버전을 사용해서 생기는 모든 문제에 대한 책임은 여러분에게 있습니다. 아직까지는 별로 그런 일은 없었지만, 혹시나 해서요.
팁: 리눅스를 사용하는 것 같은데 배포판을 잘 모르겠다면 먼저
python -m platform
을 쳐서 중간에Ubuntu
가 나오는지 확인해 보세요.python
이 없다고 나올 경우cat /etc/lsb-release
를 대신 해 보셔도 됩니다.
Hans Jørgen Hoel이 관리하는 우분투용 Rust 나이틀리 스냅샷을 사용합니다.
터미널에서 다음 명령을 입력하고 지시를 따르면 설치됩니다.
관리자 모드(sudo
)를 쓰기 위해 로그인된 계정의 암호를 입력해야 할 수 있습니다.
$ sudo add-apt-repository ppa:hansjorg/rust
$ sudo apt-get update
$ sudo apt-get install rust-nightly
혹은 rust-0.8
, rust-0.9
등을 대신 설치할 수도 있습니다.
나중에 업데이트를 하려면 마지막 두 명령만 되풀이하면 됩니다.
(혹은 sudo apt-get upgrade
로 Rust를 포함한 모든 패키지를 업데이트할 수 있습니다.)
$ sudo apt-get update
$ sudo apt-get install rust-nightly
팁: 여러 개의
rustc
가 설치되었을 경우 각 릴리스는/usr/lib/rust-<버전>/bin/rustc
에 들어가고 마지막으로 설치되거나 업데이트된 버전만rustc
에 심볼릭 링크됩니다. 심볼릭 링크를 바꾸려면 우분투의 링크 관리 기능을 사용합니다.$ sudo update-alternatives --config rustc 대체 항목 rustc에 대해 (/usr/bin/rustc 제공) 3개 선택이 있습니다. 선택 경로 우선순 상태 ------------------------------------------------------------ * 0 /usr/lib/rust/rust-nightly/bin/rustc 150 자동 모드 1 /usr/lib/rust/rust-0.8/bin/rustc 80 수동 모드 2 /usr/lib/rust/rust-0.9/bin/rustc 90 수동 모드 3 /usr/lib/rust/rust-nightly/bin/rustc 150 수동 모드 기본 사항[*]을 사용하려면 엔터, 다른 것을 사용하려면 번호를 입력하십시오:
MinGW 인스톨러를 받아서 실행한 뒤 지시에 따릅니다. 그래픽 패키지 매니저를 설치할지 선택하는 칸이 있는데 선택해도 되지만 여기서는 사용하지 않습니다.
팁: 그래픽 패키지 매니저를 실수로 안 설치했을 경우
mingw-get install mingw-get-gui
명령을 사용해서 나중에 설치할 수 있습니다.
MinGW는 기본적으로 PATH
환경 변수에 추가되지 않습니다.
rustc
를 아무데서나 실행하려면 이 환경 변수가 필요하므로, MinGW 실행파일이 위치한 경로를 PATH
에 추가해 줍니다.
(기본값대로 설치했다면 C:\MinGW\bin
을 뒤에 넣으면 됩니다.)
제어판의 [시스템] → [고급 시스템 설정] (또는 [고급]) → [환경 변수]에서 설정할 수 있습니다.
명령 프롬포트를 열고 다음을 입력합니다.
> mingw-get install mingw32-base
팁: 이 명령은 C 컴파일러도 함께 설치합니다. C 컴파일이 필요 없다면
mingw-get install gcc
만 해도 됩니다.
다음으로, Chocolatey를 설치합니다. 홈페이지에 나와 있는 명령을 복사해서 명령 프롬포트에 붙여 넣으세요. (명령 프롬포트 창의 오른쪽 위 아이콘을 눌러서 [편집] → [붙여넣기]를 선택합니다.)
> @powershell -NoProfile -ExecutionPolicy unrestricted -Command "iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))" && SET PATH=%PATH%;%systemdrive%\chocolatey\bin
이제 Chocolatey를 사용하여 Rust를 설치합니다. Heather가 관리하는 NuGet Rust 패키지를 사용합니다. 패키지가 120MB 정도에 달하기 때문에 다운로드에 다소 시간이 걸릴 수 있습니다.
> cinst Rust
팁: cinst를 실행하고 얼마 안 지나 "Unable to read package from path" 오류가 날 경우, 기존 NuGet 캐시와 충돌이 나서 패키지가 덜 받아졌을 경우가 대부분입니다.
%AppData%\Local\NuGet\Cache
에서Rust
로 시작하는 파일을 삭제하고 다시 시도하세요.
설치가 종료되면 C:\Chocolatey\lib\Rust.<버전>\bin
에 rustc.exe
등이 설치됩니다.
명령 프롬포트에서 rustc -v
를 입력해서 올바른 버전이 설치되었는지 확인해 보세요.
나중에 업데이트를 하려면 Chocolatey의 업데이트 기능을 이용합니다.
> cup Rust
MinGW에는 유닉스 셸을 흉내내는 MSYS라는 서브시스템이 있습니다.
이 서브시스템은 Rust 컴파일러를 포함해서 make
같은 유닉스 빌드 시스템을 쓰는 프로젝트를 위해 필요합니다.
MSYS를 설치하려면 다음 명령을 실행합니다.
> mingw-get install msys-base
이제 MinGW 디렉토리 안의 msys\1.0\msys.bat
를 실행하면 MSYS 셸이 뜹니다.
팁: MSYS를 설치해도 자동으로 바로가기가 만들어지진 않습니다.
msys.bat
에 대한 바로가기를 만드는 걸 추천합니다.
팁: 만약 MinGW를 위에 제시된 방법으로 설치해 쓰지 않는다면, 특히
PATH
에 MinGW가 없다면, 셸 안에서/postinstall/pi.sh
를 실행해서 지시에 따르셔야 합니다. (보통은 필요 없습니다.)
Chocolatey로 설치한 rustc
는 MSYS에서도 큰 문제 없이 동작합니다만,
Chocolatey가 배치 파일을 사용하는데 MSYS 셸이 (현재는) 배치 파일을 지원하지 않아서 바로 실행할 수 없습니다.
따라서 MinGW 디렉토리 안에 다음과 같은 파일을 따로 만들어 주어야 합니다.
msys\1.0\bin\rustc
msys\1.0\bin\rustdoc
msys\1.0\bin\rustpkg
각 파일에는 다음과 같은 내용을 집어 넣으면 됩니다.
#!/bin/sh
cmd //c $(basename "$0") "$@"
이렇게 하면 MSYS에서도 rustc
등의 명령을 사용할 수 있습니다.
Rust is in the continuous development and thus changes over time. You have to use the most recent version for the recent language features and/or more stable compiler.
The point releases (0.8, 0.9 etc.) are mostly for the development milestones, and thus only released once every three months. Therefore it is best to compile a source code for the most recent version (a.k.a. "master" version). But compiling Rust is time-consuming and often does not work, so there are nightly snapshots which are pre-compiled binaries for relatively recent (up to one or two weeks ago) master.
WARNING: Every nightly snapshot mentioned in this document is unofficial and not maintained by the Rust core team. You are fully responsible for any problems due to the use of nightly snapshots. There were no such problems so far, but I just want to make it sure.
TIP: If you think you are using Linux but are not sure about the distros, make sure that
python -m platform
gives some text withUbuntu
inside. Ifpython
does not exist, trycat /etc/lsb-release
instead.
We will use Rust PPA maintained by Hans Jørgen Hoel.
Type the following commands in the console and follow the instructions.
You may have to type your password to use the administrative mode (sudo
).
$ sudo add-apt-repository ppa:hansjorg/rust
$ sudo apt-get update
$ sudo apt-get install rust-nightly
You can also install rust-0.8
, rust-0.9
and so on instead.
Repeat the second and third line when upgrading.
(Or use sudo apt-get upgrade
for upgrading every installed package including Rust.)
$ sudo apt-get update
$ sudo apt-get install rust-nightly
TIP: Multiple
rustc
s are installed in/usr/lib/rust-VERSION/bin/rustc
and the most recently installed or upgrade one is symbolic-linked torustc
. You need to use Ubuntu's alternatives facility to change that.$ sudo update-alternatives --config rustc There are 3 choices for the alternative rustc (providing /usr/bin/rustc). Selection Path Priority Status ------------------------------------------------------------ * 0 /usr/lib/rust/rust-nightly/bin/rustc 150 auto mode 1 /usr/lib/rust/rust-0.8/bin/rustc 80 manual mode 2 /usr/lib/rust/rust-0.9/bin/rustc 90 manual mode 3 /usr/lib/rust/rust-nightly/bin/rustc 150 manual mode Press enter to keep the current choice[*], or type selection number:
Download and run the MinGW installer and follow the instructions. There is a checkbox for whether to install the graphical user interface, which we will not use but nevertheless may be useful.
TIP: You can install the GUI later using
mingw-get install mingw-get-gui
.
MinGW, by default, does not append itself to the PATH
environment variable.
Since running rustc
anywhere requires this environment variable,
you should append a path to the MinGW executables to PATH
in the control panel.
(In the default settings, the path would be C:\MinGW\bin
.)
Turn the Command Prompt on and type the following.
> mingw-get install mingw32-base
TIP: This would install the C compiler. If you don't want it, use
mingw-get install gcc
instead.
Install Chocolatey by copying the command line in the website and pasting it into the Command Prompt.
> @powershell -NoProfile -ExecutionPolicy unrestricted -Command "iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))" && SET PATH=%PATH%;%systemdrive%\chocolatey\bin
Then install Rust using Chocolatey. We will use the NuGet Rust package maintained by Heather. It would take some time as it weighs about 120 MB.
> cinst Rust
TIP: If you get the "Unable to read package from path" error shortly after
cinst
, you have the incomplete NuGet package cache. Delete everything starting withRust
in%AppData%\Local\NuGet\Cache
and try again.
cinst
would install C:\Chocolatey\lib\Rust.VERSION\bin\rustc.exe
and so on.
Try rustc -v
out in the Command Prompt and check if it installs the correct version.
You can update the Rust installation using Chocolatey later.
> cup Rust
MinGW has a subsystem named MSYS which emulates a conventional Unix shell.
This subsystem is required for projects depending on Unix build systems like make
,
and it's a must for building the Rust compiler.
Type the following in order to install MSYS.
> mingw-get install msys-base
Then run msys\1.0\msys.bat
in the MinGW directory.
TIP: Installing MSYS does not automatically generate a shortcut to it. You are recommended to make a shortcut for
msys.bat
.
TIP: If you've installed MSYS in your own way, and especially if you don't have a path to MinGW in
PATH
, then you need to run/postinstall/pi.sh
in the MSYS shell and follow the instructions. (You normally don't need that, however.)
rustc
installed via Chocolatey works well with MSYS,
but you can't directly run it since the MSYS shell (currently) can't run batch files generated by Chocolatey.
You need to make the following files in the MinGW directory by hand...
msys\1.0\bin\rustc
msys\1.0\bin\rustdoc
msys\1.0\bin\rustpkg
...with the following contents.
#!/bin/sh
cmd //c $(basename "$0") "$@"
You can now use rustc
directly in the MSYS shell.