XcodesOrg / xcodes

The best command-line tool to install and switch between multiple versions of Xcode.
MIT License
3.74k stars 130 forks source link

Support Proxies via environment variables #255

Open iliuta opened 1 year ago

iliuta commented 1 year ago

Hi,

I have just a question for you. Are "standard" environment variables for proxy settings (HTTP_PROXY, HTTPS_PROXY or http_proxy and https_proxy) honoured while installing xcode?

I ask this because I have an installation failing with timeout: $ xcodes install 14.1 The request timed out.

This is done on a remote AWS mac machine which needs proxy for outgoing http(s) connections. All mentioned proxy variables are set.

If proxy is not the cause, have you already met this error before? What could be the cause?

Many thanks for your answers.

MattKiazyk commented 1 year ago

Hi @iliuta

I don't have too much experience with that but from my brief investigations, it looks like Xcodes doesn't support it.

For aria2: http://aria2.github.io/manual/en/html/aria2c.html#http-ftp-sftp-options xcodes would have to pass up the --all-proxy option which we currently don't.

For URLSession it looks like we would need to configure that as well to look at the environment variables. A good example would be https://github.com/Carthage/Carthage/pull/2371/files#diff-1729db5850075c9e9d77248d6818720cf6f4a4b1d7792f59cd1a4920f5cd09e2

Sorry Xcodes isn't working for you. This definitely could be added!

iliuta commented 1 year ago

Thank you @MattKiazyk FYI, I've just found 2 things:

  1. yes, proxy was the issue
  2. it looks like the system proxy (the one in Network Preferences on the Mac) is taken into account and not the env variables in the terminal

How to setup the system proxy? By using networksetup command. First list all network interfaces:

networksetup -listallnetworkservices An asterisk (*) denotes that a network service is disabled. Wi-Fi Thunderbolt Bridge Then set proxy for each interface, for instance: networksetup -setsecurewebproxy "Thunderbolt Bridge" my.proxy.host.com 3128

xcodes seems to work fine after that.

MattKiazyk commented 1 year ago

@iliuta thanks for the response. Glad you got it working. Is that setup working with aria2 as well?

I've updated the title to indicate we should add support for one-off proxy connections.

iliuta commented 1 year ago

@MattKiazyk I honestly don't know (yet) what aria2 is. I'm just trying to help a developer who needs to automate flutter builds on a CI pipeline on a Mac instance on cloud (AWS). He tells me he doesn't need it for the moment. I'll tell you if I get into trouble with that.

But anyway, for the proxy issue, maybe it would be useful to document this somewhere.

legege commented 1 year ago

In my environment with proxy variables set, when trying to install, I get this strange error:

$ xcodes install --latest --experimental-unxip
Updating...
Latest release version available is 14.3

Downloading with aria2 (/opt/homebrew/bin/aria2c)

XcodesKit/Environment.swift:80: Precondition failed: Aria must be called on the main queue
[1]    39491 trace trap  sudo xcodes install --latest --experimental-unxip