LoginSignup
9
5

More than 5 years have passed since last update.

Proxy内でRustをビルドする

Posted at

最近な言語は、コンパイルで必要なライブラリを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もそんな言語のひとつであるが、Windows環境での設定方法を記載。
実際には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`

なかなか楽しい。

9
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
5