在Mix中设置代理

时间:2018-04-25 19:14:12

标签: elixir mix

defmodule Elixirrest.MixProject do
  use Mix.Project

  def project do
    [
      app: :elixirrest,
      version: "0.1.0",
      elixir: "~> 1.6",
      start_permanent: Mix.env() == :prod,
      deps: deps()
    ]
  end

  # Run "mix help compile.app" to learn about applications.
  def application do
    [
      extra_applications: [:logger]
    ]
  end

  # Run "mix help deps" to learn about dependencies.
  defp deps do
    [
      {:maru, "~> 0.13"}
    ]
  end
end

当我跑步时

mix do deps.get, compile

我收到:

  

无法找到构建依赖关系:maru所需的十六进制   我要安装Hex吗? (如果以非交互方式运行,请使用"mix local.hex --force")[Yn] y

     

**(混合)httpc请求失败:{:could_no_establish_ssh_tunnel,{'HTTP / 1.1',407,'需要代理授权'}}

     

无法安装Hex,因为Mix无法在https://repo.hex.pm/installs/hex-1.x.csv下载元数据。

1 个答案:

答案 0 :(得分:0)

您应该能够通过环境变量导出代理设置。

https://github.com/elixir-lang/elixir/blob/ab302d23e4b632486645cdf0fcc392e66b7abb99/lib/mix/lib/mix/utils.ex#L609-L614

  defp proxy_env do
    http_proxy = System.get_env("HTTP_PROXY") || System.get_env("http_proxy")
    https_proxy = System.get_env("HTTPS_PROXY") || System.get_env("https_proxy")
    no_proxy = no_proxy_env() |> no_proxy_list()

    {proxy_setup(:http, http_proxy, no_proxy), proxy_setup(:https, https_proxy, no_proxy)}
  end