简体   繁体   中英

Set Proxy in 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

When I run

mix do deps.get, compile

I receive:

Could not find Hex, which is needed to build dependency :maru
Shall I install Hex? (if running non-interactively, use "mix local.hex --force" ) [Yn] y

** (Mix) httpc request failed with: {:could_no_establish_ssh_tunnel, {'HTTP/1.1', 407, 'Proxy Authorization Required'}}

Could not install Hex because Mix could not download metadata at https://repo.hex.pm/installs/hex-1.x.csv .

You should be able to export the proxy settings through environment variables.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM