Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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. 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

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

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? How can I update it and access the gcloud command line tool?

like image 426
NicoM Avatar asked Jun 27 '15 02:06

NicoM


2 Answers

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. 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.

In the new shell, you can see if "gcloud" is defined using the command:

 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. To do that, edit ~/.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. 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.

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.

like image 88
Michael Aaron Safyan Avatar answered Sep 18 '22 22:09

Michael Aaron Safyan


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

Or Simply Run:

echo "source ~/.bashrc" >> ~/.bash_profile
source ~/.bash_profile
which gcloud

Showed me

/home/myusername/google/google-cloud-sdk/bin/gcloud

like image 27
JayRizzo Avatar answered Sep 18 '22 22:09

JayRizzo