-bash:gcloud:在Mac上找不到命令

Sha*_*ain 16 bash gcloud google-cloud-sdk

我正在关注Mac OS XQuickstart以安装云SDK.完全按照步骤,

1)python -V返回"Python 2.7.10"

2)./install.sh在google-cloud-sdk中使用64位版本的SDK 下载并解压缩...

Welcome to the Google Cloud SDK!

To help improve the quality of this product, we collect anonymized usage data
and anonymized stacktraces when crashes are encountered; additional information
is available at <https://cloud.google.com/sdk/usage-statistics>. You may choose
to opt out of this collection now (by choosing 'N' at the below prompt), or at
any time in the future by running the following command:

    gcloud config set disable_usage_reporting true

Do you want to help improve the Google Cloud SDK (Y/n)?  Y


Your current Cloud SDK version is: 170.0.1
The latest available version is: 170.0.1

???????????????????????????????????????????????????????????????????????????????????????????????????????????????
?                                                  Components                                                 ?
???????????????????????????????????????????????????????????????????????????????????????????????????????????????
?     Status    ?                         Name                         ?            ID            ?    Size   ?
???????????????????????????????????????????????????????????????????????????????????????????????????????????????
? Not Installed ? App Engine Go Extensions                             ? app-engine-go            ?  97.7 MiB ?
? Not Installed ? Cloud Bigtable Command Line Tool                     ? cbt                      ?   4.0 MiB ?
? Not Installed ? Cloud Bigtable Emulator                              ? bigtable                 ?   3.5 MiB ?
? Not Installed ? Cloud Datalab Command Line Tool                      ? datalab                  ?   < 1 MiB ?
? Not Installed ? Cloud Datastore Emulator                             ? cloud-datastore-emulator ?  15.4 MiB ?
? Not Installed ? Cloud Datastore Emulator (Legacy)                    ? gcd-emulator             ?  38.1 MiB ?
? Not Installed ? Cloud Pub/Sub Emulator                               ? pubsub-emulator          ?  33.2 MiB ?
? Not Installed ? Emulator Reverse Proxy                               ? emulator-reverse-proxy   ?  14.5 MiB ?
? Not Installed ? Google Container Local Builder                       ? container-builder-local  ?   3.7 MiB ?
? Not Installed ? Google Container Registry's Docker credential helper ? docker-credential-gcr    ?   2.2 MiB ?
? Not Installed ? gcloud Alpha Commands                                ? alpha                    ?   < 1 MiB ?
? Not Installed ? gcloud Beta Commands                                 ? beta                     ?   < 1 MiB ?
? Not Installed ? gcloud app Java Extensions                           ? app-engine-java          ? 128.1 MiB ?
? Not Installed ? gcloud app PHP Extensions (Mac OS X)                 ? app-engine-php-darwin    ?  21.9 MiB ?
? Not Installed ? gcloud app Python Extensions                         ? app-engine-python        ?   6.5 MiB ?
? Not Installed ? kubectl                                              ? kubectl                  ?  15.9 MiB ?
? Installed     ? BigQuery Command Line Tool                           ? bq                       ?   < 1 MiB ?
? Installed     ? Cloud SDK Core Libraries                             ? core                     ?   6.7 MiB ?
? Installed     ? Cloud Storage Command Line Tool                      ? gsutil                   ?   3.0 MiB ?
???????????????????????????????????????????????????????????????????????????????????????????????????????????????
To install or remove components at your current SDK version [170.0.1], run:
  $ gcloud components install COMPONENT_ID
  $ gcloud components remove COMPONENT_ID

To update your SDK installation to the latest version [170.0.1], run:
  $ gcloud components update

==> Source [/Users/shaneoseasnain/Desktop/google-cloud-sdk/completion.bash.inc] in your profile to enable shell command completion for gcloud.
==> Source [/Users/shaneoseasnain/Desktop/google-cloud-sdk/path.bash.inc] in your profile to add the Google Cloud SDK command line tools to your $PATH.

For more information on how to get started, please visit:
  https://cloud.google.com/sdk/docs/quickstarts
Run Code Online (Sandbox Code Playgroud)

3)我重新启动了终端并gcloud init从google-cloud-sdk内部运行.这返回" command not found." 如果我运行ls,我会看到以下目录结构:

LICENSE               completion.zsh.inc      path.fish.inc
README                deb                     path.zsh.inc
RELEASE_NOTES         install.bat             platform
VERSION               install.sh              properties
bin                   lib                     rpm
completion.bash.inc   path.bash.inc
Run Code Online (Sandbox Code Playgroud)

4)我也试过在gcloud init里面跑bin,但得到同样的问题,command not found.

我可以从安装指南中看到的唯一其他建议是"在bash shell中启用命令完成,和/或启用使用情况报告".我不知道如何做到这一点,但命令完成和报告似乎不应该与此问题相关.有很多关于command not found它的文章,但它们与其他问题有关,例如,gcloud在一段时间后停止工作或者在旧版本中出现问题.有没有人提示如何让云sdk工作?

谢谢

Liw*_*eiZ 64

我遇到过同样的问题.一个懒惰和快速的解决方法是运行:

brew cask install google-cloud-sdk

通过谷歌搜索找到.

  • 没有为我修好 (7认同)
  • 在“brew install”之后,我在这里找到了“gcloud”:“/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/bin” (3认同)

Abh*_*oda 14

对于 MAC 操作系统 - 使用 Homebrew

brew install --cask google-cloud-sdk
Run Code Online (Sandbox Code Playgroud)

然后使用

 source "$(brew --prefix)/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/path.zsh.inc"
 source "$(brew --prefix)/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/completion.zsh.inc"
Run Code Online (Sandbox Code Playgroud)


Zac*_*man 8

gcloud可执行生活google-cloud-sdk/bin-to执行gcloud.你需要:

  1. 将此目录添加到$ PATH.特别是,将行添加source /Users/shaneoseasnain/Desktop/google-cloud-sdk/path.bash.inc.bash_profile文件中(有关此文件执行操作以及如何选择文件的更多详细信息)将起到作用.
  2. gcloud运行时指定可执行文件的完整路径.在你的情况下,这是/Users/shaneoseasnain/Desktop/google-cloud-sdk/bin/gcloud.例如:

    $ /Users/shaneoseasnain/Desktop/google-cloud-sdk/bin/gcloud init
    
    Run Code Online (Sandbox Code Playgroud)

快速入门的相关部分(重点补充):

运行安装脚本以将Cloud SDK工具添加到路径中,在bash shell中启用命令完成,和/或启用使用情况报告:

至于为什么安装脚本不起作用,我不能说.请提出问题,我们会进行调查.


吳約南*_*吳約南 7

这是在 MacOS 上。我有同样的问题。我有gcloud: command not found

之后brew install --cask google-cloud-sdk,我发现我必须手动安装它。

  • 首先,你会install.sh在 directory 下找到google-cloud-sdk,你会.../google-cloud-sdk/install.sh在终端下运行。就我而言,文件位于/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk

  • 二、跑 /usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/install.sh

  • 第三,由于您的bash文件或zsh文件更新,将有一条消息指导您重新启动终端。

  • 第四,gcloud -v测试gcloud-cli在你启动新终端后是否正常工作。

  • 我只做了第二步 `/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/install.sh` 并按照提示操作,它起作用了 (2认同)

小智 5

简而言之:

emacs -nw ~/.zshrc
Run Code Online (Sandbox Code Playgroud)

并在开头添加以下行:

# The next line updates PATH for the Google Cloud SDK.
source '/home/lesaint/GOOGLE_CLOUD/google-cloud-sdk/path.zsh.inc'

# The next lines enables bash completion in Zsh for gcloud. 
autoload -U compinit compdef
compinit
source '/home/lesaint/GOOGLE_CLOUD/google-cloud-sdk/completion.zsh.inc'
Run Code Online (Sandbox Code Playgroud)

以下文章提出的解决方案对我有用:

http://www.javatronic.fr/tips/2014/10/17/installing_google_cloud_sdk_on_ubuntu_with_oh-my-zsh.html