gcloud command not found - while installing Google

2019-01-30 21:29发布

I am on a mac and am trying to install the Google Cloud SDK (including the gcloud command line utility) using this command in terminal

curl https://sdk.cloud.google.com | bash

as seen at https://cloud.google.com/sdk/

It got all the way to the end and finished but even after I restarted my shell, the gcloud command still says it's not found.

Why isn't this installation working?

20条回答
一纸荒年 Trace。
2楼-- · 2019-01-30 21:46

I know this question has been answered, but here are my two cent. After installing gcloud, you need to restart the shell before you able to gcloud command.

How you do this, mostly depends on the file you keep your shell configuration. Most files are .bashrc_profile, .bashrc, .zshrc.

You can now restart with

source ~/.bashrc_profile

You can replace the file to the file you have.

Or if you don't care the file you have, on Mac or linux you can restart the shell .

exec -l $SHELL

查看更多
等我变得足够好
3楼-- · 2019-01-30 21:47

This one worked for me:

source ~/.bash_profile
查看更多
手持菜刀,她持情操
4楼-- · 2019-01-30 21:48

If running

source ~/.bashrc

results in "No such file or directory"

On windows:

  1. Go to c/Users/
  2. While holding shift, right-click .bashrc file and select "Copy as path"
  3. In bash: source <pasteCopiedPathHere> -> for example: source "C:\Users\John\.bashhrc"
查看更多
干净又极端
5楼-- · 2019-01-30 21:50

So below is my previous fix for this problem, but it turns out it isn't permanent. It works but every time you restart Terminal, you'd have to do the same thing which isn't practical.

So that is why I suggest you delete the current google-cloud-sdk directory, and just redo the installation. Be sure (as Zachary has mentioned) to answer yes (Y) to the prompt Modify profile to update your $PATH and enable bash completion? (Y/n).

Here is my old answer, but just redo the installation:

I had the same problem, `gcloud` wasn't working for me.
But then, in the same directory as my `google-cloud-sdk` folder which I had just installed (my `home` directory), I found this file called `test`.
Inside this `test` file I found two commands:


    # The next line updates PATH for the Google Cloud SDK.
    source '[path-to-my-home]/google-cloud-sdk/path.bash.inc'
    # The next line enables bash completion for gcloud.
    source '[path-to-my-home]/google-cloud-sdk/completion.bash.inc'

After I ran these two `source` commands in terminal, `gcloud` worked!
查看更多
迷人小祖宗
6楼-- · 2019-01-30 21:50
$ sudo su
$ /opt/google-appengine-sdk/bin/gcloud components update
$ su <yourusername>
查看更多
霸刀☆藐视天下
7楼-- · 2019-01-30 21:51

I had this issue today, and adding sudo to the install command fixed my issue on maxOS Sierra!

sudo ./google-cloud-sdk/install.sh
查看更多
登录 后发表回答