smn*_*ntx 102 terminal installation google-cloud-storage google-cloud-platform gcloud
我在Mac上,正在尝试使用终端中的此命令安装Google Cloud SDK(包括gcloud命令行实用程序)
curl https://sdk.cloud.google.com | bash
Run Code Online (Sandbox Code Playgroud)
如https://cloud.google.com/sdk/所示
它一直到最后并完成,但即使在我重新启动我的shell之后,该gcloud命令仍然说它没有找到.
为什么这个装置不起作用?
smn*_*ntx 101
所以下面是我之前解决这个问题的方法,但事实证明它不是永久性的.它工作,但每次重新启动终端,你必须做同样的事情,这是不切实际的.
所以我建议你删除当前的google-cloud-sdk目录,然后重做安装.确保(如Zachary所提到的)对提示回答是(Y)Modify profile to update your $PATH and enable bash completion? (Y/n).
这是我的旧答案,但只是重做安装:
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!
Run Code Online (Sandbox Code Playgroud)
nvc*_*ken 42
同样在这里,我试试
source ~/.bashrc
Run Code Online (Sandbox Code Playgroud)
然后,它工作
Mir*_* Vu 26
这个对我有用:
source ~/.bash_profile
Run Code Online (Sandbox Code Playgroud)
Zep*_*ine 24
就我而言,我在安装 Google Cloud SDK 后将终端从 bash 切换到 zsh,因此显示“zsh: command not found: gcloud”错误。
通过运行解决了
source ~/.zshrc
Run Code Online (Sandbox Code Playgroud)
Map*_*psy 23
在Mac/Linux上,您需要在以下内容中输入以下条目~/.bashrc:
export PATH="/usr/lib/google-cloud-sdk/bin:$PATH"
Run Code Online (Sandbox Code Playgroud)
Ibr*_*him 20
我今天遇到了这个问题,并在maxOS Sierra上添加sudo了install command修复我的问题!
sudo ./google-cloud-sdk/install.sh
Run Code Online (Sandbox Code Playgroud)
小智 12
我知道这个问题已得到解答,但这是我的两分钱.安装gcloud之后,您需要在能够执行gcloud命令之前重新启动shell.
如何执行此操作,主要取决于您保留shell配置的文件.大部分文件是.bashrc_profile,.bashrc,.zshrc.
您现在可以重新启动
source ~/.bashrc_profile
您可以将文件替换为您拥有的文件.
或者,如果您不关心您拥有的文件,则可以在Mac或Linux上重新启动shell.
exec -l $SHELL
dha*_*eme 12
您必须将命令添加到路径中
跑
brew info --cask google-cloud-sdk
并找到要附加到的行 ~/.zshrc
要附加的行可以从上一个命令的输出中获得。对于 zsh 用户,它应该是这样的:
export CLOUDSDK_PYTHON="/usr/local/opt/python@3.8/libexec/bin/python"
source "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/path.zsh.inc"
source "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/completion.zsh.inc"
Run Code Online (Sandbox Code Playgroud)
(或根据您使用的 Shell 从命令输出中选择正确的)
小智 11
安装SDK时我使用了这个方法:
curl https://sdk.cloud.google.com | bash
Run Code Online (Sandbox Code Playgroud)
从原始作者使用此方法时,请确保您已接受Mac设置中的安全首选项,以允许从应用商店和已识别的开发人员下载的应用.
小智 10
在Mac OS HIGH Sierra上重新启动后,如何安装GCloud并始终运行:
在此处下载安装包
已实现文件并放入您的文件夹
打开终端,转到带有文件的文件夹,然后输入以下命令:
./google-cloud-sdk/install.sh
Run Code Online (Sandbox Code Playgroud)“修改个人资料以更新您的信息$PATH并启用bash完成吗?”
是
/Users/USERNAME_COMPUTER/.bashrc安装完成后,输入以下内容:
source ~/.bashrc
Run Code Online (Sandbox Code Playgroud)输入以下内容检查安装gcloud:
gcloud-版本
打开新窗口终端cmd+n
DONT CLOSE OLD WINDOW并输入新窗口gcloud version
如果:«找不到命令»转到步骤9
否则:祝贺GCloud在终端中工作
返回旧窗口并输入echo $PATH
并将路径复制到GCloud
打开BASH_PROFILE:
open ~/.bash_profile
Run Code Online (Sandbox Code Playgroud)输入新Bash的路径:
« export PATH="/Users/USERNAME_COMPUTER/google-cloud-sdk/bin:$PATH" »
Run Code Online (Sandbox Code Playgroud)返回步骤8
小智 9
您只需要以root用户身份执行此命令
$ curl https://sdk.cloud.google.com | bash
Run Code Online (Sandbox Code Playgroud)
重新启动终端,仅此而已。现在,所有命令都应以root用户身份执行
我正在运行zsh并发现此要点非常有帮助:https : //gist.github.com/dwchiang/10849350
编辑〜/ .zshrc文件以包括以下两行:
# The next line updates PATH for the Google Cloud SDK.
source /Users/YOUR_USERNAME/google-cloud-sdk/path.zsh.inc
# The next line enables zsh completion for gcloud.
source /Users/YOUR_USERNAME/google-cloud-sdk/completion.zsh.inc
Run Code Online (Sandbox Code Playgroud)
假设您已从官方文档将软件包安装在主目录中
小智 6
为了在 MacOs Sierra 上启动它,安装 gcloud 后我修改了我的 .bash_profile
原始线路:
# The next line updates PATH for the Google Cloud SDK.
if [ -f '/Users/alejandro/google-cloud-sdk/path.bash.inc' ]; then . '/Users/alejandro/google-cloud-sdk/path.bash.inc'; fi
# The next line enables shell command completion for gcloud.
if [ -f '/Users/alejandro/google-cloud-sdk/completion.bash.inc' ]; then . '/Users/alejandro/google-cloud-sdk/completion.bash.inc'; fi
Run Code Online (Sandbox Code Playgroud)
更新为:
# The next line updates PATH for the Google Cloud SDK.
if [ -f '/Users/alejandro/google-cloud-sdk/path.bash.inc' ]; then source '/Users/alejandro/google-cloud-sdk/path.bash.inc'; fi
# The next line enables shell command completion for gcloud.
if [ -f '/Users/alejandro/google-cloud-sdk/completion.bash.inc' ]; then source '/Users/alejandro/google-cloud-sdk/completion.bash.inc'; fi
Run Code Online (Sandbox Code Playgroud)
重新启动终端,一切都按预期工作!
这对我有用:
说后Y到Modify profile to update your $PATH and enable bash completion? (Y/n)?
谷歌启动提示这个 :Enter a path to an rc file to update, or leave blank to use并且默认路径是 :[/Users/MY_USERSAME/.bash_profile]:但enter我没有按,而是写了 :/Users/MY_USERNAME/.bashrc来更改路径。
这将覆盖 Google 建议的默认位置。
然后,我只需要做source ~/.bashrc,现在一切正常!
如果您是 macOS homebrew zsh 用户:
brew cask install google-cloud-sdk
更新你的~/.zshrc:
plugins=(
...
gcloud
)
Run Code Online (Sandbox Code Playgroud)