gcloud command not found - while installing Google Cloud SDK

后端 未结 28 1114
忘掉有多难
忘掉有多难 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:19

    So below is my previous fix for this problem, but it turns out it isn't permanent. It works but every time you restart Terminal, you'd have to do the same thing which isn't practical.

    So that is why I suggest you delete the current google-cloud-sdk directory, and just redo the installation. Be sure (as Zachary has mentioned) to answer yes (Y) to the prompt Modify profile to update your $PATH and enable bash completion? (Y/n).

    Here is my old answer, but just redo the installation:

    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!
    
    0 讨论(0)
  • 2020-12-07 14:19

    In addition to the above answers, depending on your distro, it may be necessary to execute the bash command from the command line before calling your gsutil command. This is the case for distros that have tcsh or other shell as the default. By typing "bash" the source is changed to the .bashrc file and the file is executed.

    # Step 1
    bash
    # Step 2
    gsutil 
    #Step 3: profit!
    
    0 讨论(0)
  • 2020-12-07 14:20

    I had to source my bash_profile file. To do so,

    1. Open up a Terminal session.
    2. In that session type: source .bash_profile and then press enter

    Now, the gcloud command should work

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

    On Mac/Linux, you'll need to enter the following entry in your ~/.bashrc:

    export PATH="/usr/lib/google-cloud-sdk/bin:$PATH"
    
    0 讨论(0)
  • 2020-12-07 14:23

    This worked for me :

    After saying Y to Modify profile to update your $PATH and enable bash completion? (Y/n)?

    Google initiation is prompting this : Enter a path to an rc file to update, or leave blank to use and the default path was : [/Users/MY_USERSAME/.bash_profile]: but instead of pressing enter, I wrote : /Users/MY_USERNAME/.bashrc to change the path.

    This would overwrite the default location that Google suggest.

    Then, I only had to do source ~/.bashrc and everything works now!

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

    In short:

    emacs -nw ~/.zshrc
    And add following line at the beginning:
    
    # The next line updates PATH for the Google Cloud SDK.
    source '/home/lesaint/GOOGLE_CLOUD/google-cloud-sdk/path.zsh.inc'
    
    #The next lines enables bash completion in Zsh for gcloud. 
    autoload -U compinit compdef
    compinit
    source '/home/lesaint/GOOGLE_CLOUD/google-cloud-sdk/completion.zsh.inc'
    

    The solution proposed by following article works for me:

    Referencee: http://www.javatronic.fr/tips/2014/10/17/installing_google_cloud_sdk_on_ubuntu_with_oh-my-zsh.html

    Check my solution: -bash: gcloud: command not found on Mac

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