简体   繁体   English

如何移动 Google Cloud SDK 目录

[英]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).我错误地将 Google Cloud SDK 安装到了我本地机器上的错误目录中(我将它安装到了我的 Google Drive 文件夹中,这并不理想)。 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.我在本地机器上运行 OS X。

The Cloud SDK is self contained , and so the google-cloud-sdk directory can generally be moved to wherever you like. Cloud SDK 是自包含的,因此通常可以将google-cloud-sdk目录移动到您喜欢的任何位置。 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.在该目录之外配置的唯一内容是您的~/.bash_profile文件(仅当您在安装过程中说是时),它将 SDK 添加到您的 PATH 并安装命令选项卡完成。 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.如果您有安装程序更新,可能最简单的方法就是完全删除 google-cloud-sdk 目录并重新安装到您想要的位置。 The installer will re-update your ~/.bash_profile with the new location.安装程序将使用新位置重新更新您的~/.bash_profile

for zsh, just move the folder to desired location and update .zshrc , check for following lines and set new path:对于 zsh,只需将文件夹移动到所需位置并更新.zshrc ,检查以下行并设置新路径:

# 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 和 NEW_DIR 变量

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


声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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