# Buggy code
def get_info_dict(system=False):
    try:
        from ..install import linked_data

        root_pkgs = linked_data(context.root_prefix)
    except:  # pragma: no cover
        root_pkgs = {}

    try:
        from requests import __version__ as requests_version
        # These environment variables can influence requests' behavior, along with configuration
        # in a .netrc file
        #   REQUESTS_CA_BUNDLE
        #   HTTP_PROXY
        #   HTTPS_PROXY
    except ImportError:  # pragma: no cover
        try:
            from pip._vendor.requests import __version__ as requests_version
        except Exception as e:  # pragma: no cover
            requests_version = "Error %r" % e
    except Exception as e:  # pragma: no cover
        requests_version = "Error %r" % e

    try:
        from conda_env import __version__ as conda_env_version
    except:  # pragma: no cover
        try:
            cenv = [p for p in itervalues(root_pkgs) if p["name"] == "conda-env"]
            conda_env_version = cenv[0]["version"]
        except:
            conda_env_version = "not installed"

    try:
        import conda_build
    except ImportError:  # pragma: no cover
        conda_build_version = "not installed"
    except Exception as e:  # pragma: no cover
        conda_build_version = "Error %s" % e
    else:  # pragma: no cover
        conda_build_version = conda_build.__version__

    channels = list(all_channel_urls(context.channels))
    if not context.json:
        channels = [c + ("" if offline_keep(c) else "  (offline)") for c in channels]
    channels = [mask_anaconda_token(c) for c in channels]

    config_files = tuple(
        path for path in context.collect_all() if path not in ("envvars", "cmd_line")
    )

    netrc_file = os.environ.get("NETRC")
    if not netrc_file:
        user_netrc = expanduser("~/.netrc")
        if isfile(user_netrc):
            netrc_file = user_netrc

    active_prefix_name = env_name(context.active_prefix)

    info_dict = dict(
        platform=context.subdir,
        conda_version=conda_version,
        conda_env_version=conda_env_version,
        conda_build_version=conda_build_version,
        root_prefix=context.root_prefix,
        conda_prefix=context.conda_prefix,
        conda_private=conda_in_private_env(),
        root_writable=context.root_writable,
        pkgs_dirs=context.pkgs_dirs,
        envs_dirs=context.envs_dirs,
        default_prefix=context.default_prefix,
        active_prefix=context.active_prefix,
        active_prefix_name=active_prefix_name,
        conda_shlvl=context.shlvl,
        channels=channels,
        user_rc_path=user_rc_path,
        rc_path=user_rc_path,
        sys_rc_path=sys_rc_path,
        # is_foreign=bool(foreign),
        offline=context.offline,
        envs=[],
        python_version=".".join(map(str, sys.version_info)),
        requests_version=requests_version,
        user_agent=context.user_agent,
        conda_location=CONDA_PACKAGE_ROOT,
        config_files=config_files,
        netrc_file=netrc_file,
    )
    if on_win:
        from ..common.platform import is_admin_on_windows

        info_dict["is_windows_admin"] = is_admin_on_windows()
    else:
        info_dict["UID"] = os.geteuid()
        info_dict["GID"] = os.getegid()

    if system:
        evars = {
            "CIO_TEST",
            "CONDA_DEFAULT_ENV",
            "CONDA_ENVS_PATH",
            "DYLD_LIBRARY_PATH",
            "FTP_PROXY",
            "HTTP_PROXY",
            "HTTPS_PROXY",
            "LD_LIBRARY_PATH",
            "PATH",
            "PYTHONHOME",
            "PYTHONPATH",
            "REQUESTS_CA_BUNDLE",
            "SSL_CERT_FILE",
        }

        evars.update(v for v in os.environ if v.startswith("CONDA_"))
        evars.update(v for v in os.environ if v.startswith("conda_"))

        info_dict.update(
            {
                "sys.version": sys.version,
                "sys.prefix": sys.prefix,
                "sys.executable": sys.executable,
                "site_dirs": get_user_site(),
                "env_vars": {
                    ev: os.getenv(ev, os.getenv(ev.lower(), "<not set>"))
                    for ev in evars
                },
            }
        )

    return info_dict


# Traceback (FileNotFoundError)
Traceback (most recent call last):
File \"/home/travis/miniconda/lib/python3.6/site-packages/conda-4.4.0rc2.post15+0dc8573d-py3.6.egg/conda/core/package_cache.py\", line 265, in _make_single_record
repodata_record = read_repodata_json(extracted_package_dir)
File \"/home/travis/miniconda/lib/python3.6/site-packages/conda-4.4.0rc2.post15+0dc8573d-py3.6.egg/conda/gateways/disk/read.py\", line 123, in read_repodata_json
with open(join(extracted_package_directory, 'info', 'repodata_record.json')) as fi:
FileNotFoundError: [Errno 2] No such file or directory: '/home/travis/miniconda/pkgs/test_source_files-1-0/info/repodata_record.json'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File \"/home/travis/miniconda/lib/python3.6/site-packages/conda-4.4.0rc2.post15+0dc8573d-py3.6.egg/conda/core/package_cache.py\", line 276, in _make_single_record
index_json_record = read_index_json(extracted_package_dir)
File \"/home/travis/miniconda/lib/python3.6/site-packages/conda-4.4.0rc2.post15+0dc8573d-py3.6.egg/conda/gateways/disk/read.py\", line 111, in read_index_json
with open(join(extracted_package_directory, 'info', 'index.json')) as fi:
FileNotFoundError: [Errno 2] No such file or directory: '/home/travis/miniconda/pkgs/test_source_files-1-0/info/index.json'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File \"/home/travis/miniconda/lib/python3.6/site-packages/conda-4.4.0rc2.post15+0dc8573d-py3.6.egg/conda/exceptions.py\", line 683, in __call__
return func(*args, **kwargs)
File \"/home/travis/miniconda/lib/python3.6/site-packages/conda-4.4.0rc2.post15+0dc8573d-py3.6.egg/conda/cli/main.py\", line 78, in _main
exit_code = do_call(args, p)
File \"/home/travis/miniconda/lib/python3.6/site-packages/conda-4.4.0rc2.post15+0dc8573d-py3.6.egg/conda/cli/conda_argparse.py\", line 75, in do_call
exit_code = getattr(module, func_name)(args, parser)
File \"/home/travis/miniconda/lib/python3.6/site-packages/conda-4.4.0rc2.post15+0dc8573d-py3.6.egg/conda/cli/main_create.py\", line 11, in execute
install(args, parser, 'create')
File \"/home/travis/miniconda/lib/python3.6/site-packages/conda-4.4.0rc2.post15+0dc8573d-py3.6.egg/conda/cli/install.py\", line 241, in install
handle_txn(progressive_fetch_extract, unlink_link_transaction, prefix, args, newenv)
File \"/home/travis/miniconda/lib/python3.6/site-packages/conda-4.4.0rc2.post15+0dc8573d-py3.6.egg/conda/cli/install.py\", line 258, in handle_txn
unlink_link_transaction.display_actions(progressive_fetch_extract)
File \"/home/travis/miniconda/lib/python3.6/site-packages/conda-4.4.0rc2.post15+0dc8573d-py3.6.egg/conda/core/link.py\", line 704, in display_actions
legacy_action_groups = self.make_legacy_action_groups(pfe)
File \"/home/travis/miniconda/lib/python3.6/site-packages/conda-4.4.0rc2.post15+0dc8573d-py3.6.egg/conda/core/link.py\", line 687, in make_legacy_action_groups
pfe.prepare()
File \"/home/travis/miniconda/lib/python3.6/site-packages/conda-4.4.0rc2.post15+0dc8573d-py3.6.egg/conda/core/package_cache.py\", line 504, in prepare
for prec in self.link_precs)
File \"/home/travis/miniconda/lib/python3.6/site-packages/conda-4.4.0rc2.post15+0dc8573d-py3.6.egg/conda/core/package_cache.py\", line 504, in <genexpr>
for prec in self.link_precs)
File \"/home/travis/miniconda/lib/python3.6/site-packages/conda-4.4.0rc2.post15+0dc8573d-py3.6.egg/conda/core/package_cache.py\", line 399, in make_actions_for_record
), None)
File \"/home/travis/miniconda/lib/python3.6/site-packages/conda-4.4.0rc2.post15+0dc8573d-py3.6.egg/conda/core/package_cache.py\", line 396, in <genexpr>
pcrec for pcrec in concat(PackageCache(pkgs_dir).query(pref_or_spec)
File \"/home/travis/miniconda/lib/python3.6/site-packages/conda-4.4.0rc2.post15+0dc8573d-py3.6.egg/conda/core/package_cache.py\", line 397, in <genexpr>
for pkgs_dir in context.pkgs_dirs)
File \"/home/travis/miniconda/lib/python3.6/site-packages/conda-4.4.0rc2.post15+0dc8573d-py3.6.egg/conda/core/package_cache.py\", line 116, in query
return (pcrec for pcrec in itervalues(self._package_cache_records) if pcrec == param)
File \"/home/travis/miniconda/lib/python3.6/site-packages/conda-4.4.0rc2.post15+0dc8573d-py3.6.egg/conda/core/package_cache.py\", line 208, in _package_cache_records
return self.__package_cache_records or self.load() or self.__package_cache_records
File \"/home/travis/miniconda/lib/python3.6/site-packages/conda-4.4.0rc2.post15+0dc8573d-py3.6.egg/conda/core/package_cache.py\", line 88, in load
package_cache_record = self._make_single_record(base_name)
File \"/home/travis/miniconda/lib/python3.6/site-packages/conda-4.4.0rc2.post15+0dc8573d-py3.6.egg/conda/core/package_cache.py\", line 291, in _make_single_record
extract_tarball(package_tarball_full_path, extracted_package_dir)
File \"/home/travis/miniconda/lib/python3.6/site-packages/conda-4.4.0rc2.post15+0dc8573d-py3.6.egg/conda/gateways/disk/create.py\", line 133, in extract_tarball
assert not lexists(destination_directory), destination_directory
AssertionError: /home/travis/miniconda/pkgs/test_source_files-1-0

# Fixed code
def get_info_dict(system=False):
    try:
        from ..install import linked_data

        root_pkgs = linked_data(context.root_prefix)
    except:  # pragma: no cover
        root_pkgs = {}

    try:
        from requests import __version__ as requests_version
        # These environment variables can influence requests' behavior, along with configuration
        # in a .netrc file
        #   REQUESTS_CA_BUNDLE
        #   HTTP_PROXY
        #   HTTPS_PROXY
    except ImportError:  # pragma: no cover
        try:
            from pip._vendor.requests import __version__ as requests_version
        except Exception as e:  # pragma: no cover
            requests_version = "Error %r" % e
    except Exception as e:  # pragma: no cover
        requests_version = "Error %r" % e

    try:
        from conda_env import __version__ as conda_env_version
    except:  # pragma: no cover
        try:
            cenv = [p for p in itervalues(root_pkgs) if p["name"] == "conda-env"]
            conda_env_version = cenv[0]["version"]
        except:
            conda_env_version = "not installed"

    try:
        import conda_build
    except ImportError:  # pragma: no cover
        conda_build_version = "not installed"
    except Exception as e:  # pragma: no cover
        conda_build_version = "Error %s" % e
    else:  # pragma: no cover
        conda_build_version = conda_build.__version__

    channels = list(all_channel_urls(context.channels))
    if not context.json:
        channels = [c + ("" if offline_keep(c) else "  (offline)") for c in channels]
    channels = [mask_anaconda_token(c) for c in channels]

    config_files = tuple(
        path for path in context.collect_all() if path not in ("envvars", "cmd_line")
    )

    netrc_file = os.environ.get("NETRC")
    if not netrc_file:
        user_netrc = expanduser("~/.netrc")
        if isfile(user_netrc):
            netrc_file = user_netrc

    active_prefix_name = env_name(context.active_prefix)

    info_dict = dict(
        platform=context.subdir,
        conda_version=conda_version,
        conda_env_version=conda_env_version,
        conda_build_version=conda_build_version,
        root_prefix=context.root_prefix,
        conda_prefix=context.conda_prefix,
        conda_private=conda_in_private_env(),
        root_writable=context.root_writable,
        pkgs_dirs=context.pkgs_dirs,
        envs_dirs=context.envs_dirs,
        default_prefix=context.default_prefix,
        active_prefix=context.active_prefix,
        active_prefix_name=active_prefix_name,
        conda_shlvl=context.shlvl,
        channels=channels,
        user_rc_path=user_rc_path,
        rc_path=user_rc_path,
        sys_rc_path=sys_rc_path,
        # is_foreign=bool(foreign),
        offline=context.offline,
        envs=[],
        python_version=".".join(map(str, sys.version_info)),
        requests_version=requests_version,
        user_agent=context.user_agent,
        conda_location=CONDA_PACKAGE_ROOT,
        config_files=config_files,
        netrc_file=netrc_file,
    )
    if on_win:
        from ..common.platform import is_admin_on_windows

        info_dict["is_windows_admin"] = is_admin_on_windows()
    else:
        info_dict["UID"] = os.geteuid()
        info_dict["GID"] = os.getegid()

    evars = {
        "CIO_TEST",
        "REQUESTS_CA_BUNDLE",
        "SSL_CERT_FILE",
    }

    # add all relevant env vars, e.g. startswith('CONDA') or endswith('PATH')
    evars.update(v for v in os.environ if v.upper().startswith("CONDA"))
    evars.update(v for v in os.environ if v.upper().startswith("PYTHON"))
    evars.update(v for v in os.environ if v.upper().endswith("PROXY"))
    evars.update(v for v in os.environ if v.upper().endswith("PATH"))

    info_dict.update(
        {
            "sys.version": sys.version,
            "sys.prefix": sys.prefix,
            "sys.executable": sys.executable,
            "site_dirs": get_user_site(),
            "env_vars": {
                ev: os.getenv(ev, os.getenv(ev.lower(), "<not set>")) for ev in evars
            },
        }
    )

    return info_dict