Proxy内でRustをビルドする。

最近な言語は、コンパイルで必要なライブラリをGithub等から直接更新するようなものが多い。
そこで、必ずハマるのが、proxyに邪魔されて、ライブラリが取得できないようなこと。

[bash]
error: failed to load source for a dependency on `rand`
Caused by:
Unable to update registry https://github.com/rust-lang/crates.io-index
Caused by:
failed to fetch `https://github.com/rust-lang/crates.io-index`
To learn more, run the command again with –verbose.
[/bash]

Rustもそんな言語のひとつであるが、下記環境での設定方法を記載。
実際は、cargoの設定であるが。

Windowsの場合、Rustをインストールすると、ホームディレクトリに、.cargo というフォルダが存在する。
その中に、下記のファイルを作成し記述する。

C:\Users\myname\.cargo\config
[bash]
[http]
proxy = "http://user:password@host:port"
[/bash]

設定がOKであれば、レジストリから更新されコンパイルされ実行される。
[bash]
C:\Rust\main>cargo run
Updating registry `https://github.com/rust-lang/crates.io-index`
Compiling main v0.1.0 (file:///C:/Rust/main)
Finished debug [unoptimized + debuginfo] target(s) in 0.42 secs
Running `target\debug\main.exe`
[/bash]

なかなか楽しい。

This entry was posted in Rust, 技術情報. Bookmark the permalink.

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です