[英]Installed Google Cloud SDK but can't access gcloud
I am trying to install the Google Cloud SDK on OSX and do this node.js tutorial ( https://cloud.google.com/nodejs/getting-started/hello-world ) and keep running into a problem where the gcloud
is not found. 我正在尝试在OSX上安装Google Cloud SDK并执行此node.js教程( https://cloud.google.com/nodejs/getting-started/hello-world )并继续
gcloud
不存在的问题找到。 It might be just be something simple about setting in or where I'm in saving the file. 设置或我保存文件的位置可能只是简单的事情。
I've read a ton of other posts here but haven't been able to solve this problem. 我在这里读了很多其他的帖子但是还没能解决这个问题。 Here are all the steps/issues:
以下是所有步骤/问题:
I already created a project in the dev console. 我已经在开发控制台中创建了一个项目。
Install the cloud sdk 安装云sdk
MacBook-Pro-2:~ nico$ curl https://sdk.cloud.google.com | bash
Then go through the process 然后完成整个过程
Directory to extract under (this will create a directory google-cloud-sdk) (/Users/nico):
Do you want to help improve the Google Cloud SDK (Y/n)? y
Modify profile to update your $PATH and enable bash completion? (Y/n)? y
Enter path to an rc file to update, or leave blank to use [/Users/nico/.bash_profile]:
Then I tried to authenticate: 然后我试着验证:
MacBook-Pro-2:~ nico$ gcloud auth login
-bash: gcloud: command not found
Then I went into a cloud sdk bin directory 然后我进入了一个云sdk bin目录
MacBook-Pro-2:~ nico$ cd google-cloud-sdk/bin
MacBook-Pro-2:bin nico$ ./gcloud auth login
Authentication was successful 身份验证成功
MacBook-Pro-2:bin nico$ ./gcloud config set project helloworld-project
Setting the project was successful 设置项目成功
MacBook-Pro-2:bin nico$ ./gcloud components update app
ERROR: (gcloud.components.update) Your current working directory is inside the Cloud SDK install root: /Users/nico/google-cloud-sdk.
In order to perform this update, run the command from outside of this directory.
So then I move out of that directory 然后我离开那个目录
MacBook-Pro-2:test_project nico$ gcloud components update app
-bash: gcloud: command not found
And now it's not working, do I have to set gcloud somewhere so it can be access globally? 现在它不起作用,我是否必须在某处设置gcloud以便可以全局访问? How can I update it and access the gcloud command line tool?
如何更新它并访问gcloud命令行工具?
Looking at the output of the install tool: 查看安装工具的输出:
Enter path to an rc file to update, or leave blank to use [/Users/nico/.bash_profile]:
... it appears that the install tool updated "/Users/nico/.bash_profile" whereas Mac OS X relies on "/Users/nico/.profile" for the configuration. ...似乎安装工具更新了“/Users/nico/.bash_profile”,而Mac OS X依赖于“/Users/nico/.profile”进行配置。 Copy the changes to "/Users/nico/.bash_profile" over to "/Users/nico/.profile" and then close and restart the Terminal for the changes to take effect.
将更改复制到“/Users/nico/.bash_profile”到“/Users/nico/.profile”,然后关闭并重新启动终端以使更改生效。
In the new shell, you can see if "gcloud" is defined using the command: 在新shell中,您可以看到是否使用以下命令定义了“gcloud”:
which gcloud
It should output: 它应该输出:
/Users/nico/google-cloud-sdk/bin/gcloud
If that doesn't work, then I'd recommend just updating your PATH manually. 如果这不起作用,那么我建议您手动更新PATH。 To do that, edit ~/.profile:
为此,编辑〜/ .profile:
nano ~/.profile
And then add the following line at the very end: 然后在最后添加以下行:
export PATH="$HOME/google-cloud-sdk/bin:$PATH"
And restart your shell. 然后重启你的shell。 Note that if you are using a shell other than the builtin Terminal, you may need to edit a different file (such as ~/.bashrc or ~/.bash_profile for a custom BASH installation, and various other "rc" files for altnerative shells such as ZSH, CSH, etc.) to update your PATH variable.
请注意,如果您使用的是内置终端以外的shell,则可能需要编辑其他文件(例如〜/ .bashrc或〜/ .bash_profile用于自定义BASH安装,以及各种其他“rc”文件用于替代shell如ZSH,CSH等)更新你的PATH变量。
If this is still not working, I'd suggest debugging by typing: 如果这仍然无法正常工作,我建议您输入以下命令进行调试:
echo "$PATH"
... so that you can at least see what the current path is set to. ...这样你至少可以看到当前路径的设置。
I had modified my 我修改了我的
vi ~/.bash_profile
and added one line to the end of it 并在其末尾添加了一行
source ~/.bashrc
Then you can log out & logged in again or run: 然后您可以注销并重新登录或运行:
source ~/.bash_profile
After you have added the line. 添加完行后。
OS: Linux vagrant-ubuntu-trusty-64 3.13.0-116-generic #163-Ubuntu
操作系统:Linux vagrant-ubuntu-trusty-64 3.13.0-116-generic#163-Ubuntu
Or Simply Run: 或者简单地运行:
echo "source ~/.bashrc" >> ~/.bash_profile
source ~/.bash_profile
which gcloud
Showed me 给我看了
/home/myusername/google/google-cloud-sdk/bin/gcloud
/家庭/名为myUsername /谷歌/谷歌云SDK /斌/ gcloud
In my ~/.bash_profile menu I had an error, at the top I had this line: 在我的〜/ .bash_profile菜单中我出错了,在顶部我有这一行:
if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi source /Users/nico/.bash_profile
Which was throwing an error and messed with gcloud
, the weird thing is that other command line variables worked fine with that error. 这是抛出错误并与
gcloud
,奇怪的是其他命令行变量与该错误一起工作正常。
Once I removed that line gcloud
worked fine. 一旦我删除该行,
gcloud
工作正常。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.