解除安裝 Google Cloud CLI

如果安裝作業是使用 OS 套件 (例如 apt-get 或 yum) 完成,請使用 OS 套件管理工具解除安裝 gcloud CLI。

如果是 Windows 安裝作業,請在 gcloud CLI 目錄中執行 uninstaller.exe 檔案。

如要移除 gcloud CLI,請按照下列操作說明進行:

  1. 請執行下列指令找出您的安裝目錄:

     gcloud info --format='value(installation.sdk_root)'
    

    執行下列指令,找出使用者設定目錄 (在 MacOS 和 Linux 上通常是 ~/.config/gcloud):

     gcloud info --format='value(config.paths.global_config_dir)'
    
  2. 刪除這兩個目錄。

  3. 此外,如果您在安裝期間新增了 .bashrc 或對等殼層 init 檔案,請移除來源為 completion.bash.inc 和 path.bash.inc 的行。

  4. 查看主目錄中 .boto 檔案的內容,並移除 [GoogleCompute] 和 [GSUtil] 區段。此外,請查看 [OAuth2] 和 [Credentials] 部分,瞭解哪些設定已不再需要。

  5. 部分系統可能會有 Cache 目錄,例如 Mac OS X 上的 ~/Library/Caches/。請找出並刪除系統中的下列目錄:

     find ~/Library/Caches/ -type d -name "google-cloud-sdk" | xargs -I {} rm -r "{}"