Repository: conda/conda

Issue:
conda-4.5.12 does not work after downgrading from conda-4.6rc1
after

    conda update -c conda-canary conda

and later (because conda-4.6rc1 kept wanting to upgrade to python-3.7)

    conda install conda=4.5 python=3.6

conda-4.5.12 now refuses to work

```
(base) $ conda install -c conda-forge conda=4.6
Solving environment: failed

CondaUpgradeError: This environment has previously been operated on by a conda version that's newer
than the conda currently being used. A newer version of conda is required.
  target environment location: /home/dm/anaconda3
  current conda version: 4.5.12
  minimum conda version: 4.6


(base) $ conda update -c conda-forge conda
Solving environment: failed

CondaUpgradeError: This environment has previously been operated on by a conda version that's newer
than the conda currently being used. A newer version of conda is required.
  target environment location: /home/dm/anaconda3
  current conda version: 4.5.12
  minimum conda version: 4.6
```


Discussion:

Resolving patch:
diff --git a/conda/base/context.py b/conda/base/context.py
--- a/conda/base/context.py
+++ b/conda/base/context.py
@@ -745,8 +745,8 @@ def category_map(self):
         )),
         ('Hidden and Undocumented', (
             'allow_cycles',  # allow cyclical dependencies, or raise
-            'add_pip_as_python_dependency',
             'allow_conda_downgrades',
+            'add_pip_as_python_dependency',
             'debug',
             'default_python',
             'enable_private_envs',
diff --git a/conda/history.py b/conda/history.py
--- a/conda/history.py
+++ b/conda/history.py
@@ -23,7 +23,7 @@
 from .common.compat import ensure_text_type, iteritems, open, text_type
 from .common.path import paths_equal
 from .core.prefix_data import PrefixData
-from .exceptions import CondaHistoryError, CondaUpgradeError, NotWritableError
+from .exceptions import CondaHistoryError, NotWritableError
 from .gateways.disk.update import touch
 from .models.dist import dist_str_to_quad
 from .models.version import VersionOrder, version_relation_re
@@ -255,7 +255,15 @@ def get_user_requests(self):
                         "base_prefix": context.root_prefix,
                         "minimum_version": minimum_major_minor,
                     }
-                raise CondaUpgradeError(message)
+                message += dedent("""
+                To work around this restriction, one can also set the config parameter
+                'allow_conda_downgrades' to False at their own risk.
+                """)
+
+                # we need to rethink this.  It's fine as a warning to try to get users
+                #    to avoid breaking their system.  However, right now it is preventing
+                #    normal conda operation after downgrading conda.
+                # raise CondaUpgradeError(message)
 
         return res
 


Test patch:
diff --git a/tests/test_history.py b/tests/test_history.py
--- a/tests/test_history.py
+++ b/tests/test_history.py
@@ -185,23 +185,24 @@ def test_specs_line_parsing_43(self):
         }
 
 
-def test_minimum_conda_version_error():
-    with tempdir() as prefix:
-        assert not isfile(join(prefix, 'conda-meta', 'history'))
-        mkdir_p(join(prefix, 'conda-meta'))
-        copy2(join(dirname(__file__), 'conda-meta', 'history'),
-              join(prefix, 'conda-meta', 'history'))
-
-        with open(join(prefix, 'conda-meta', 'history'), 'a') as fh:
-            fh.write("==> 2018-07-09 11:18:09 <==\n")
-            fh.write("# cmd: blarg\n")
-            fh.write("# conda version: 42.42.4242\n")
-
-        h = History(prefix)
-
-        with pytest.raises(CondaUpgradeError) as exc:
-            h.get_user_requests()
-        exception_string = repr(exc.value)
-        print(exception_string)
-        assert "minimum conda version: 42.42" in exception_string
-        assert "$ conda install -p" in exception_string
\ No newline at end of file
+# behavior disabled as part of https://github.com/conda/conda/pull/8160
+# def test_minimum_conda_version_error():
+#     with tempdir() as prefix:
+#         assert not isfile(join(prefix, 'conda-meta', 'history'))
+#         mkdir_p(join(prefix, 'conda-meta'))
+#         copy2(join(dirname(__file__), 'conda-meta', 'history'),
+#               join(prefix, 'conda-meta', 'history'))
+
+#         with open(join(prefix, 'conda-meta', 'history'), 'a') as fh:
+#             fh.write("==> 2018-07-09 11:18:09 <==\n")
+#             fh.write("# cmd: blarg\n")
+#             fh.write("# conda version: 42.42.4242\n")
+
+#         h = History(prefix)
+
+#         with pytest.raises(CondaUpgradeError) as exc:
+#             h.get_user_requests()
+#         exception_string = repr(exc.value)
+#         print(exception_string)
+#         assert "minimum conda version: 42.42" in exception_string
+#         assert "$ conda install -p" in exception_string