gcloud command not found - while installing Google Cloud SDK

后端 未结 28 1115
忘掉有多难
忘掉有多难 2020-12-07 13:43

I am on a mac and am trying to install the Google Cloud SDK (including the gcloud command line utility) using this command in terminal

curl https://sdk.cloud         


        
相关标签:
28条回答
  • 2020-12-07 14:28

    I had the same problem and it was because the ~/.bash_profile had invalid fi statements.

    The fix:

    1. Execute command sudo nano ~/.bash_profile
    2. Removed closing fi statements (the ones missing an opening if)
    3. Save .bash_profile changes
    4. Execute command source ~/.bash_profile
    0 讨论(0)
  • 2020-12-07 14:28

    You have to add the command to the path

    Run

    brew cask info google-cloud-sdk

    and find the lines to append to ~/.zshrc

    The lines to append can be obtained from the output of the previous command. For zsh users, It should be some like these:

    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"
    

    (or choose the proper ones from the command output depending un the Shell you are using)

    0 讨论(0)
  • 2020-12-07 14:29

    Using .zsh shell you can just try to add glcoud in plugin list in the ~/.zshrc file.

    plugins=(
      gcloud
    )
    

    If that doesn't work, try this: (updated Krishna's answer)

    1. Update the ~/.zshrc file
    # Updates PATH for the Google Cloud SDK.
    source /Users/austris/google-cloud-sdk/path.zsh.inc
    
    # Enables zsh completion for gcloud.
    source /Users/austris/google-cloud-sdk/completion.zsh.inc
    
    1. Update the google-cloud-sdk/path.zsh.inc file with following
    script_link="$( readlink "$0" )" || script_link="$0" 
    apparent_sdk_dir="${script_link%/*}" 
    if [[ "$apparent_sdk_dir" == "$script_link" ]]; then
      apparent_sdk_dir=. 
    fi
    sdk_dir="$( cd -P "$apparent_sdk_dir" && pwd -P )" 
    bin_path="$sdk_dir/bin" 
    export PATH=$bin_path:$PATH
    

    *double square brackets at the third line were missing from the original answer

    0 讨论(0)
  • 2020-12-07 14:29
    $ sudo su
    $ /opt/google-appengine-sdk/bin/gcloud components update
    $ su <yourusername>
    
    0 讨论(0)
提交回复
热议问题