×


Google Cloud SDK error "Unzip Failed: Error opening zip file" - Fix it Now ?

While trying to install the Google Cloud SDK command-line interface using Windows Installer, users often receive the error "Unzip failed: Error opening ZIP file".

Here at Ibmi Media, as part of our Server Management Services, we regularly help our Customers to perform  Google cloud queries.


What causes Google Cloud SDK "Unzip Failed: Error opening zip file" error ?

This generally happens due to the firewall blocking some URLs that the installer tries to access. Before proceeding to the solution for this error, let us discuss the steps involved in installing Google Cloud SDK in Windows.

 

How to install Google Cloud SDK in Windows ?

To Install of Google Cloud SDK in Windows involves the steps below:

  • Download the Cloud SDK installer
  • Launch the installer
  • Install dependencies
  • Run the installer
  • Install Extensions


Now, Let's discuss each of these steps:


1. Download the Cloud SDK installer

The Cloud SDK installer can be downloaded from the URL:

https://dl.google.com/dl/cloudsdk/channels/rapid/GoogleCloudSDKInstaller.exe

Alternatively, open a PowerShell terminal and run the following PowerShell commands:

(New-Object Net.WebClient).DownloadFile("https://dl.google.com/dl/cloudsdk/channels/rapid/GoogleCloudSDKInstaller.exe", "$env:Temp\GoogleCloudSDKInstaller.exe")
& $env:Temp\GoogleCloudSDKInstaller.exe


2. Launch installer

Now, launch the installer and follow the prompts.  If we want to enable screen reader mode, select the Turn on screen reader mode option for a more streamlined screen reader experience.


3. Install dependencies

Cloud SDK requires Python. The supported versions are Python 3 (preferred, 3.5 to 3.8) and Python 2 (2.7.9 or higher).

The installer will install all necessary dependencies, including the needed Python version. While Cloud SDK currently uses Python 3 by default, we can use an existing Python installation if necessary by unchecking the option to Install Bundled Python.


4. Run the installer

After installation is completed, the installer presents several options.

Make sure that the following are selected:

  • Start Google Cloud SDK Shell
  • Run gcloud init


The installer starts a terminal window and runs the gcloud init command.


5. Install Extensions

The default installation does not include the App Engine extensions required to deploy an application using gcloud commands. These components can be installed using the Cloud SDK component manager.

At times, when it cannot recognize the find command, the installation becomes unsuccessful. Here, we need to ensure that the PATH environment variable includes the folder containing find. Usually, this is C:\WINDOWS\system32.

Further, if we have just uninstalled Cloud SDK, we will need to reboot the system before installing Cloud SDK again.


How to resolve Google Cloud SDK "Unzip Failed: Error opening zip file" error ?

As this error happens mainly due to firewall blocks, we can try from a different network to find if it fixes the issue. Also, check the firewall for any blocks.

Another solution is to close the proxy and add a new env:

CLOUDSDK_PYTHON=\your Python27 path\python.exe

Alternatively, we could run the installer as administrator.

If we are behind a corporate proxy or firewall, the gcloud command-line tool may not be able to access the internet with its default settings.

The interactive Cloud SDK installers download components from the internet as part of the installation process, which may not work correctly if we are behind a proxy or firewall.


Proxy configuration to fix Google Cloud SDK "Unzip Failed: Error opening zip file" error

The gcloud command-line tool respects the http_proxy, https_proxy, and no_proxy variables set in the proxy configuration. Configure gcloud proxy settings only if we would like to use a different proxy. If gcloud proxy settings are set, they override the existing proxy configuration; this includes ignoring no_proxy.

Once we have the SDK installed, we can configure the proxy settings via Cloud SDK properties by using the typical gcloud config mechanism.

To start, set the type of proxy we use, the address and port on which to reach it:

gcloud config set proxy/type [PROXY_TYPE]
gcloud config set proxy/address [PROXY_IP_ADDRESS]
gcloud config set proxy/port [PROXY_PORT]

Cloud SDK supports the following values for PROXY_TYPE:

http, http_no_tunnel, socks4, socks5

Here, PROXY_IP_ADDRESS is the hostname or IP address of where the proxy can be reached. Further, PROXY_PORT is the port the proxy is running on (e.g. 8080).

For an authenticated proxy, we will need to set proxy username and password using properties, like so:

gcloud config set proxy/username [USERNAME]
gcloud config set proxy/password [PASSWORD]


Alternatively, to close your proxy:

add a new env: CLOUDSDK_PYTHON=\your Python27 path\python.exe

Avoid recording the proxy credentials in any logs (such as shell history or gcloud logs) or in the gcloud CLI configuration file, we can set the properties using 

environment variables, like so:

export CLOUDSDK_PROXY_USERNAME [USERNAME]
export CLOUDSDK_PROXY_PASSWORD [PASSWORD]

The gcloud CLI will not store these values anywhere. This way, we can store the credentials in an encrypted file locally or we can store them in a secure network location and retrieve them when necessary.

If we are behind a proxy and we receive SSL handshake errors, it is likely that proxy is a man-in-the-middle proxy that uses a custom CA. We need to set the following property to point to custom CA file:

gcloud config set core/custom_ca_certs_file [PATH_TO_CUSTOM_CA]


[Need urgent assistance in fixing Linux errors? We can help you. ]


Conclusion

This article covers how to fix Google Cloud error, "Unzip Failed: Error opening zip file". Basically, the Google Cloud SDK setup wizard triggers the "Unzip Failed: Error opening zip file" error mainly due to firewall restrictions.

To fix this error, do the following:

  • close your proxy.
  • add a new env: CLOUDSDK_PYTHON=\your Python27 path\python.exe