New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
conda init shouldn't activate base environment #8211
Comments
I struggled with this. I agree with you, but it also goes against the momentum of what users expect as current behavior. I introduced a config parameter |
In the meantime I've added |
BTW use |
Each invocation of |
TLDR; I have been back and forth on this too.
Nevertheless, I love all the improvements, the speed, the support for more shells, and the pip interoperability direction. |
Relevant:
On one hand I think it's an interesting idea to add some of this configuration to |
related: #8169 |
I see...and agreed, no bloat , no duplication :) |
The Conda Configuration Engine for Power Users is a blog post I wrote a while back that I don't think has still been fully incorporated into the docs. We have a docs team trying to catch up on the backlog now :) |
Nice!! :) Thanks |
This is also a problem for sub shells. They now always activate the base env and deactivate a previously activated env: $ echo "$CONDA_SHLVL $CONDA_PREFIX"
1 /path/to/conda
$ conda activate test
(test) $ echo "$CONDA_SHLVL $CONDA_PREFIX"
2 /path/to/conda/envs/test
(test) $ bash
$ echo "$CONDA_SHLVL $CONDA_PREFIX"
1 /path/to/conda This is especially annoying for shells started within neovim or another editor. |
Something like this in my . "$HOME/conda/etc/profile.d/conda.sh"
if [[ -z ${CONDA_PREFIX+x} ]]; then
export PATH="$HOME/conda/bin:$PATH"
fi $ which pip
~/conda/bin/pip
$ conda activate test
(test) $ which pip
~/conda/envs/test/bin/pip
(test) $ # Env should still be activated:
(test) $ bash
(test) $ which pip
~/conda/envs/test/bin/pip
(test) $ # Deactivate env in sub shell
(test) $ conda deactivate
$ exit
(test) $ # Env is still active in parent shell
(test) $ conda deactivate
$ which pip
~/conda/bin/pip |
@sscherfke do you mind briefly explaining the goal of your script? |
This snippet (below an updated version) does the following:
|
@sscherfke Thanks for the clarification. I'm trying to extend this behavior to starting a new terminal in a new window. |
Looking forward to testing your ideas. :) |
I could get rid of this behaviour by invoking However, I have to say this was a really confusing behaviour after reinstalling miniconda. (Since I was used to NOT having all the binaries from the base environment in my PATH ...) and I strongly suggest we make this a user-controlled setting which is part of the install process (like adding everything to PATH was in earlier versions...). |
That's why we have a message about |
Oh then that did in fact slip past my attention, mea culpa. But seeing as this has confused some people (also on stackoverflow) you may want to change that to asking the user in the install process with a default to yes? Just a suggestion. |
I looked at https://www.anaconda.com/conda-configuration-engine-power-users/ mentioned above and saw that config params for conda can be set using env variables. This works for me now in bash scripts (where i don't want the default behavior)
|
I don't think this makes much sense in that case. My understanding is that newbies are less likely to read information that is provided for them, and also having an environment already active I believe leads to the case where the said newbie ends up creating envs inside envs, and other issues. |
It's not easy to create envs inside other envs without really trying to do so (you have to use the less common, less documented -p option to do that and even then I expect conda might prevent it). It does not happen by default. Envs are all created in the envs subdir of the root of the installation unless -p and an explicit path are specified. |
Basically any installer asks the user if the new binaries should be added to PATH automatically. This is kind of the behavior I have learned to expect from installers that fiddle with my environment variables. Therefore, I think there is no problem asking the user if the default environment should be activated automatically? |
Even with # >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
if [ -n "$ZSH_VERSION" ]; then
__conda_setup="$('/home/konfekt/miniconda3/bin/conda' 'shell.zsh' 'hook' 2> /dev/null)"
elif [ -n "$BASH" ]; then
__conda_setup="$('/home/konfekt/miniconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
fi
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
if [ -f "/home/konfekt/miniconda3/etc/profile.d/conda.sh" ]; then
. "/home/konfekt/miniconda3/etc/profile.d/conda.sh"
else
export PATH="/home/konfekt/miniconda3/bin:$PATH"
fi
fi
unset __conda_setup
# <<< conda initialize <<< around conda_activate() {
...
conda activate "$@"
} to init conda when activated on demand. |
|
Ah you edited it, well, still |
A natural name for the function that calls the code managed by |
I've had a few CentOS 7 users that couldn't use their desktop (gnome-shell) anymore because of conda. The reason is that the gnome-shell relies on the system's Python and that the user's .bashrc is loaded during graphical logins... |
Despite this topic being closed, I'd like to add my voice to those who were surprised to see |
Hi there, thank you for your contribution! This issue has been automatically locked because it has not had recent activity after being closed. Please open a new issue if needed. Thanks! |
With the new
conda init
, the base environment is always activated in new shells. I don't think this is helpful. I don't want conda-installed binaries to shadow the system ones by default. Sinceconda
is set up as a shell function as well, this default activation sounds unnecesary.The text was updated successfully, but these errors were encountered: