hexpm / hex

Package manager for the Erlang ecosystem.
https://hex.pm
973 stars 185 forks source link

mix failed to fetch hex package even I set hex proxy #707

Closed taijitao closed 4 years ago

taijitao commented 5 years ago

Hi,

  1. I installed the erlang through yum, and git clone elixir, hex.
  2. after installed elixir, hex, I tried to run mix local.hex under hex directory.
  3. I tried to build a rabbitmq plugin.
    
    # mix hex.info
    Hex:    0.20.1
    Elixir: 1.9.1
    OTP:    21.3.8.6

Built with: Elixir 1.9.1 and OTP 21.3.8.6

it reported:

Failed to fetch record for 'hexpm/recon' from registry (using cache instead) :timeout ** (Mix) No package with name recon (from: mix.exs) in registry

`I moved to the plugin directory and run # > mix deps.get`
it reported the same error.
I tried to set  proxy like:
mix hex.config http_proxy http://87.254.212.120:8080
mix hex.config https_proxy https://87.254.212.120:8080

mix hex.config

api_key: nil (default) api_url: "https://hex.pm/api" (default) diff_command: "git diff --no-index PATH1 PATH2" (default) home: "/root/.hex" (default) http_concurrency: 8 (default) http_proxy: "87.254.212.120:8080" (using http_proxy) http_timeout: nil (default) https_proxy: "87.254.212.120:8080" (using https_proxy) mirror_url: "http://hexpm.upyun.com/" (using /root/.hex/hex.config) no_verify_repo_origin: false (default) offline: false (default) repos_key: nil (default) resolve_verbose: false (default) unsafe_https: false (default) unsafe_registry: false (default) and use tshark to capture the package.


Even it set the  proxy, mix reported the same error. I used tshark to captured the package, and found
mix still sending package to hexpm directly instead of proxy.

I tried to use curl throught proxy, I could access the https://hex.pm and http://hexpm.upyun.com/.

any suggestions will be appreciated.

B.R,
Tao
ericmj commented 5 years ago

I cannot reproduce this error. If I set mix hex.config http_proxy hex will use the config for me. Can you show how you build the rabbitmq plugin?

You do not have to clone hex, mix local.hex will download and install the latest release.

taijitao commented 5 years ago

Hi, I think it's not related to the rabbitmq plugin. I use

# git clone https://github.com/rabbitmq/rabbitmq-auth-backend-oauth2.git
# cd rabbitmq-auth-backend-oauth2
# make

I tried to install hex as you said(I'm new to elixir, hex)

[root@localhost vagrant]# export https_proxy=135.245.48.34:8000
[root@localhost vagrant]# mix hex.config http_proxy http://135.245.48.34:8000
[root@localhost vagrant]# mix local.hex
** (Mix) request timed out after 60000ms

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

[root@localhost vagrant]# curl -s https://repo.hex.pm/installs/hex-1.x.csv
0.14.0,b8a849be7e731f8d844229c029107e281364b55fe257d0f6d6ea9f7224d8c414d2ec2f0dee4bcdd9bc7672cab6c9d19e7e6bbb0539c740678fb6047821ce363d,1.0.0

From tshark, it only captures the package between localhost and hex.pm

[root@localhost rabbitmq_mqtt]# tshark -n -i any host 10.0.2.15
Running as user "root" and group "root". This could be dangerous.
Capturing on 'any'
  1 0.000000000    10.0.2.15 -> 135.1.1.111  DNS 73 Standard query 0xc1da  A repo.hex.pm
  2 0.357233861  135.1.1.111 -> 10.0.2.15    DNS 140 Standard query response 0xc1da  CNAME dualstack.f2.shared.global.fastly.net A 151.101.58.2
  3 0.357931459    10.0.2.15 -> 151.101.58.2 TCP 76 37635 > 443 [SYN] Seq=0 Win=29200 Len=0 MSS=1460 SACK_PERM=1 TSval=66370864 TSecr=0 WS=64
  4 1.359419151    10.0.2.15 -> 151.101.58.2 TCP 76 [TCP Retransmission] 37635 > 443 [SYN] Seq=0 Win=29200 Len=0 MSS=1460 SACK_PERM=1 TSval=66371866 TSecr=0 WS=64
  5 3.365748390    10.0.2.15 -> 151.101.58.2 TCP 76 [TCP Retransmission] 37635 > 443 [SYN] Seq=0 Win=29200 Len=0 MSS=1460 SACK_PERM=1 TSval=66373872 TSecr=0 WS=64

but for curl:

42 52.895244026    10.0.2.15 -> 135.245.48.34 TCP 56 41846 > 8000 [ACK] Seq=523 Ack=23766 Win=65320 Len=0
 43 52.895622712 135.245.48.34 -> 10.0.2.15    TLSv1.2 1288 Application Data
 44 52.895640413    10.0.2.15 -> 135.245.48.34 TCP 56 41846 > 8000 [ACK] Seq=523 Ack=24998 Win=65320 Len=0
 45 53.094629558 135.245.48.34 -> 10.0.2.15    TLSv1.2 953 Application Data
 46 53.094668659    10.0.2.15 -> 135.245.48.34 TCP 56 41846 > 8000 [ACK] Seq=523 Ack=25895 Win=65320 Len=0
 47 53.095269185    10.0.2.15 -> 135.245.48.34 TLSv1.2 87 Encrypted Alert

So i can't figure out what's wrong. Thanks for your reply.

ericmj commented 5 years ago

This is a different error than what you showed first. mix local.hex installs hex and since you use mix hex.config without error it assumes you already have hex installed. Make sure you don't have multiple versions installed and somehow configure the wrong version.

mix local.hex does not use the configuration mix hex.config (since it is used for installing hex it cannot use configuration for hex). Try also setting export http_proxy=135.245.48.34:8000.

taijitao commented 5 years ago

Hi, Got it. [root@localhost vagrant]# mix local.hex ** (Mix) request timed out after 60000ms

Could not install Hex because Mix could not download metadata at https://repo.hex.pm/installs/hex-1.x.csv. [root@localhost vagrant]# curl https://repo.hex.pm/installs/hex-1.x.csv 0.14.0,b8a849be7e731f8d844229c029107e281364b55fe257d0f6d6ea9f7224d8c414d2ec2f0dee4bcdd9bc7672cab6c9d19e7e6bbb0539c740678fb6047821ce363d,1.0.0 so mix also doesn't work even there is the proxy shared with the curl. Let' back to the first error:

[root@localhost rabbitmq-auth-backend-oauth2]# mix hex.config
api_key: nil (default)
api_url: "https://hex.pm/api" (default)
diff_command: "git diff --no-index __PATH1__ __PATH2__" (default)
home: "/root/.hex" (default)
http_concurrency: 8 (default)
http_proxy: "135.245.48.34:8000" (using `http_proxy`)
http_timeout: nil (default)
https_proxy: "135.245.48.34:8000" (using `https_proxy`)
mirror_url: "http://hexpm.upyun.com" (using `/root/.hex/hex.config`)
no_verify_repo_origin: false (default)
offline: false (default)
repos_key: nil (default)
resolve_verbose: false (default)
unsafe_https: false (default)
unsafe_registry: false (default)
[root@localhost rabbitmq-auth-backend-oauth2]# cd deps/rabbitmq_cli/
[root@localhost rabbitmq_cli]# mix deps.get
Failed to check for new Hex version
Failed to fetch record for 'hexpm/amqp' from registry (using cache instead)
:timeout
:timeout

tshark output shown that hex didn't send package to proxy

77 334.354206177    10.0.2.15 -> 69.28.62.187 TCP 76 [TCP Retransmission] 42500 > 80 [SYN] Seq=0 Win=29200 Len=0 MSS=1460 SACK_PERM=1 TSval=170616784 TSecr=0 WS=64
 78 334.354306663    10.0.2.15 -> 69.28.62.187 TCP 76 [TCP Retransmission] 37289 > 80 [SYN] Seq=0 Win=29200 Len=0 MSS=1460 SACK_PERM=1 TSval=170616784 TSecr=0 WS=64
 79 334.354336978    10.0.2.15 -> 69.28.62.187 TCP 76 [TCP Retransmission] 40318 > 80 [SYN] Seq=0 Win=29200 Len=0 MSS=1460 SACK_PERM=1 TSval=170616784 TSecr=0 WS=64
 80 334.354362505    10.0.2.15 -> 69.28.62.187 TCP 76 [TCP Retransmission] 36112 > 80 [SYN] Seq=0 Win=29200 Len=0 MSS=1460 SACK_PERM=1 TSval=170616784 TSecr=0 WS=64
 81 334.354386560    10.0.2.15 -> 69.28.62.187 TCP 76 [TCP Retransmission] 42085 > 80 [SYN] Seq=0 Win=29200 Len=0 MSS=1460 SACK_PERM=1 TSval=170616784 TSecr=0 WS=64
 82 334.370666840    10.0.2.15 -> 69.28.62.187 TCP 76 [TCP Retransmission] 46249 > 80 [SYN] Seq=0 Win=29200 Len=0 MSS=1460 SACK_PERM=1 TSval=170616800 TSecr=0 WS=64
 83 334.370765347    10.0.2.15 -> 69.28.62.187 TCP 76 [TCP Retransmission] 42670 > 80 [SYN] Seq=0 Win=29200 Len=0 MSS=1460 SACK_PERM=1 TSval=170616800 TSecr=0 WS=64
 84 334.370798651    10.0.2.15 -> 69.28.62.187 TCP 76 [TCP Retransmission] 42161 > 80 [SYN] Seq=0 Win=29200 Len=0 MSS=1460 SACK_PERM=1 TSval=170616800 TSecr=0 WS=64
 85 334.882726128    10.0.2.15 -> 151.101.122.2 TCP 76 [TCP Retransmission] 43930 > 443 [SYN] Seq=0 Win=29200 Len=0 MSS=1460 SACK_PERM=1 TSval=170617312 TSecr=0 WS=64

Is it possbile mix/hex use the same library? any debug info or log?

B.R, Tao

ericmj commented 5 years ago

Is it possbile mix/hex use the same library?

They use the same underlying HTTP library but the configuration for proxies happen separately.

Does Hex not use any of http_proxy, https_proxy, nor mirror_url for you? If that's the case I think it's an issue with how you have installed Hex or maybe your PATHs. It's unlikely that you are hitting two separate bugs I cannot reproduce and we haven't had any other reported issues about.

josevalim commented 4 years ago

Closing this for now, please let us know if you have any updates, thanks!

lllnew commented 4 years ago

Hi, Got it. [root@localhost vagrant]# mix local.hex ** (Mix) request timed out after 60000ms

Could not install Hex because Mix could not download metadata at https://repo.hex.pm/installs/hex-1.x.csv. [root@localhost vagrant]# curl https://repo.hex.pm/installs/hex-1.x.csv 0.14.0,b8a849be7e731f8d844229c029107e281364b55fe257d0f6d6ea9f7224d8c414d2ec2f0dee4bcdd9bc7672cab6c9d19e7e6bbb0539c740678fb6047821ce363d,1.0.0 so mix also doesn't work even there is the proxy shared with the curl. Let' back to the first error:

[root@localhost rabbitmq-auth-backend-oauth2]# mix hex.config
api_key: nil (default)
api_url: "https://hex.pm/api" (default)
diff_command: "git diff --no-index __PATH1__ __PATH2__" (default)
home: "/root/.hex" (default)
http_concurrency: 8 (default)
http_proxy: "135.245.48.34:8000" (using `http_proxy`)
http_timeout: nil (default)
https_proxy: "135.245.48.34:8000" (using `https_proxy`)
mirror_url: "http://hexpm.upyun.com" (using `/root/.hex/hex.config`)
no_verify_repo_origin: false (default)
offline: false (default)
repos_key: nil (default)
resolve_verbose: false (default)
unsafe_https: false (default)
unsafe_registry: false (default)
[root@localhost rabbitmq-auth-backend-oauth2]# cd deps/rabbitmq_cli/
[root@localhost rabbitmq_cli]# mix deps.get
Failed to check for new Hex version
Failed to fetch record for 'hexpm/amqp' from registry (using cache instead)
:timeout
:timeout

tshark output shown that hex didn't send package to proxy

77 334.354206177    10.0.2.15 -> 69.28.62.187 TCP 76 [TCP Retransmission] 42500 > 80 [SYN] Seq=0 Win=29200 Len=0 MSS=1460 SACK_PERM=1 TSval=170616784 TSecr=0 WS=64
 78 334.354306663    10.0.2.15 -> 69.28.62.187 TCP 76 [TCP Retransmission] 37289 > 80 [SYN] Seq=0 Win=29200 Len=0 MSS=1460 SACK_PERM=1 TSval=170616784 TSecr=0 WS=64
 79 334.354336978    10.0.2.15 -> 69.28.62.187 TCP 76 [TCP Retransmission] 40318 > 80 [SYN] Seq=0 Win=29200 Len=0 MSS=1460 SACK_PERM=1 TSval=170616784 TSecr=0 WS=64
 80 334.354362505    10.0.2.15 -> 69.28.62.187 TCP 76 [TCP Retransmission] 36112 > 80 [SYN] Seq=0 Win=29200 Len=0 MSS=1460 SACK_PERM=1 TSval=170616784 TSecr=0 WS=64
 81 334.354386560    10.0.2.15 -> 69.28.62.187 TCP 76 [TCP Retransmission] 42085 > 80 [SYN] Seq=0 Win=29200 Len=0 MSS=1460 SACK_PERM=1 TSval=170616784 TSecr=0 WS=64
 82 334.370666840    10.0.2.15 -> 69.28.62.187 TCP 76 [TCP Retransmission] 46249 > 80 [SYN] Seq=0 Win=29200 Len=0 MSS=1460 SACK_PERM=1 TSval=170616800 TSecr=0 WS=64
 83 334.370765347    10.0.2.15 -> 69.28.62.187 TCP 76 [TCP Retransmission] 42670 > 80 [SYN] Seq=0 Win=29200 Len=0 MSS=1460 SACK_PERM=1 TSval=170616800 TSecr=0 WS=64
 84 334.370798651    10.0.2.15 -> 69.28.62.187 TCP 76 [TCP Retransmission] 42161 > 80 [SYN] Seq=0 Win=29200 Len=0 MSS=1460 SACK_PERM=1 TSval=170616800 TSecr=0 WS=64
 85 334.882726128    10.0.2.15 -> 151.101.122.2 TCP 76 [TCP Retransmission] 43930 > 443 [SYN] Seq=0 Win=29200 Len=0 MSS=1460 SACK_PERM=1 TSval=170617312 TSecr=0 WS=64

Is it possbile mix/hex use the same library? any debug info or log?

B.R, Tao

Hello, did you solve your problem, i encountered a similar problem

limeuser commented 2 years ago

i have same problem,obviously, proxy config does't work! image

ericmj commented 2 years ago

mix hex.config configures Hex, but mix local.hex installs Hex so the configuration cannot be used before it's installed.

mix local.hex is part of Mix (not Hex), to configure a proxy for it you can set the environment variable HTTPS_PROXY.

antheiz commented 1 year ago

mix hex.config configures Hex, but mix local.hex installs Hex so the configuration cannot be used before it's installed.

mix local.hex is part of Mix (not Hex), to configure a proxy for it you can set the environment variable HTTPS_PROXY.

Thank you sir, this work on my localhost!