gcloud in WSL

11,568 views
Skip to first unread message

Derrick Gunter

unread,
Mar 11, 2022, 1:30:19 PM3/11/22
to Google Cloud Developers
Anyone using the gcloud cli from Windows Subsystem for Linux (WSL 2)? I am having problems getting it to work consistently. Sometimes the gcloud command just sits there stuck. Most times it works fine. 

Easily reproducible with a simple command like "gcloud compute instances list". Looks like it always hangs just before an https connection:

root@DESKTOP-H8CB6JO:/mnt/c/Users/ddgun# gcloud compute instances --verbosity=debug list
DEBUG: Running [gcloud.compute.instances.list] with arguments: [--verbosity: "debug"]
INFO: Display format: "    table(
      name,
      zone.basename(),
      machineType.machine_type().basename(),
      scheduling.preemptible.yesno(yes=true, no=''),
      networkInterfaces[].networkIP.notnull().list():label=INTERNAL_IP,
      networkInterfaces[].accessConfigs[0].natIP.notnull().list()      :label=EXTERNAL_IP,
      status
    )"
DEBUG: Starting new HTTPS connection (1): compute.googleapis.com:443

Any ideas?

Thanks,
Derrick

Bruno (Cloud Platform Support)

unread,
Mar 11, 2022, 5:40:02 PM3/11/22
to Google Cloud Developers
Hi, 

I suggest verifying that you are using gcloud cli's latest version (gcloud version). If it isn't the latest, please update it. You may also try uninstalling gcloud and installing it. 

If the steps above do not mitigate the issue, then perhaps the workarounds mentioned in this Stackoverflow answer as well as this thread may prove useful.

Hopefully the steps above help in resolving this gcloud's inconsistency. If not, my recommendation would be to cross-post your question to Stackoverflow for comprehensive and more technically detailed answers tailored to your use case. 

Chris Gerber

unread,
Mar 14, 2022, 9:28:54 AM3/14/22
to Bruno (Cloud Platform Support), Google Cloud Developers
You may be able to get additional debugging information by adding `--log-http` to your command. Additionally, running `gcloud config set core/console_log_format detailed` will add timestamps to the logging messages to help determine how much of a pause is occurring between each event. These timestamps can be turned back off later with `gcloud config set core/console_log_format standard`.

--
You received this message because you are subscribed to the Google Groups "Google Cloud Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-cloud-d...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-cloud-dev/da830ab7-d206-4daa-aa5c-bb6040d2d164n%40googlegroups.com.

Derrick Gunter

unread,
Mar 14, 2022, 1:21:27 PM3/14/22
to Google Cloud Developers
Thanks Chris. The --log-http shows it stopping at exactly same spot as with just --verbosity=debug:
 
ddg@DESKTOP-H8CB6JO:~$ gcloud compute instances list --verbosity=debug --log-http
DEBUG: Running [gcloud.compute.instances.list] with arguments: [--log-http: "true", --verbosity: "debug"]

INFO: Display format: "    table(
      name,
      zone.basename(),
      machineType.machine_type().basename(),
      scheduling.preemptible.yesno(yes=true, no=''),
      networkInterfaces[].networkIP.notnull().list():label=INTERNAL_IP,
      networkInterfaces[].accessConfigs[0].natIP.notnull().list()      :label=EXTERNAL_IP,
      status
    )"
=======================
==== request start ====
uri: https://compute.googleapis.com/batch/compute/v1
method: POST
== headers start ==
b'authorization': --- Token Redacted ---
b'content-length': b'542'
b'content-type': b'multipart/mixed; boundary="===============6313490827299795107=="'
b'user-agent': b'google-cloud-sdk gcloud/376.0.0 command/gcloud.compute.instances.list invocation-id/560138ecfb164543b3eeff3a8d54e178 environment/None environment-version/None interactive/True from-script/False python/3.9.2 term/xterm-256color (Linux 5.10.60.1-microsoft-standard-WSL2)'
== headers end ==
== body start ==
--===============6313490827299795107==
Content-Type: application/http
MIME-Version: 1.0
Content-Transfer-Encoding: binary
Content-ID: <9a5f1833-df46-458a-8e67-bbfd5ea01a4a+0>

GET /compute/v1/projects/my-test-337915/aggregated/instances?alt=json&includeAllScopes=True&maxResults=500&returnPartialSuccess=True HTTP/1.1
Content-Type: application/json
MIME-Version: 1.0
content-length: 0
user-agent: google-cloud-sdk
accept: application/json
accept-encoding: gzip, deflate
Host: compute.googleapis.com


--===============6313490827299795107==--

== body end ==
==== request end ====

DEBUG: Starting new HTTPS connection (1): compute.googleapis.com:443
^C

Command killed by keyboard interrupt


ddg@DESKTOP-H8CB6JO:~$

David Charles Martinez

unread,
Mar 14, 2022, 4:47:07 PM3/14/22
to Google Cloud Developers

Hello,

It seems that this is an issue directly related to WSL. I can see that you took the steps to report this in the Issue Tracker. Please, continue to wait for a response through this channel.
Reply all
Reply to author
Forward
0 new messages