Archive for: 𔃳月 2017’

Proxy内でRustをビルドする。

2017年3月16日 Posted by PURGE

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

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.

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

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

C:\Users\myname\.cargo\config

[http]
proxy = "http://user:password@host:port"

設定がOKであれば、レジストリから更新されコンパイルされ実行される。

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`

なかなか楽しい。