Ubuntu: add-apt-repository uses proxy

In order to have console applications use a proxy, the easiest way is to set the proxy in system environment, this can either be done by using command line:

Or simply to set it by setting “Network Proxy” in system settings (Can be found in network panel in Ubuntu 18.04, which may also work on other Linux distributions, but the export command always work.)

After above setting, the system setting will work for many software including wget, etc. however, certain software will be stubborn enough to connect to the Internet directly without the proxy, such as apt-get and apt-apt-repository, apt-get can set its own proxy by configuring

Just as my previous post mentioned.

There is one way to solve the problem:

In addition to configuring proxies, tell sudo to preserve the environment with the -E option:

Notice: -E can be replaced with: -E, --preserve-env 

HERE, you will be able to find further instruction: