首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >-bash: gcloud:在Mac上未找到命令

-bash: gcloud:在Mac上未找到命令
EN

Stack Overflow用户
提问于 2017-09-11 02:41:51
回答 10查看 46.3K关注 0票数 36

我正在按照Quickstart for Mac OS X来安装cloud SDK。完全按照步骤进行,

1) python -V返回"Python 2.7.10“

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

代码语言:javascript
运行
复制
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

3)重启终端,在google-cloud-sdk内部运行gcloud init。这将返回“command not found”。如果运行ls,我会看到以下目录结构:

代码语言:javascript
运行
复制
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

4)我也尝试过在bin中运行gcloud init,但是遇到了同样的问题,command not found

我在安装指南中看到的其他建议是“在bash shell中启用命令补全,和/或启用使用报告”。我不确定如何做到这一点,但命令完成和报告看起来不应该与这个问题相关。有很多关于command not found的文章,但它们与其他问题有关,例如,gcloud在一段时间后停止工作,或者旧版本中的问题。有没有人能告诉我如何让云sdk正常工作?

谢谢

EN

回答 10

Stack Overflow用户

发布于 2017-11-21 18:26:19

我也有同样的问题。一个懒惰而快速的解决方法是直接运行:

brew install --cask google-cloud-sdk

通过谷歌搜索找到的。

票数 87
EN

Stack Overflow用户

发布于 2021-03-25 07:51:51

对于MAC OS -使用Homebrew

代码语言:javascript
运行
复制
brew install --cask google-cloud-sdk

然后使用

代码语言:javascript
运行
复制
 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"
票数 28
EN

Stack Overflow用户

发布于 2017-09-11 06:11:26

gcloud可执行文件位于运行gcloud的google-cloud-sdk/bin-to中。您需要执行以下任一操作:

  1. 将此目录添加到您的$PATH。特别是,在.bash_profile文件(more detail on what this file does and how to pick one)中添加source /Users/shaneoseasnain/Desktop/google-cloud-sdk/path.bash.inc行就可以了。
  2. 在您运行gcloud可执行文件时指定它的完整路径。在您的示例中,这是/Users/shaneoseasnain/Desktop/google-cloud-sdk/bin/gcloud。举个例子:

$ /Users/shaneoseasnain/Desktop/google-cloud-sdk/bin/gcloud初始化

quickstart的相关部分(增加了重点):

运行安装脚本,将云开发工具包工具添加到路径中,在bash shell中启用命令补全,和/或启用使用情况报告:

至于为什么安装脚本不起作用,我不能说。请file an issue,我们会调查的。

票数 10
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46144267

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档