Repository: conda/conda

Issue:
TypeError: '<' not supported between instances of 'PrefixRecord' and 'PackageRecord'
<!--
Hi!  Read this; it's important.

This is an issue tracker for conda -- the package manager.  File feature requests
for conda here, as well as bug reports about something conda has messed up.

If your issue is a bug report for:
  * a specific conda package from Anaconda ('defaults' channel):
      ==> file at https://github.com/ContinuumIO/anaconda-issues
  * a specific conda package from conda-forge:
      ==> file at the corresponding feedstock under https://github.com/conda-forge
  * repo.anaconda.com access and service:
      ==> file at https://github.com/ContinuumIO/anaconda-issues
  * anaconda.org access and service:
      ==> file at https://anaconda.org/contact/report
  * commands under 'conda build':
      ==> file at https://github.com/conda/conda-build
  * commands under 'conda env':
      ==> please file it here!
  * all other conda commands that start with 'conda':
      ==> please file it here!

If you continue on,

   **please include all requested information below.**

If a maintainer determines the information is required to understand 
your issue, and if it is not provided, your issue may be
closed automatically.

-->

## Current Behavior

Run `conda update --all` or `conda update conda`, get
first exception

```
 Traceback (most recent call last):                                                                                        File "C:\Anaconda\lib\site-packages\conda\models\prefix_graph.py", line 252, in _topo_sort_handle_cycles                  value = next(t)                                                                                                       File "C:\Anaconda\lib\site-packages\conda\models\prefix_graph.py", line 230, in _toposort_raise_on_cycles                 raise CyclicalDependencyError(tuple(graph))                                                                         conda.exceptions.CyclicalDependencyError: Cyclic dependencies exist among these items: 
```

and then final exception 

```
...
      File "C:\Anaconda\lib\site-packages\conda\models\prefix_graph.py", line 259, in _topo_sort_handle_cycles
        yield cls._toposort_pop_key(graph)
      File "C:\Anaconda\lib\site-packages\conda\models\prefix_graph.py", line 274, in _toposort_pop_key
        (len(parents), node.name, node) for node, parents in iteritems(graph)
    TypeError: '<' not supported between instances of 'PrefixRecord' and 'PackageRecord'
```


### Steps to Reproduce
```
conda update --all
```


## Expected Behavior
Update suceeds

## Environment Information
<details open><summary><code>`conda info`</code></summary><p>
<!-- between the ticks below, paste the output of 'conda info' -->

```
     active environment : None
       user config file : C:\Users\kevin\.condarc
 populated config files : C:\Users\kevin\.condarc
          conda version : 4.7.5
    conda-build version : not installed
         python version : 3.7.3.final.0
       virtual packages :
       base environment : C:\Anaconda  (writable)
           channel URLs : https://repo.anaconda.com/pkgs/main/win-64
                          https://repo.anaconda.com/pkgs/main/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
          package cache : C:\Anaconda\pkgs
                          C:\Users\kevin\.conda\pkgs
                          C:\Users\kevin\AppData\Local\conda\conda\pkgs
       envs directories : C:\Anaconda\envs
                          C:\Users\kevin\.conda\envs
                          C:\Users\kevin\AppData\Local\conda\conda\envs
               platform : win-64
             user-agent : conda/4.7.5 requests/2.22.0 CPython/3.7.3 Windows/10 Windows/10.0.18362
          administrator : False
             netrc file : None
           offline mode : False
```
</p></details>


<details open><summary><code>`conda config --show-sources`</code></summary><p>
<!-- between the ticks below, paste the output of 'conda config --show-sources' -->

```
report_errors: False
anaconda_upload: True
```
</p></details>


<details><summary><code>`conda list --show-channel-urls`</code></summary><p>
<!-- between the ticks below, paste the output of 'conda list --show-channel-urls' -->

```
# packages in environment at C:\Anaconda:
#
# Name                    Version                   Build  Channel
alabaster                 0.7.12                   py37_0    defaults
apipkg                    1.5                      py37_0    defaults
arch                      4.8.1+21.g9e6d614.dirty           dev_0    <develop>
asn1crypto                0.24.0                   py37_0    defaults
astroid                   2.2.5                    py37_0    defaults
atomicwrites              1.3.0                    py37_1    defaults
attrs                     19.1.0                   py37_1    defaults
babel                     2.7.0                      py_0    defaults
backcall                  0.1.0                    py37_0    defaults
blas                      1.0                         mkl    defaults
bleach                    3.1.0                    py37_0    defaults
blosc                     1.16.3               h7bd577a_0    defaults
bzip2                     1.0.6                hfa6e2cd_5    defaults
ca-certificates           2019.5.15                     0    defaults
cached-property           1.5.1                    pypi_0    pypi
certifi                   2019.6.16                py37_0    defaults
cffi                      1.12.3           py37h7a1dbc1_0    defaults
chardet                   3.0.4                    py37_1    defaults
colorama                  0.4.1                    py37_0    defaults
conda                     4.7.5                    py37_0    defaults
conda-env                 2.6.0                         1    defaults
conda-package-handling    1.3.10                   py37_0    defaults
console_shortcut          0.1.1                         3    defaults
coverage                  4.5.3            py37he774522_0    defaults
cryptography              2.7              py37h7a1dbc1_0    defaults
cvxopt                    1.2.0            py37hdc3235a_0    defaults
cycler                    0.10.0                   py37_0    defaults
cython                    0.29.10          py37ha925a31_0    defaults
decorator                 4.4.0                    py37_1    defaults
defusedxml                0.6.0                      py_0    defaults
deprecated                1.2.5                    pypi_0    pypi
docutils                  0.14                     py37_0    defaults
entrypoints               0.3                      py37_0    defaults
et_xmlfile                1.0.1                    py37_0    defaults
execnet                   1.6.0                      py_0    defaults
flake8                    3.7.7                    py37_0    defaults
freetype                  2.9.1                ha9979f8_1    defaults
garp                      1.0                       dev_0    <develop>
glpk                      4.65                 hdc00fd2_2    defaults
gsl                       2.4                  hfa6e2cd_4    defaults
guzzle-sphinx-theme       0.7.11                   pypi_0    pypi
hdf5                      1.10.4               h7ebc959_0    defaults
hypothesis                4.23.6                   py37_0    defaults
icc_rt                    2019.0.0             h0cc432a_1    defaults
icu                       58.2                 ha66f8fd_1    defaults
idna                      2.8                      py37_0    defaults
imagesize                 1.1.0                    py37_0    defaults
importlib_metadata        0.17                     py37_1    defaults
intel-openmp              2019.4                      245    defaults
ipykernel                 5.1.1            py37h39e3cac_0    defaults
ipython                   7.5.0            py37h39e3cac_0    defaults
ipython_genutils          0.2.0                    py37_0    defaults
ipywidgets                7.4.2                    py37_0    defaults
isort                     4.3.20                   py37_0    defaults
jdcal                     1.4.1                      py_0    defaults
jedi                      0.13.3                   py37_0    defaults
jinja2                    2.10.1                   py37_0    defaults
joblib                    0.13.2                   py37_0    defaults
jpeg                      9b                   hb83a4c4_2    defaults
jsonschema                3.0.1                    py37_0    defaults
jupyter                   1.0.0                    py37_7    defaults
jupyter_client            5.2.4                    py37_0    defaults
jupyter_console           6.0.0                    py37_0    defaults
jupyter_core              4.4.0                    py37_0    defaults
kiwisolver                1.1.0            py37ha925a31_0    defaults
lazy-object-proxy         1.4.1            py37he774522_0    defaults
lets-be-rational          1.0.9                    pypi_0    pypi
libarchive                3.3.3                h0643e63_5    defaults
libiconv                  1.15                 h1df5818_7    defaults
libpng                    1.6.37               h2a8f88b_0    defaults
libsodium                 1.0.16               h9d3ae62_0    defaults
libxml2                   2.9.9                h464c3ec_0    defaults
linearmodels              4.12+12.gafae51d           dev_0    <develop>
llvmlite                  0.29.0           py37ha925a31_0    defaults
lz4-c                     1.8.1.2              h2fa13f4_0    defaults
lzo                       2.10                 h6df0209_2    defaults
m2w64-gcc-libgfortran     5.3.0                         6    defaults
m2w64-gcc-libs            5.3.0                         7    defaults
m2w64-gcc-libs-core       5.3.0                         7    defaults
m2w64-gmp                 6.1.0                         2    defaults
m2w64-libwinpthread-git   5.0.0.4634.697f757               2    defaults
markupsafe                1.1.1            py37he774522_0    defaults
matplotlib                3.1.0            py37hc8f65d3_0    defaults
mccabe                    0.6.1                    py37_1    defaults
menuinst                  1.4.16           py37he774522_0    defaults
mfe                       1.0                       dev_0    <develop>
mistune                   0.8.4            py37he774522_0    defaults
mkl                       2019.4                      245    defaults
mkl-service               2.0.2            py37he774522_0    defaults
mkl_fft                   1.0.12           py37h14836fe_0    defaults
mkl_random                1.0.2            py37h343c172_0    defaults
mock                      3.0.5                    py37_0    defaults
more-itertools            7.0.0                    py37_0    defaults
msys2-conda-epoch         20160418                      1    defaults
mypy                      0.700                    pypi_0    pypi
mypy-extensions           0.4.1                    pypi_0    pypi
nbconvert                 5.5.0                      py_0    defaults
nbformat                  4.4.0                    py37_0    defaults
nbsphinx                  0.4.2                    pypi_0    pypi
notebook                  5.7.8                    py37_0    defaults
numba                     0.44.1           py37hf9181ef_0    defaults
numexpr                   2.6.9            py37hdce8814_0    defaults
numpy                     1.17.0.dev0+7ee800c           dev_0    <develop>
numpy-base                1.16.4           py37hc3f5095_0    defaults
numpydoc                  0.8.0                    pypi_0    pypi
openpyxl                  2.6.2                      py_0    defaults
openssl                   1.1.1c               he774522_1    defaults
packaging                 19.0                     py37_0    defaults
palettable                3.1.1                    pypi_0    pypi
pandas                    0.25.0.dev0+354.gf90f4aad4           dev_0    <develop>
pandoc                    2.2.3.2                       0    defaults
pandocfilters             1.4.2                    py37_1    defaults
parso                     0.4.0                      py_0    defaults
patsy                     0.5.1                    py37_0    defaults
pickleshare               0.7.5                    py37_0    defaults
pip                       19.1.1                   py37_0    defaults
pluggy                    0.12.0                     py_0    defaults
prometheus_client         0.6.0                    py37_0    defaults
prompt_toolkit            2.0.9                    py37_0    defaults
py                        1.8.0                    py37_0    defaults
pycodestyle               2.5.0                    py37_0    defaults
pycosat                   0.6.3            py37hfa6e2cd_0    defaults
pycparser                 2.19                     py37_0    defaults
pyfin                     1.0.0a1                  pypi_0    pypi
pyflakes                  2.1.1                    py37_0    defaults
pygithub                  1.43.7                   pypi_0    pypi
pygments                  2.4.2                      py_0    defaults
pyjwt                     1.7.1                    pypi_0    pypi
pylint                    2.3.1                    py37_0    defaults
pyopenssl                 19.0.0                   py37_0    defaults
pypandoc                  1.4                      py37_1    defaults
pyparsing                 2.4.0                      py_0    defaults
pyqt                      5.9.2            py37h6538335_2    defaults
pyrsistent                0.14.11          py37he774522_0    defaults
pysocks                   1.7.0                    py37_0    defaults
pytables                  3.5.2            py37h1da0976_1    defaults
pytest                    4.6.2                    py37_0    defaults
pytest-cov                2.7.1                      py_0    defaults
pytest-forked             1.0.2                    py37_0    defaults
pytest-xdist              1.28.0                     py_0    defaults
python                    3.7.3                h8c8aaf0_1    defaults
python-dateutil           2.8.0                    py37_0    defaults
python-libarchive-c       2.8                      py37_6    defaults
pytz                      2019.1                     py_0    defaults
pywin32                   223              py37hfa6e2cd_1    defaults
pywinpty                  0.5.5                 py37_1000    defaults
pyzmq                     18.0.0           py37ha925a31_0    defaults
qt                        5.9.7            vc14h73c81de_0    defaults
qtconsole                 4.5.1                      py_0    defaults
randomgen                 1.17.0.dev0+147.gd5e398cc.dirty           dev_0    <develop>
requests                  2.22.0                   py37_0    defaults
ruamel_yaml               0.15.46          py37hfa6e2cd_0    defaults
scikit-learn              0.21.2           py37h6288b17_0    defaults
scipy                     1.2.1            py37h29ff71c_0    defaults
seaborn                   0.9.0                    py37_0    defaults
send2trash                1.5.0                    py37_0    defaults
setuptools                41.0.1                   py37_0    defaults
simplejson                3.16.0                   pypi_0    pypi
sip                       4.19.8           py37h6538335_0    defaults
six                       1.12.0                   py37_0    defaults
snappy                    1.1.7                h777316e_3    defaults
snowballstemmer           1.2.1                    py37_0    defaults
sphinx                    2.1.0                      py_0    defaults
sphinx-autodoc-typehints  1.6.0                    pypi_0    pypi
sphinxcontrib             1.0                      py37_1    defaults
sphinxcontrib-applehelp   1.0.1                      py_0    defaults
sphinxcontrib-devhelp     1.0.1                      py_0    defaults
sphinxcontrib-htmlhelp    1.0.2                      py_0    defaults
sphinxcontrib-jsmath      1.0.1                      py_0    defaults
sphinxcontrib-qthelp      1.0.2                      py_0    defaults
sphinxcontrib-serializinghtml 1.1.3                      py_0    defaults
sphinxcontrib-websupport  1.1.2                      py_0    defaults
sqlite                    3.28.0               he774522_0    defaults
statsmodels               0.10.0rc2+8.g551671aa1           dev_0    <develop>
swig                      3.0.12               h047fa9f_3    defaults
tabulate                  0.8.2                    pypi_0    pypi
terminado                 0.8.2                    py37_0    defaults
testpath                  0.4.2                    py37_0    defaults                                                                           toml                      0.10.0                   pypi_0    pypi                                                                               tornado                   6.0.2            py37he774522_0    defaults                                                                           tqdm                      4.32.1                     py_0    defaults                                                                           traitlets                 4.3.2                    py37_0    defaults                                                                           typed-ast                 1.3.1                    pypi_0    pypi                                                                               urllib3                   1.24.2                   py37_0    defaults                                                                           vboxapi                   1.0                      pypi_0    pypi                                                                               vc                        14.1                 h0510ff6_4    defaults                                                                           vollib                    0.1.5                    pypi_0    pypi                                                                               vs2015_runtime            14.15.26706          h3a45250_4    defaults                                                                           wcwidth                   0.1.7                    py37_0    defaults                                                                           webencodings              0.5.1                    py37_1    defaults     
wheel                     0.33.4                   py37_0    defaults                                                                           widgetsnbextension        3.4.2                    py37_0    defaults                                                                           win_inet_pton             1.1.0                    py37_0    defaults                                                                           wincertstore              0.2                      py37_0    defaults                                                                           winpty                    0.4.3                         4    defaults                                                                           wrapt                     1.11.1           py37he774522_0    defaults                                                                           xarray                    0.12.1                     py_0    defaults                                                                           xlrd                      1.2.0                    py37_0    defaults                                                                           xlwt                      1.3.0                    py37_0    defaults                                                                           xxhash                    1.3.0                    pypi_0    pypi                                                                               xz                        5.2.4                h2fa13f4_4    defaults                                                                           yaml                      0.1.7                hc54c509_2    defaults                                                                           zeromq                    4.3.1                h33f27b4_3    defaults                                                                           zipp                      0.5.1                      py_0    defaults                                                                           zlib                      1.2.11               h62dcd97_3    defaults                                                                           zstd                      1.3.7                h508b16e_0    defaults     
```
</p></details>



Discussion:
I am also getting the same error/stacktrace (on linux) after having upgraded conda to 4.7.5 and then running `conda update --all`

I fixed mine by removing the package that showed up as conflicting and then
updating and finally reinstalling the removed packages. I think this is
related to the recent changes in the channels.

On Fri, Jul 12, 2019, 19:36 Daniel Himmelstein <notifications@github.com>
wrote:

> I am also getting the same error/stacktrace (on linux) after having
> upgraded conda to 4.7.5 and then running conda update --all
>
> —
> You are receiving this because you authored the thread.
> Reply to this email directly, view it on GitHub
> <https://github.com/conda/conda/issues/8898?email_source=notifications&email_token=ABKTSRJTFT7DWILLNF3PFWLP7DFJVA5CNFSM4H7YVQFKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZ2RKZY#issuecomment-510989671>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/ABKTSRPOVI5B5WO4X2PBK7DP7DFJVANCNFSM4H7YVQFA>
> .
>


Resolving patch:
diff --git a/conda/resolve.py b/conda/resolve.py
--- a/conda/resolve.py
+++ b/conda/resolve.py
@@ -396,8 +396,7 @@ def find_conflicts(self, specs, specs_to_add=None, history_specs=None):
             #    should start with `spec` and end with the first encountered conflict.  A
             #    conflict is something that is either not available at all, or is present in
             #    more than one pool, but those pools do not all overlap.
-
-            g = GeneralGraph(records)
+            g = GeneralGraph((r for r in records if isinstance(r, PackageRecord)))
             spec_order = sorted(sdeps_with_dep.keys(),
                                 key=lambda x: list(g.graph_by_name.keys()).index(x.name))
             for spec in spec_order:


Test patch: