# Buggy code
def execute(args, parser):
    from conda.base.context import context

    name = args.remote_definition or args.name

    try:
        spec = specs.detect(
            name=name, filename=expand(args.file), directory=os.getcwd()
        )
        env = spec.environment

        # FIXME conda code currently requires args to have a name or prefix
        # don't overwrite name if it's given. gh-254
        if args.prefix is None and args.name is None:
            args.name = env.name

    except exceptions.SpecNotFound:
        raise

    prefix = get_prefix(args, search=False)

    if args.force and prefix != context.root_prefix and os.path.exists(prefix):
        rm_rf(prefix)
    cli_install.check_prefix(prefix, json=args.json)

    # TODO, add capability
    # common.ensure_override_channels_requires_channel(args)
    # channel_urls = args.channel or ()

    # # special case for empty environment
    # if not env.dependencies:
    #     from conda.install import symlink_conda
    #     symlink_conda(prefix, context.root_dir)

    for installer_type, pkg_specs in env.dependencies.items():
        try:
            installer = get_installer(installer_type)
            installer.install(prefix, pkg_specs, args, env)
        except InvalidInstaller:
            sys.stderr.write(
                textwrap.dedent("""
                Unable to install package for {0}.

                Please double check and ensure you dependencies file has
                the correct spelling.  You might also try installing the
                conda-env-{0} package to see if provides the required
                installer.
                """)
                .lstrip()
                .format(installer_type)
            )
            return -1

    touch_nonadmin(prefix)
    cli_install.print_activate(args.name if args.name else prefix)


# Traceback (TypeError)
$ cat environment.yml
dependencies:
- pip:

$ conda env create -n recreate --file=environment.yml
Fetching package metadata ...........
Solving package specifications: An unexpected error has occurred.
Please consider posting the following information to the
conda GitHub issue tracker at:

https://github.com/conda/conda/issues

Current conda install:

platform : linux-64
conda version : 4.3.13
conda is private : False
conda-env version : 4.3.13
conda-build version : 2.1.5
python version : 3.5.2.final.0
requests version : 2.13.0
root environment : /opt/ts/services/miniconda.ext_public_miniconda/dist  (read only)
default environment : /opt/ts/services/miniconda.ext_public_miniconda/dist
envs directories : /nas/dft/ire/rhys/envs
/opt/ts/services/miniconda.ext_public_miniconda/dist/envs
/home/rhys/.conda/envs
package cache : /opt/ts/services/miniconda.ext_public_miniconda/dist/pkgs
/home/rhys/.conda/pkgs
channel URLs : http://python3.app.twosigma.com/conda/twosigma.com/ts/linux-64
http://python3.app.twosigma.com/conda/twosigma.com/ts/noarch
http://python3.app.twosigma.com/conda/twosigma.com/ext/linux-64
http://python3.app.twosigma.com/conda/twosigma.com/ext/noarch
http://python3.app.twosigma.com/conda/repo.continuum.io/pkgs/free/linux-64
http://python3.app.twosigma.com/conda/repo.continuum.io/pkgs/free/noarch
http://python3.app.twosigma.com/conda/repo.continuum.io/pkgs/pro/linux-64
http://python3.app.twosigma.com/conda/repo.continuum.io/pkgs/pro/noarch
config file : /home/rhys/.condarc
offline mode : False
user-agent : conda/4.3.13 requests/2.13.0 CPython/3.5.2 Linux/4.1.35-pv-ts2 debian/7.10 glibc/2.13
UID:GID : 11082:5000

`$ /opt/ts/services/miniconda.ext_public_miniconda/dist/bin/conda-env create -n recreate --file=environment.yml`

Traceback (most recent call last):
File "/opt/ts/services/miniconda.ext_public_miniconda/dist/lib/python3.5/site-packages/conda/exceptions.py", line 591, in conda_exception_handler
return_value = func(*args, **kwargs)
File "/opt/ts/services/miniconda.ext_public_miniconda/dist/lib/python3.5/site-packages/conda_env/cli/main_create.py", line 108, in execute
installer.install(prefix, pkg_specs, args, env)
File "/opt/ts/services/miniconda.ext_public_miniconda/dist/lib/python3.5/site-packages/conda_env/installers/pip.py", line 8, in install
pip_cmd = pip_args(prefix) + ['install', ] + specs
TypeError: unsupported operand type(s) for +: 'NoneType' and 'list'

# Fixed code
def execute(args, parser):
    from conda.base.context import context

    name = args.remote_definition or args.name

    try:
        spec = specs.detect(
            name=name, filename=expand(args.file), directory=os.getcwd()
        )
        env = spec.environment

        # FIXME conda code currently requires args to have a name or prefix
        # don't overwrite name if it's given. gh-254
        if args.prefix is None and args.name is None:
            args.name = env.name

    except exceptions.SpecNotFound:
        raise

    prefix = get_prefix(args, search=False)

    if args.force and prefix != context.root_prefix and os.path.exists(prefix):
        rm_rf(prefix)
    cli_install.check_prefix(prefix, json=args.json)

    # TODO, add capability
    # common.ensure_override_channels_requires_channel(args)
    # channel_urls = args.channel or ()

    # # special case for empty environment
    # if not env.dependencies:
    #     from conda.install import symlink_conda
    #     symlink_conda(prefix, context.root_dir)

    for installer_type, pkg_specs in env.dependencies.items():
        try:
            installer = get_installer(installer_type)
            installer.install(prefix, pkg_specs, args, env)
        except InvalidInstaller:
            sys.stderr.write(
                textwrap.dedent("""
                Unable to install package for {0}.

                Please double check and ensure your dependencies file has
                the correct spelling.  You might also try installing the
                conda-env-{0} package to see if provides the required
                installer.
                """)
                .lstrip()
                .format(installer_type)
            )
            return -1

    touch_nonadmin(prefix)
    cli_install.print_activate(args.name if args.name else prefix)