Installed Google Cloud SDK but can't access gcloud

后端 未结 3 1280
有刺的猬
有刺的猬 2021-02-04 05:57

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 whe

相关标签:
3条回答
  • 2021-02-04 06:36

    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.

    0 讨论(0)
  • 2021-02-04 06:43

    In my ~/.bash_profile menu I had an error, at the top I had this line:

    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.

    Once I removed that line gcloud worked fine.

    0 讨论(0)
  • 2021-02-04 06:48

    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

    0 讨论(0)
提交回复
热议问题