Can I use gcloud in Git Bash on Windows?

泄露秘密 提交于 2019-12-04 17:09:48

问题


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).

echo $PATH in Git Bash does include the path to the Google SDK (highlighted 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.


回答1:


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




回答2:


Create ~/.bashrc with one and only line:

alias gcloud="gcloud.cmd"

and restart you shell session. That's it.




回答3:


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.



来源:https://stackoverflow.com/questions/36843983/can-i-use-gcloud-in-git-bash-on-windows

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!