# Buggy code
def from_string(cls, string, channel_override=NULL):
    string = text_type(string)

    if is_url(string) and channel_override == NULL:
        return cls.from_url(string)

    if string.endswith("@"):
        return cls(
            channel="@",
            name=string,
            version="",
            build_string="",
            build_number=0,
            dist_name=string,
        )

    REGEX_STR = (
        r"(?:([^\s\[\]]+)::)?"  # optional channel
        r"([^\s\[\]]+)"  # 3.x dist
        r"(?:\[([a-zA-Z0-9_-]+)\])?"  # with_features_depends
    )
    channel, original_dist, w_f_d = re.search(REGEX_STR, string).groups()

    if original_dist.endswith(CONDA_TARBALL_EXTENSION):
        original_dist = original_dist[: -len(CONDA_TARBALL_EXTENSION)]

    if channel_override != NULL:
        channel = channel_override
    if channel is None:
        channel = UNKNOWN_CHANNEL

    # enforce dist format
    dist_details = cls.parse_dist_name(original_dist)
    return cls(
        channel=channel,
        name=dist_details.name,
        version=dist_details.version,
        build_string=dist_details.build_string,
        build_number=dist_details.build_number,
        dist_name=original_dist,
    )


# Traceback (KeyError)
Solving environment: failed

# >>>>>>>>>>>>>>>>>>>>>> ERROR REPORT <<<<<<<<<<<<<<<<<<<<<<

Traceback (most recent call last):
File "/mnt/data/home/psommer/miniconda/lib/python3.6/site-packages/conda/exceptions.py", line 724, in __call__
return func(*args, **kwargs)
File "/mnt/data/home/psommer/miniconda/lib/python3.6/site-packages/conda/cli/main.py", line 78, in _main
exit_code = do_call(args, p)
File "/mnt/data/home/psommer/miniconda/lib/python3.6/site-packages/conda/cli/conda_argparse.py", line 76, in do_call
exit_code = getattr(module, func_name)(args, parser)
File "/mnt/data/home/psommer/miniconda/lib/python3.6/site-packages/conda/cli/main_install.py", line 11, in execute
install(args, parser, 'install')
File "/mnt/data/home/psommer/miniconda/lib/python3.6/site-packages/conda/cli/install.py", line 236, in install
force_reinstall=context.force,
File "/mnt/data/home/psommer/miniconda/lib/python3.6/site-packages/conda/core/solve.py", line 504, in solve_for_transaction
force_remove, force_reinstall)
File "/mnt/data/home/psommer/miniconda/lib/python3.6/site-packages/conda/core/solve.py", line 437, in solve_for_diff
final_precs = self.solve_final_state(deps_modifier, prune, ignore_pinned, force_remove)
File "/mnt/data/home/psommer/miniconda/lib/python3.6/site-packages/conda/core/solve.py", line 407, in solve_final_state
return IndexedSet(index[d] for d in solution)
File "/mnt/data/home/psommer/miniconda/lib/python3.6/site-packages/conda/_vendor/boltons/setutils.py", line 90, in __init__
self.update(other)
File "/mnt/data/home/psommer/miniconda/lib/python3.6/site-packages/conda/_vendor/boltons/setutils.py", line 304, in update
for o in other:
File "/mnt/data/home/psommer/miniconda/lib/python3.6/site-packages/conda/core/solve.py", line 407, in <genexpr>
return IndexedSet(index[d] for d in solution)
KeyError: Dist(channel='<unknown>', dist_name='dask-0.16.0-py36h73d177f_0', name='dask', version='0.16.0', build_string='py36h73d177f_0', build_number=0, base_url=None, platform=None)

`$ /mnt/data/home/psommer/miniconda/bin/conda install anaconda-client`

environment variables:
CIO_TEST=<not set>
CONDA_DEFAULT_ENV=root
CONDA_PATH_BACKUP=/mnt/data/home/psommer/bin:/mnt/data/home/psommer/.local/bin:/usr/loca
l/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/lo
cal/games:/snap/bin
CONDA_PREFIX=/mnt/data/home/psommer/miniconda
CONDA_PS1_BACKUP=
CONDA_ROOT=/mnt/data/home/psommer/miniconda
PATH=/mnt/data/home/psommer/miniconda/bin:/mnt/data/home/psommer/bin:/mnt/d
ata/home/psommer/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/
usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
REQUESTS_CA_BUNDLE=<not set>
SSL_CERT_FILE=<not set>

active environment : base
active env location : /mnt/data/home/psommer/miniconda
user config file : /mnt/data/home/psommer/.condarc
populated config files :
conda version : 4.4.6
conda-build version : not installed
python version : 3.6.3.final.0
base environment : /mnt/data/home/psommer/miniconda  (writable)
channel URLs : https://repo.continuum.io/pkgs/main/linux-64
https://repo.continuum.io/pkgs/main/noarch
https://repo.continuum.io/pkgs/free/linux-64
https://repo.continuum.io/pkgs/free/noarch
https://repo.continuum.io/pkgs/r/linux-64
https://repo.continuum.io/pkgs/r/noarch
https://repo.continuum.io/pkgs/pro/linux-64
https://repo.continuum.io/pkgs/pro/noarch
package cache : /mnt/data/home/psommer/miniconda/pkgs
/mnt/data/home/psommer/.conda/pkgs
envs directories : /mnt/data/home/psommer/miniconda/envs
/mnt/data/home/psommer/.conda/envs
platform : linux-64
user-agent : conda/4.4.6 requests/2.18.4 CPython/3.6.3 Linux/4.4.0-104-generic ubuntu/16.04 glibc/2.23
UID:GID : 1042:1025
netrc file : None
offline mode : False


An unexpected error has occurred. Conda has prepared the above report.

# Fixed code
def from_string(cls, string, channel_override=NULL):
    string = text_type(string)

    if is_url(string) and channel_override == NULL:
        return cls.from_url(string)

    if string.endswith("@"):
        return cls(
            channel="@",
            name=string,
            version="",
            build_string="",
            build_number=0,
            dist_name=string,
        )

    REGEX_STR = (
        r"(?:([^\s\[\]]+)::)?"  # optional channel
        r"([^\s\[\]]+)"  # 3.x dist
        r"(?:\[([a-zA-Z0-9_-]+)\])?"  # with_features_depends
    )
    channel, original_dist, w_f_d = re.search(REGEX_STR, string).groups()

    if original_dist.endswith(CONDA_TARBALL_EXTENSION):
        original_dist = original_dist[: -len(CONDA_TARBALL_EXTENSION)]

    if channel_override != NULL:
        channel = channel_override
    if not channel:
        channel = UNKNOWN_CHANNEL

    # enforce dist format
    dist_details = cls.parse_dist_name(original_dist)
    return cls(
        channel=channel,
        name=dist_details.name,
        version=dist_details.version,
        build_string=dist_details.build_string,
        build_number=dist_details.build_number,
        dist_name=original_dist,
    )