gCloud SDK failed to install in macOS behind corpo

2019-09-04 20:26发布

I am trying to install gcloud SDK while using a coporate network which works behind a proxy (and a VPN sometimes). I get proxy settings automatically using a pac.fcgi file (Automatic Proxy Configuration).

Now when I try to run ./install.sh in the terminal, I am constantly getting the following error

➜  google-cloud-sdk ./install.sh
Welcome to the Google Cloud SDK!

To help improve the quality of this product, we collect anonymized usage data
and anonymized stacktraces when crashes are encountered; additional information
is available at <https://cloud.google.com/sdk/usage-statistics>. You may choose
to opt out of this collection now (by choosing 'N' at the below prompt), or at
any time in the future by running the following command:

    gcloud config set disable_usage_reporting true

Do you want to help improve the Google Cloud SDK (Y/n)?  

ERROR: (gcloud.components.list) Failed to fetch component listing from server. Check your network settings and try again.

I found this SO question which was having the same issue, but their problem was related to ipv6. I already have ipv6 disabled (I can't even enable it) and I am using ethernet to connect to the network. Thus the answer is not useful to me.

I searched for proxy related info about installation and found this page. It asks for using a non-interactive installer instead and using gcloud command to set the proxy after installation. My problem is that I can't even install gcloud. I have tried with both interactive and non-interactive installers.

Any way I can install gcloud while being behind a corporate proxy.

PS: I am on macOS High Sierra and using zsh shell (already tried bash), in case it matters.

1条回答
Lonely孤独者°
2楼-- · 2019-09-04 21:11

So, the problem was I was unable to set proxy before installation of gcloud. The installation of gcloud basically set the CLI in the path and installs some required components (core, bq, gsutil etc).

So what I did is I added the following lines in my .zshrc

source <PATH to gcloud sdk>/google-cloud-sdk/path.zsh.inc
source <PATH to gcloud sdk>/google-cloud-sdk/completion.zsh.inc

or if you're using bash, add these lines in your .bashrc or .bash_profile

source <PATH to gcloud sdk>/google-cloud-sdk/path.bash.inc
source <PATH to gcloud sdk>/google-cloud-sdk/completion.bash.inc

After that I restarted the terminal (or just run source ~/.zshrc or source ~/.bashrc or source ~/.bash_profile on terminal)

Now I was able to use gcloud commands. I ran gcloud init, set the proxy and then installed the required components using the following command -

gcloud components install core bq gsutil

And I installed gcloud without using the install.sh script.

PS: Run scutil --proxy to know the proxy settings set in your system.

查看更多
登录 后发表回答