Repository: conda/conda

Issue:
condarc file precedence not respected when merging
In my system `.condarc` I have `defaults` and `conda-forge` and in my user `.condarc` I have my own `dhirschfeld` channel:

![image](https://user-images.githubusercontent.com/881019/52687124-445f2300-2f9c-11e9-9474-bb677267d09c.png)

My understanding ([from this blog post](https://www.anaconda.com/conda-configuration-engine-power-users/)) was that the system `.condarc` should take precedence when merging and that my channel should be *appended* to the channel list. This is the behaviour I'd like, but not what I'm observing in practice:
```
(base) C:\> conda info

     active environment : base
    active env location : C:\Miniconda3
            shell level : 1
       user config file : C:\Users\dhirschfeld\.condarc
 populated config files : C:\Miniconda3\.condarc
                          C:\Users\dhirschfeld\.condarc
          conda version : 4.6.3
    conda-build version : not installed
         python version : 3.7.1.final.0
       base environment : C:\Miniconda3  (writable)
           channel URLs : https://conda.anaconda.org/dhirschfeld/win-64
                          https://conda.anaconda.org/dhirschfeld/noarch
                          https://repo.anaconda.com/pkgs/main/win-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/free/win-64
                          https://repo.anaconda.com/pkgs/free/noarch
                          https://repo.anaconda.com/pkgs/r/win-64
                          https://repo.anaconda.com/pkgs/r/noarch
                          https://repo.anaconda.com/pkgs/msys2/win-64
                          https://repo.anaconda.com/pkgs/msys2/noarch
                          https://conda.anaconda.org/conda-forge/win-64
                          https://conda.anaconda.org/conda-forge/noarch
          package cache : C:\Miniconda3\pkgs
                          C:\Users\dhirschfeld\.conda\pkgs
                          C:\Users\dhirschfeld\AppData\Local\conda\conda\pkgs
       envs directories : C:\Miniconda3\envs
                          C:\Users\dhirschfeld\.conda\envs
                          C:\Users\dhirschfeld\AppData\Local\conda\conda\envs
               platform : win-64
             user-agent : conda/4.6.3 requests/2.21.0 CPython/3.7.1 Windows/10 Windows/10.0.17763
          administrator : False
             netrc file : None
           offline mode : False
```


Discussion:
This one is tricky and unfortunate, and there’s really no good solution. What’s happening is that the “system” .condarc in the base environment is also the .condarc in the active environment. It gets doubled up, and sandwiches the user .condarc when the base environment is the active environment. 
> there’s really no good solution

The best solution is to use one of the lower-level paths other than the .condarc in your base environment.

https://github.com/conda/conda/blob/b1a29f1/conda/base/constants.py#L27-L45

However the search path was originally laid out for unix-y file systems and we never really added in a switch for a search path that's more Windows-native.

Will python on Windows automatically covert `/etc/conda/.condarc` to `C:\etc\conda\.condarc` for you?
I've found that adding `#!top` in the system condarc does put them at the top (and maintains the order) - e.g.
```
channels:
  - defaults  #!top
  - conda-forge  #!top
```
```
(base) C:\> conda info

     active environment : base
    active env location : C:\Miniconda3
            shell level : 1
       user config file : C:\Users\dhirschfeld\.condarc
 populated config files : C:\Miniconda3\.condarc
                          C:\Users\dhirschfeld\.condarc
          conda version : 4.6.3
    conda-build version : not installed
         python version : 3.7.1.final.0
       base environment : C:\Miniconda3  (writable)
           channel URLs : https://repo.anaconda.com/pkgs/main/win-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/free/win-64
                          https://repo.anaconda.com/pkgs/free/noarch
                          https://repo.anaconda.com/pkgs/r/win-64
                          https://repo.anaconda.com/pkgs/r/noarch
                          https://repo.anaconda.com/pkgs/msys2/win-64
                          https://repo.anaconda.com/pkgs/msys2/noarch
                          https://conda.anaconda.org/conda-forge/win-64
                          https://conda.anaconda.org/conda-forge/noarch
						  https://conda.anaconda.org/dhirschfeld/win-64
                          https://conda.anaconda.org/dhirschfeld/noarch
          package cache : C:\Miniconda3\pkgs
                          C:\Users\dhirschfeld\.conda\pkgs
                          C:\Users\dhirschfeld\AppData\Local\conda\conda\pkgs
       envs directories : C:\Miniconda3\envs
                          C:\Users\dhirschfeld\.conda\envs
                          C:\Users\dhirschfeld\AppData\Local\conda\conda\envs
               platform : win-64
             user-agent : conda/4.6.3 requests/2.21.0 CPython/3.7.1 Windows/10 Windows/10.0.17763
          administrator : False
             netrc file : None
           offline mode : False
```
> *Will python on Windows automatically convert `/etc/conda/.condarc` to `C:\etc\conda\.condarc` for you?*

It seems so:
```
(base) C:\> New-Item -Type File -Force /etc/conda/.condarc

    Directory: C:\etc\conda

Mode                LastWriteTime         Length Name
----                -------------         ------ ----
-a----       13/02/2019   3:49 PM              0 .condarc


(base) C:\> Add-Content /etc/conda/.condarc 'Hello World!'
(base) C:\> python

Python 3.7.1 (default, Dec 10 2018, 22:54:23) [MSC v.1915 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> with open('/etc/conda/.condarc', 'r') as f:
...     print(f.read())
...
Hello World!

>>>
```
Ha! Here's something interesting - the 'Hello World' `.condarc` file I created just "broke conda"! :laughing: 
```
(base) C:\> conda info
[y/N]: N
(base) C:\>
```
I think "Don't do that" is a valid solution to that problem though - deleting the folder "fixed" my conda again.
If I move my `.condarc` file to either `C:\Miniconda3\condarc` or `C:\Miniconda3\condarc.d`
directories it doesn't get picked up at all.

***Edit:*** Is this perhaps because `CONDA_ROOT` is undefined?
```
(base) C:\> $env:CONDA_ROOT
(base) C:\>
```
Maybe, to not conflate the base environment with a system configuration, the system configuration could live in `C:\ProgramData\conda\.condarc` on Windows? 

Resolving patch:
diff --git a/conda/base/constants.py b/conda/base/constants.py
--- a/conda/base/constants.py
+++ b/conda/base/constants.py
@@ -24,13 +24,23 @@
 
 APP_NAME = 'conda'
 
-SEARCH_PATH = (
-    '/etc/conda/.condarc',
-    '/etc/conda/condarc',
-    '/etc/conda/condarc.d/',
-    '/var/lib/conda/.condarc',
-    '/var/lib/conda/condarc',
-    '/var/lib/conda/condarc.d/',
+if on_win:
+    SEARCH_PATH = (
+        'C:/ProgramData/conda/.condarc',
+        'C:/ProgramData/conda/condarc',
+        'C:/ProgramData/conda/condarc.d',
+    )
+else:
+    SEARCH_PATH = (
+        '/etc/conda/.condarc',
+        '/etc/conda/condarc',
+        '/etc/conda/condarc.d/',
+        '/var/lib/conda/.condarc',
+        '/var/lib/conda/condarc',
+        '/var/lib/conda/condarc.d/',
+    )
+
+SEARCH_PATH += (
     '$CONDA_ROOT/.condarc',
     '$CONDA_ROOT/condarc',
     '$CONDA_ROOT/condarc.d/',


Test patch: