简体   繁体   中英

How to Move Google Cloud SDK Directory

I mistakenly installed the Google Cloud SDK to the wrong directory on my local machine (I installed it to my Google Drive folder, which is not ideal). What is the preferred method of moving the folder? I haven't tried anything yet for fear of creating issues with environment variables that may have been set during installation. I'm running OS X on my local machine.

The Cloud SDK is self contained , and so the google-cloud-sdk directory can generally be moved to wherever you like. The only thing that is configured outside that directory is your ~/.bash_profile file (only if you said yes during the installation process) which adds the SDK to your PATH and installs command tab completion. If you had the installer update that, probably the easiest thing to do is just delete the google-cloud-sdk directory entirely and reinstall in the location you want. The installer will re-update your ~/.bash_profile with the new location.

for zsh, just move the folder to desired location and update .zshrc , check for following lines and set new path:

# The next line updates PATH for the Google Cloud SDK.
... path.zsh.inc ...

# The next line enables shell command completion for gcloud.
... completion.zsh.inc ...

Here is the magic script.. just change the PREV_DIR & NEW_DIR variables

PREV_DIR=/Users/some_user/Downloads/google-cloud-sdk
NEW_DIR=/Users/some_user/google-cloud-sdk

function z(){
  if test -f "$1"; then; sed -i "" -e "s#$PREV_DIR#$NEW_DIR#g" $1 ; fi
}

z ~/.zshrc
z ~/.zprofile
z ~/.bashrc
z ~/.bash_profile
z ~/.kube/config


The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM