bloosh
bloosh

Reputation: 288

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.

Upvotes: 13

Views: 6812

Answers (3)

Vikas Verma
Vikas Verma

Reputation: 11

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


Upvotes: 1

attaboyabhipro
attaboyabhipro

Reputation: 1628

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

Upvotes: 1

Mark
Mark

Reputation: 2355

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.

Upvotes: 23

Related Questions