# Buggy code
def execute(args, parser):
    name = args.remote_definition or args.name

    try:
        spec = install_specs.detect(
            name=name, filename=expand(args.file), directory=os.getcwd()
        )
        env = spec.environment
    except exceptions.SpecNotFound:
        raise

    if not (args.name or args.prefix):
        if not env.name:
            # Note, this is a hack fofr get_prefix that assumes argparse results
            # TODO Refactor common.get_prefix
            name = os.environ.get("CONDA_DEFAULT_ENV", False)
            if not name:
                msg = "Unable to determine environment\n\n"
                msg += textwrap.dedent("""
                    Please re-run this command with one of the following options:

                    * Provide an environment name via --name or -n
                    * Re-run this command inside an activated conda environment.""").lstrip()
                # TODO Add json support
                raise CondaEnvException(msg)

        # Note: stubbing out the args object as all of the
        # conda.cli.common code thinks that name will always
        # be specified.
        args.name = env.name

    prefix = get_prefix(args, search=False)
    # CAN'T Check with this function since it assumes we will create prefix.
    # cli_install.check_prefix(prefix, json=args.json)

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

    for installer_type, specs in env.dependencies.items():
        try:
            installer = get_installer(installer_type)
            installer.install(prefix, specs, args, env, prune=args.prune)
        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)
{
"command":"/home/travis/miniconda/bin/conda-env update",
"conda_info":{
"GID":2000,
"UID":2000,
"_channels":"https://conda.anaconda.org/conda-canary/linux-64
https://conda.anaconda.org/conda-canary/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",
"_config_files":"/home/travis/.condarc",
"_envs_dirs":"/home/travis/miniconda/envs
/home/travis/.conda/envs",
"_pkgs_dirs":"/home/travis/miniconda/pkgs
/home/travis/.conda/pkgs",
"_rtwro":"writable",
"active_prefix":null,
"active_prefix_name":null,
"channels":[
"https://conda.anaconda.org/conda-canary/linux-64",
"https://conda.anaconda.org/conda-canary/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"
],
"conda_build_version":"not installed",
"conda_env_version":"4.4.0rc0",
"conda_location":"/home/travis/miniconda/lib/python3.6/site-packages/conda",
"conda_prefix":"/home/travis/miniconda",
"conda_private":false,
"conda_shlvl":-1,
"conda_version":"4.4.0rc0",
"config_files":[
"/home/travis/.condarc"
],
"default_prefix":"/home/travis/miniconda",
"envs":[

],
"envs_dirs":[
"/home/travis/miniconda/envs",
"/home/travis/.conda/envs"
],
"netrc_file":null,
"offline":false,
"pkgs_dirs":[
"/home/travis/miniconda/pkgs",
"/home/travis/.conda/pkgs"
],
"platform":"linux-64",
"python_version":"3.6.1.final.0",
"rc_path":"/home/travis/.condarc",
"requests_version":"2.14.2",
"root_prefix":"/home/travis/miniconda",
"root_writable":true,
"sys_rc_path":"/home/travis/miniconda/.condarc",
"user_agent":"conda/4.4.0rc0 requests/2.14.2 CPython/3.6.1 Linux/4.4.0-83-generic ubuntu/14.04 glibc/2.19",
"user_rc_path":"/home/travis/.condarc"
},
"error":"TypeError(\"_pip_install_via_requirements() got an unexpected keyword argument 'prune'\",)",
"exception_name":"TypeError",
"exception_type":"<class 'TypeError'>",
"traceback":"Traceback (most recent call last):
File \"/home/travis/miniconda/lib/python3.6/site-packages/conda/exceptions.py\", line 653, in __call__
return func(*args, **kwargs)
File \"/home/travis/miniconda/lib/python3.6/site-packages/conda_env/cli/main_update.py\", line 107, in execute
installer.install(prefix, specs, args, env, prune=args.prune)
TypeError: _pip_install_via_requirements() got an unexpected keyword argument 'prune'
"
}

# Fixed code
def execute(args, parser):
    name = args.remote_definition or args.name

    try:
        spec = install_specs.detect(
            name=name, filename=expand(args.file), directory=os.getcwd()
        )
        env = spec.environment
    except exceptions.SpecNotFound:
        raise

    if not (args.name or args.prefix):
        if not env.name:
            # Note, this is a hack fofr get_prefix that assumes argparse results
            # TODO Refactor common.get_prefix
            name = os.environ.get("CONDA_DEFAULT_ENV", False)
            if not name:
                msg = "Unable to determine environment\n\n"
                msg += textwrap.dedent("""
                    Please re-run this command with one of the following options:

                    * Provide an environment name via --name or -n
                    * Re-run this command inside an activated conda environment.""").lstrip()
                # TODO Add json support
                raise CondaEnvException(msg)

        # Note: stubbing out the args object as all of the
        # conda.cli.common code thinks that name will always
        # be specified.
        args.name = env.name

    prefix = get_prefix(args, search=False)
    # CAN'T Check with this function since it assumes we will create prefix.
    # cli_install.check_prefix(prefix, json=args.json)

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

    for installer_type, specs in env.dependencies.items():
        try:
            installer = get_installer(installer_type)
            installer.install(prefix, 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)