Search code examples
anacondazshdotfiles

How to tell conda init location of .zshrc?


I'm trying to install miniconda automatically in my setup script. The issue is, I have my .zshrc in ~/.config/zsh/ and when I run

eval "${XDG_DATA_HOME}/miniconda/bin/conda init zsh"

it creates new .zshrc in my home.

How could I tell the conda init where my .zshrc is?


Solution

  • Known Bug with Imminent Fix

    This is a known issue and a fix has been merged into master branch, but is not yet released. The fix assumes that the ZDOTDIR environment variable defines where to find the .zshrc file. If one didn't have it defined, then the fix would be

    ZDOTDIR=~/.config/zsh conda init zsh
    

    However, that will have to wait until the next release.

    Temporary Workaround

    In the meantime you can just manually copy the code it added to ~/.zshrc and append it to yours. Or if you are super concerned about Conda running it, you could run this script in the Conda base Python

    File: init_zsh.py

    #!/usr/bin/env python
    from conda.core.initialize import init_sh_user
    from conda.base.context import context
    from conda.common.path import expand
    
    init_sh_user(expand("$ZDOTDIR/.zshrc"), context.conda_prefix, "zsh")
    

    which for you would be something like

    eval "${XDG_DATA_HOME}/miniconda/bin/python init_zsh.py"
    

    assuming ZDOTDIR is defined.