gcloud stop working - "was unexpected at this time."
Asked Answered
G

5

11

I just update my google cloud SDK on windows 10 (gcloud components update). After the update the gcloud command stop working. All I get is (for example : gcloud -h): PATH\lib\gcloud.py" -h" was unexpected at this time.

I try to re-install but it didn't help:(

enter image description here

Gammadion answered 19/12, 2019 at 23:44 Comment(5)
I seem to be having a similar issue except I appear to be getting a message of \Google\Cloud was unexpected at this time. for every command. Unfortunately, this also means I cannot revert to a previous versionOdawa
Seems like this a bug in latest edition, since it just was reported and at least us experienced thisJobie
I was having the same issue today because I just recently updated as well, I'm using the Git bash terminal (mingw-w64.org/doku.php/download) for now, it works.Buitenzorg
The script C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\bin\gcloud.cmd if broken. The problem is at the very bottom of the file in the last ELSE block. The script is also breaking the PATH environment variable on Windows. Download a version 2.73 storage.cloud.google.com/cloud-sdk-releasePettaway
was having same issue (\Google\Cloud was unexpected at this time) - version 2.73 worked for meCrapshooter
G
2

This is a known issue that is being tracked here

After hours of trying to fix it! I found how :)

  1. uninstall google SDK
  2. https://dl.google.com/dl/cloudsdk/channels/rapid/google-cloud-sdk.zip
  3. https://cloud.google.com/sdk/docs/downloads-interactive#interactive_installation

This fix the bug.

After that I had new bug in pyCharm GAE:

ImportError: No module named _subprocess

I fix this with the solution here: Error importing built-in module "_subprocess" using Google Cloud Platform's Local Development Server

Hope this helps and saves a lot of trouble for you guys :)

Gammadion answered 20/12, 2019 at 8:41 Comment(0)
D
4

As noted in the other answers, this is a bug with the 274.0.0 version of gcloud. Another report of this issue actually identifies where the bug is and offers this fix:

If you are stuck and need an immediate solution, here's a workaround that will move you forward, but you should reinstall the Cloud SDK from scratch when a fix is ready.

  1. Open C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk-bin\gcloud.cmd in your editor
  2. Near line 170, change ) ELSE ( to be just )
  3. Remove the ) on the last line in the file.

That should get you working in the short term (albeit with an extraneous error message every time you run a command). After getting it working you can revert to version 273.0.0 (so that you stop getting the error message and aren't using a modified version) using:

gcloud components update --version=273.0.0
Distaff answered 22/12, 2019 at 21:35 Comment(1)
where gcloud is useful to do if that's not the precise directory of gcloud.cmdAmateur
E
4

This is being tracked in the public bug https://issuetracker.google.com/issues/146458519

We have a patch for two files that are causing these problems. These apply in two cases (both on Windows): 1. A new install fails, or 2. You are unable to run gcloud after performing a components update.

For case # 1, please download the attached file install.bat, and copy it to the location where you have attempted to install gcloud, e.g. C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk. Then run it, e.g.

cd C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk .\install.bat

For both cases #1 and #2, download the attached file gcloud.cmd, and copy it to the bin directory under your gcloud installation, e.g. C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\bin. When prompted to replace the previous copy, type Yes. This should allow you to run gcloud without being prompted to set CLOUDSDK_PYTHON.

The files are attached in the public bug tracker.

Exploitation answered 23/12, 2019 at 22:14 Comment(0)
G
2

This is a known issue that is being tracked here

After hours of trying to fix it! I found how :)

  1. uninstall google SDK
  2. https://dl.google.com/dl/cloudsdk/channels/rapid/google-cloud-sdk.zip
  3. https://cloud.google.com/sdk/docs/downloads-interactive#interactive_installation

This fix the bug.

After that I had new bug in pyCharm GAE:

ImportError: No module named _subprocess

I fix this with the solution here: Error importing built-in module "_subprocess" using Google Cloud Platform's Local Development Server

Hope this helps and saves a lot of trouble for you guys :)

Gammadion answered 20/12, 2019 at 8:41 Comment(0)
P
2

I solved this problem. I got the same error message.

My Env: gcloud v274.0.0, Windows 7

Env

First, I re-installed Google SDK, and changed my path to \Google\CloudSDK\.

Second, I got this message

"\Google\CloudSDK\google-cloud-sdk\bin..\lib\gcloud.py" init" was unexpected at this time."

So I tried to use cd command to specific directory where gcloud.py is exist.

Finally, I found the path: \Google\CloudSDK\google-cloud-sdk\lib, and it works.

Hope it can help you, too.

Paletot answered 23/12, 2019 at 3:8 Comment(0)
U
1

The problem, or rather bug within the installer, is that you are using a directory that contains spaces within it. At some point of the script the space causes the command to be split up incorrectly, causing the error.

I had the same message and fixed it by re-installing the Google Cloud SDK in a directory without spaces (c:\Google\CloudSDK)

Unmoral answered 20/12, 2019 at 14:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.