23

So, I've installed Git, Git Bash, Python2.7, and I've just installed the Google Cloud SDK per the official guide. Using Windows 10.

In cmd.exe, or the "Google Cloud SDK Shell", gcloud works fine.

Within Git Bash, however (the terminal that I prefer to use), gcloud returns the following output (screenshot).

enter image description here

echo $PATH in Git Bash does include the path to the Google SDK (highlighted here).

enter image description here

Am I missing something? Is there anything in $PATH that is possibly conflicting with gcloud, or did I misconfigure the path somehow?

I appreciate any insight.


UPDATE. Here is the output of env|grep PATH. I'm not sure what it tells me. Any other executable in the PATH is working (vagrant, conda, python, etc), but gcloud is not.

enter image description here

ensminger
  • 671
  • 3
  • 6
  • 14
  • 2
    Possible duplicate of [Git Bash doesn't see my PATH](http://stackoverflow.com/questions/10681101/git-bash-doesnt-see-my-path) – Vilas Apr 25 '16 at 17:27

4 Answers4

32

Create ~/.bashrc with one and only line:

alias gcloud="gcloud.cmd"

and restart you shell session. That's it.

d.ansimov
  • 2,131
  • 2
  • 31
  • 54
25

You need to use the full file name i.e. gcloud.sh or gcloud.cmd. See the following question for more details:

Git Bash doesn't see my PATH

Community
  • 1
  • 1
Vilas
  • 1,405
  • 12
  • 15
  • This works! `gcloud.cmd` works for me. Is there any way to account for this? – ensminger Apr 26 '16 at 14:15
  • 1
    Thanks for confirming it works. Can you clarify what you mean by 'account for this'? – Vilas Apr 26 '16 at 20:38
  • Sorry. Is there any way to 'correct' this, so that I do not have to append the file extension, and can use the command normally? – ensminger Apr 27 '16 at 00:44
  • 3
    Git Bash is working as it should since bash does not let you omit file extensions. You could create an executable shortcut called gcloud to gcloud.cmd in the same bin directory. – Vilas Apr 27 '16 at 15:01
15

Put the following in a .bashrc file which should be located in C:\Users\YourWindowsAccount:

gcloud() {
    "gcloud.cmd" "$@"
}
export -f gcloud

Adapted from: https://askubuntu.com/a/98791

Restart Git Bash thereafter.

This solution is better than using aliases because it allows you to call gcloud from a shell script also.

Kevin Lee
  • 2,307
  • 26
  • 31
0

Another option - copying the gsutil and bq files from Linux version to /google-cloud-sdk/bin on Windows.

Lei Feng
  • 11
  • 2