1

I've installed Cloud SDK on my windows 10 machine and I'm able to run commands like "gcloud", "gsutil" and "bq" on my command prompt. However, when I run "gsutil" or "bq" on Bash, this is the error I'm getting.

$ bq

bash: bq: command not found

Then I added this location to PATH C:\Users\User\AppData\Local\Google\Cloud SDK\google-cloud-sdk\bin, and afterwards I seem to be able to call gsutil and bq using gsutil.cmd and bq.cmd. But of course, I'd prefer calling bq / gsutil directly.

Has anyone has this problem before? Thank you!

johnconnor92
  • 199
  • 1
  • 13

2 Answers2

2

I found one possible solution!

  1. In Bash, go to the root bash folder by typing cd
  2. Type touch .bashrc
  3. write alias bq="bq.cmd" or alias gsutil="gsutil.cmd" or both
  4. Press Esc and type :qa and Enter to save and exit

This tells Bash to remember bq as invoking bq.cmd, hence now I can invoke bq anywhere -- as far as I know.

If anyone has a better suggestion, please let me know! Thank you!

johnconnor92
  • 199
  • 1
  • 13
0

In the bash session itself, check what echo $PATH returns. It should inherit the path that was defined on Windows.

So open a new CMD session, and:

  • make sure the %PATH% does include C:\Users\User\AppData\Local\Google\Cloud SDK\google-cloud-sdk\bin,
  • then call C:\path\to\Git\bin\bash.exe to open a bash session

bq should work in such a shell session.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Hi VonC, yes %PATH% does include the path you specified, and yes I am able to perform your second step. But shouln't Bash be able to launch bq / gsutil from any folder I open Bash in? – johnconnor92 Feb 05 '20 at 06:57
  • @johnconnor92 not if the Cloud SDK path is declared in the PATH from User variables instead of the system environment variables (https://stackoverflow.com/a/16305526/6309). A contextual menu in an explorer might open a session with only the system variables. Or at least try and reboot first, to see if the issue persists. – VonC Feb 05 '20 at 06:59