I have a problem with the bower list command, which was caused by the fact that bower uses git with git:// URLs to get a list of remote GitHub repositories, but the git:// protocol is blocked by our corporate firewall. To solve this problem in addition to setting environment variables, I have to add additional configurations to git too. Here is the complete list of commands that I must execute (do not forget to replace the proxy host and port with yours):
# set proxy for command line tools export HTTP_PROXY=http://localhost:3128 export HTTPS_PROXY=http://localhost:3128 export http_proxy=http://localhost:3128 export https_proxy=http://localhost:3128
The standard environment variables in Bash are uppercase; for proxies, the HTTPS_PROXY and HTTPS_PROXY , but some tools expect them to be lowercase, one of these tools is the gazebo. That is why I prefer to have a proxy server in two cases: lower and upper.
Bower uses git to get packages from GitHub, so configuration keys need to be added to git as well. http.proxy and https.proxy are proxy server settings and should point to your proxy server. Last but not least, telling git not to use the git:// protocol, since it can be blocked by a firewall. You need to replace it with the standard http:// protocol. Someone suggests using https:// instead of git:// as follows: git config --global url."https://".insteadOf git:// but I got a Connection reset by peer error, so I use http:// , which works great for me.
At home, I do not use a proxy server and I do not have a corporate firewall, so I prefer to switch to the "normal" settings without a proxy server. Here is how I do it:
# remove proxy environment variables unset HTTP_PROXY unset HTTPS_PROXY unset http_proxy unset https_proxy
I donβt remember things very well, so I will never remember all these commands. On top of that, I'm lazy and don't want to type these long commands manually. This is why I created functions for setting and canceling proxy server settings. Here are 2 functions that I added to my .bashrc after some alias definitions:
set_proxy() { export HTTP_PROXY=http://localhost:3128 export HTTPS_PROXY=http://localhost:3128 # some tools uses lowercase env variables export http_proxy=http://localhost:3128 export https_proxy=http://localhost:3128 # config git git config --global http.proxy http://localhost:3128 git config --global https.proxy http://localhost:3128 git config --global url."http://".insteadOf git:// } unset_proxy() { unset HTTP_PROXY unset HTTPS_PROXY unset http_proxy unset https_proxy git config --global --unset http.proxy git config --global --unset https.proxy git config --global --unset url."http://".insteadOf }
Now that I need to install the proxy, I just run the set_proxy command and the unset unset_proxy command. With Bash autocomplete, I donβt even need to enter these commands, but let the tab complete them for me.