Skip to content

cc-switch keeps deleting my environment variables

Quick fix

Closing the conflict dialog does not delete anything. To clear it for good, remove the entry from your shell config or the Hermes config.yaml.

Error output
打开cc-swtich就老是说环境变量冲突,就立马给删除了
English translation

Opening cc-swtich keeps saying there is an environment variable conflict, and then it deletes them immediately

cc-switch works by writing config files, and environment variables in your shell config (`~/.bashrc`/`~/.zshrc`) take higher priority and override what cc-switch writes — hence the environment conflict detection notice. Maintainers explained in #2071 that this detection "does not delete your environment variables if you just close it", so what users see as automatic deletion is mostly a misreading.

But #5558 reports another problem on the same conflict notice path: on v3.17.0, opening the settings page and then quitting cc-switch leaves the conflict dialog unclosable when a conflict is detected next time, with no confirmed fix version. Separately, #3051 reports some newly added environment variables being undeletable in cc-switch and shown as managed by Hermes; comments note that deleting the database alone does nothing and the entry has to be removed from the Hermes config.yaml.

  1. When the conflict notice appears, close it with the X at the top right rather than making a selection or running a repair. That does not delete environment variables from `~/.bashrc` or similar files.

  2. To clear the conflict for good, edit your shell startup file and comment out or delete the matching environment variable, `GEMINI_API_KEY=xxxx` for example.

    ~/.bashrc(或 ~/.zshrc)
    # 删除或注释下面这行即可消除冲突提示
    # GEMINI_API_KEY=xxxx
  3. If a variable shows as managed by Hermes and cannot be deleted in cc-switch, open the Hermes `config.yaml` and remove the matching environment variable entry — deleting the database alone has no effect.

  4. If the conflict dialog cannot be closed at all (reproducible on v3.17.0 by opening the settings page then quitting), quit the cc-switch process and reopen it as a stopgap. No confirmed fix version exists yet.

Toolcc-switch
Version3.13 - 3.17.0(受影响范围;#5558 在 3.17.0 仍可复现)
PlatformsLinuxmacOSWindows
Why does cc-switch delete my environment variables?
It does not delete them on its own. cc-switch detects that shell environment variables override the config it writes, so it raises a conflict notice — closing the dialog does not delete anything.
Does deleting the database resolve a Hermes environment variable that will not delete?
No. The comments confirm: "deleting the database does nothing, the source is in the Hermes config.yaml — remove it there and it disappears completely".
The conflict dialog cannot be closed. What now?
A known behaviour on v3.17.0. Quit the cc-switch process and reopen it as a stopgap while waiting for a fix.

This is an unofficial community wiki with no affiliation to the cc-switch authors or the project itself. Its content is compiled from the project's public GitHub issues. This site distributes no software.