I went looking for some conda
settings. (If you must know, it was related to messing with my bash
's $PS1
- decisions whether to use conda
's config or perhaps environment variables.) For finding the settings, the instruction was to look in .condarc
. To find .condarc
, I was instructed to use, conda config --show-sources
. I did, with this result:
(base) [bballdave025@MYMACHINE ~]$ conda config --show-sources
(base) [bballdave025@MYMACHINE ~]$
i.e. it's blank. A look through some conda documentation (and the paths it suggested looking through) didn't yield any .condarc
, either. I did my own searching in other places, but still nothing. That's okay - I can live without a .condarc
(and I know I could just create one, either by touch $HOME/.condarc
or by setting one of the parameters with conda config --set changeps1 False
- or any conda config --set <param-name> <value>
).
However, when I look at the configuration parameters (settings or default-values), I definitely see some values. Some of the commands used to see these values are conda info
, conda config --show
, and conda config --describe
. I'll give details of those commands after I ask my main question.
This question is almost certainly academic, but it's driving me crazy not to know: Where in the world are these values coming from? They've got to come from somewhere. I imagine it's some sort of a file, whether locally or somewhere online, whether text-based or pure binary. I have had no luck finding the source; obviously, it's not in any .condarc
, but it's also not anywhere else I've searched. Where is conda
pulling these values from?
The rest of this post contains details of the situation and my attempts to find the answer. The real basics are all above this point in the post. One other quick note: Since they will likely be useful, the information on my system and the conda info
are at the very end of this post.
Commands that Show the Situation
Here are some commands to show the lack of a .condarc
and to show the existence of default values for parameters/settings.
To repeat,
(base) [bballdave025@MYMACHINE ~]$ conda config --show-sources
returns nothing - maybe an empty string, but I consider that nothing.
The other searches for a .condarc
file showed that the in-conda
settings could not have come from any file with a name like "*condarc*"
. You can see the Finding "*condarc*"
Files section for details.
Here are the ways I see the settings.
(base) [bballdave025@MYMACHINE ~]$ conda config --show | head
add_anaconda_token: True
add_pip_as_python_dependency: True
aggressive_update_packages:
- ca-certificates
- certifi
- openssl
allow_conda_downgrades: False
allow_cycles: True
allow_non_channel_urls: False
allow_softlinks: False
(base) [bballdave025@MYMACHINE ~]$ conda config --show | grep -i -C2 ps1
auto_update_conda: True
bld_path:
changeps1: True
channel_alias: https://conda.anaconda.org
channel_priority: flexible
Other commands seem to validate this:
(base) [bballdave025@MYMACHINE ~]$ conda info -a > tmpf && head -n 6 tmpf && rm tmpf
active environment : base
active env location : /home/bballdave025/anaconda3
shell level : 1
user config file : /home/bballdave025/.condarc
populated config files :
(base) [bballdave025@MYMACHINE ~]$ conda config --describe | awk '/changeps1/' RS= # Note the blank at the end
# # changeps1 (bool)
# # When using activate, change the command prompt ($PS1) to include the
# # activated environment.
# #
# changeps1: true
(base) [bballdave025@MYMACHINE ~]$ conda config --describe | awk '/env_prompt/' RS= # Note the blank at the end
# # env_prompt (str)
# # Template for prompt modification based on the active environment.
# # Currently supported template variables are '{prefix}', '{name}', and
# # '{default_env}'. '{prefix}' is the absolute path to the active
# # environment. '{name}' is the basename of the active environment
# # prefix. '{default_env}' holds the value of '{name}' if the active
# # environment is a conda named environment ('-n' flag), or otherwise
# # holds the value of '{prefix}'. Templating uses python's str.format()
# # method.
# #
# env_prompt: '({default_env}) '
Finding `"*condarc*"` Files
A long input, ready for copy/paste. You might just want to head down to the output part.
find $HOME -type f -iname "*condarc*" -print0 | \
xargs -I'{}' -0 \
bash -c \
'orig="{}"; fname="${orig}"; '\
'dashes="----------------------------------"; '\
'echo "${dashes}"; echo "For file: '"'"'${fname}'"'"'"; '\
'echo "-----"; '\
'if ! grep -q "root_dir" "${fname}"; then '\
' echo " No '"'"'root_dir'"'"' in file; "'\
'"most likely invalid as a settings \`condarc\`"; '\
' if grep -q proxy <(echo "${fname}"); then '\
' echo " There is a '"'"'proxy'"'"' in the filename, "'\
'"so it is not a huge surprise."; '\
' fi; '\
'else '\
' echo " '"'"'root_dir'"'"' in file; "'\
'"could possibly be valid as a settings \`condarc\`"; '\
'fi; '\
'if grep -q changeps1 "${fname}" ; then '\
' echo " From the file:"; '\
' grep_str=$(grep changeps1 "${fname}"); '\
' echo "${grep_str}"; '\
' echo " From \`conda config --show | grep changeps1\`"; '\
' condaconf_str=$(conda config --show | grep changeps1); '\
' echo "${condaconf_str}"; '\
' if [ "${grep_str}" = "${condaconf_str}" ]; then '\
' echo " The strings are equivalent, therefore the "'\
'"settings are equivalent."; '\
' echo " The in-conda settings could have come "'\
'"from this file."; '\
' else '\
' echo " The strings - and therefore the settings - are "'\
'"not equivalent."; '\
' echo " The in-conda settings could not have come "'\
'"from this file."; '\
' if grep -q test <(echo "${fname}"); then '\
' echo " There is a '"'"'test'"'"' in the file path, "'\
'"so it is not a huge surprise."; '\
' fi; '\
' fi; '\
'else '\
' echo " No '"'"'changeps1'"'"' found in file."; '\
' echo " The in-conda settings could not have come "'\
'"from this file."; '\
'fi; '\
'echo "${dashes}"; echo;';
A long output showing no condarc
file could have been used for the current, in-conda
settings.
----------------------------------
For file: '/home/bballdave025/anaconda3/pkgs/conda-4.11.0-py39h06a4308_0/info/test/tests/condarc'
-----
'root_dir' in file; could possibly be valid as a settings `condarc`
From the file:
changeps1: False
From `conda config --show | grep changeps1`
changeps1: True
The strings - and therefore the settings - are not equivalent.
The in-conda settings could not have come from this file.
There is a 'test' in the file path, so it is not a huge surprise.
----------------------------------
----------------------------------
For file: '/home/bballdave025/anaconda3/pkgs/conda-4.11.0-py39h06a4308_0/info/test/tests/integration/proxy/condarc.proxybad'
-----
No 'root_dir' in file; most likely invalid as a settings `condarc`
There is a 'proxy' in the filename, so it is not a huge surprise.
No 'changeps1' found in file.
The in-conda settings could not have come from this file.
----------------------------------
----------------------------------
For file: '/home/bballdave025/anaconda3/pkgs/conda-4.11.0-py39h06a4308_0/info/test/tests/integration/proxy/condarc.proxygood'
-----
No 'root_dir' in file; most likely invalid as a settings `condarc`
There is a 'proxy' in the filename, so it is not a huge surprise.
No 'changeps1' found in file.
The in-conda settings could not have come from this file.
----------------------------------
----------------------------------
For file: '/home/bballdave025/anaconda3/pkgs/conda-4.10.3-py39h06a4308_0/info/test/tests/integration/proxy/condarc.proxybad'
-----
No 'root_dir' in file; most likely invalid as a settings `condarc`
There is a 'proxy' in the filename, so it is not a huge surprise.
No 'changeps1' found in file.
The in-conda settings could not have come from this file.
----------------------------------
----------------------------------
For file: '/home/bballdave025/anaconda3/pkgs/conda-4.10.3-py39h06a4308_0/info/test/tests/integration/proxy/condarc.proxygood'
-----
No 'root_dir' in file; most likely invalid as a settings `condarc`
There is a 'proxy' in the filename, so it is not a huge surprise.
No 'changeps1' found in file.
The in-conda settings could not have come from this file.
----------------------------------
----------------------------------
For file: '/home/bballdave025/anaconda3/pkgs/conda-4.10.3-py39h06a4308_0/info/test/tests/condarc'
-----
'root_dir' in file; could possibly be valid as a settings `condarc`
From the file:
changeps1: False
From `conda config --show | grep changeps1`
changeps1: True
The strings - and therefore the settings - are not equivalent.
The in-conda settings could not have come from this file.
There is a 'test' in the file path, so it is not a huge surprise.
----------------------------------
I'm running a system wide search (i.e. from /
, except excluding things like /dev/
, which could mess up such a search). Basically, everything will be the same except find $HOME
will change to sudo find /
with a 2>/dev/null
at the end. I'm also going to run a system wide grep
for changeps1
. I doubt that I'll find anything, but it's worth a shot. I'll put in an edit about what I'll have found.
Edit: The answer came in before I needed to finish either of these searches.
System Info and Conda Info
Here's my system info:
(base) [bballdave025@MYMACHINE ~]$ uname -a
Linux MYMACHINE 4.18.0-348.7.1.el8_5.x86_64 #1 SMP Wed Dec 8 21:51:17 EST
2021 x86_64 x86_64 x86_64 GNU/Linux
So, I'm running RHEL 8 - Red Hat.
Here's my conda
info:
(base) [bballdave025@MYMACHINE ~]$ conda info
active environment : base
active env location : /home/bballdave025/anaconda3
shell level : 1
user config file : /home/bballdave025/.condarc
populated config files :
conda version : 4.11.0
conda-build version : 3.21.5
python version : 3.9.7.final.0
virtual packages : __linux=4.18.0=0
__glibc=2.28=0
__unix=0=0
__archspec=1=x86_64
base environment : /home/bballdave025/anaconda3 (writable)
conda av data dir : /home/bballdave025/anaconda3/etc/conda
conda av metadata url : None
channel URLs : https://repo.anaconda.com/pkgs/main/linux-64
https://repo.anaconda.com/pkgs/main/noarch
https://repo.anaconda.com/pkgs/r/linux-64
https://repo.anaconda.com/pkgs/r/noarch
package cache : /home/bballdave025/anaconda3/pkgs
/home/bballdave025/.conda/pkgs
envs directories : /home/bballdave025/anaconda3/envs
/home/bballdave025/.conda/envs
platform : linux-64
user-agent : conda/4.11.0 requests/2.26.0 CPython/3.9.7 Linux/4.18.0-348.7.1.el8_5.x86_64 rhel/8.5 glibc/2.28
UID:GID : 1001:1001
netrc file : None
offline mode : False
CodePudding user response:
If there are no .condarc
sources, Conda falls back to the values that are hardcoded in the conda.base.context.Context
class. Here's a relevant snippet:
class Context(Configuration):
add_pip_as_python_dependency = ParameterLoader(PrimitiveParameter(True))
allow_conda_downgrades = ParameterLoader(PrimitiveParameter(False))
# allow cyclical dependencies, or raise
allow_cycles = ParameterLoader(PrimitiveParameter(True))
allow_softlinks = ParameterLoader(PrimitiveParameter(False))
auto_update_conda = ParameterLoader(PrimitiveParameter(True), aliases=('self_update',))
auto_activate_base = ParameterLoader(PrimitiveParameter(True))
auto_stack = ParameterLoader(PrimitiveParameter(0))
notify_outdated_conda = ParameterLoader(PrimitiveParameter(True))
clobber = ParameterLoader(PrimitiveParameter(False))
changeps1 = ParameterLoader(PrimitiveParameter(True))
env_prompt = ParameterLoader(PrimitiveParameter("({default_env}) "))
# ...