Repository: conda/conda

Issue:
'conda create --dry-run --yes' deletes existing environment. 
## Current Behavior
If `--dry-run` and `--yes` are _both_ passed to `conda create`, and the named environment already exists, the named environment is deleted. 


### Steps to Reproduce
```
# create the env
conda create -n tmp -y 
conda env list | grep tmp

# --dry-run without --yes leaves env in place
conda create -n tmp --dry-run
conda env list | grep tmp

# --dry-run with --yes deletes the env
conda create -n tmp --dry-run --yes
conda env list | grep tmp

```


## Expected Behavior
'conda create --dry-run' should not delete an existing environment. 

## Environment Information
<details open><summary><code>`conda info`</code></summary><p>

```
     active environment : garpy.conda-dev
    active env location : /Users/aschweit/miniconda3/envs/garpy.conda-dev
            shell level : 2
       user config file : /Users/aschweit/.condarc
 populated config files : /Users/aschweit/.condarc
          conda version : 4.8.2
    conda-build version : 3.19.2
         python version : 3.7.6.final.0
       virtual packages : __osx=10.14.6
       base environment : /Users/aschweit/miniconda3  (writable)
           channel URLs : https://repo.anaconda.com/pkgs/main/osx-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/r/osx-64
                          https://repo.anaconda.com/pkgs/r/noarch
          package cache : /Users/aschweit/miniconda3/pkgs
                          /Users/aschweit/.conda/pkgs
       envs directories : /Users/aschweit/miniconda3/envs
                          /Users/aschweit/.conda/envs
               platform : osx-64
             user-agent : conda/4.8.2 requests/2.23.0 CPython/3.7.6 Darwin/18.7.0 OSX/10.14.6
                UID:GID : 501:20
             netrc file : None
           offline mode : False

```
</p></details>


<details open><summary><code>`conda config --show-sources`</code></summary><p>

```
==> /Users/aschweit/.condarc <==
auto_update_conda: False
auto_stack: 1
```
</p></details>


<details><summary><code>`conda list --show-channel-urls`</code></summary><p>

```
# packages in environment at /Users/aschweit/miniconda3:
#
# Name                    Version                   Build  Channel
appdirs                   1.4.3                      py_1    conda-forge
arrow                     0.15.6           py37hc8dfbb8_1    conda-forge
attrs                     19.3.0                     py_0    conda-forge
beautifulsoup4            4.9.0            py37hc8dfbb8_0    conda-forge
binaryornot               0.4.4                      py_1    conda-forge
black                     19.10b0                  py37_0    conda-forge
bleach                    3.1.4                      py_0    defaults
brotlipy                  0.7.0           py37h9bfed18_1000    conda-forge
bzip2                     1.0.8                h0b31af3_2    conda-forge
ca-certificates           2020.4.5.1           hecc5488_0    conda-forge
certifi                   2020.4.5.1       py37hc8dfbb8_0    conda-forge
cffi                      1.14.0           py37h356ff06_0    conda-forge
chardet                   3.0.4           py37hc8dfbb8_1006    conda-forge
click                     7.1.2              pyh9f0ad1d_0    conda-forge
cmarkgfm                  0.4.2            py37h1de35cc_0    defaults
conda                     4.8.2                    py37_0    defaults
conda-build               3.19.2           py37hc8dfbb8_2    conda-forge
conda-package-handling    1.6.0            py37h9bfed18_2    conda-forge
cookiecutter              1.7.2              pyh9f0ad1d_0    conda-forge
cryptography              2.9.2            py37he655712_0    conda-forge
curl                      7.69.1               ha441bb4_0    defaults
decorator                 4.4.2                      py_0    defaults
docutils                  0.16                     py37_0    defaults
expat                     2.2.9                h4a8c4bd_2    conda-forge
filelock                  3.0.10                     py_0    conda-forge
future                    0.18.2                   py37_0    defaults
gettext                   0.19.8.1          h46ab8bc_1002    conda-forge
git                       2.26.2          pl526hcc376a2_0    conda-forge
glob2                     0.7                        py_0    conda-forge
icu                       67.1                 h4a8c4bd_0    conda-forge
idna                      2.9                        py_1    conda-forge
importlib-metadata        1.6.0            py37hc8dfbb8_0    conda-forge
importlib_metadata        1.6.0                         0    conda-forge
jinja2                    2.11.2             pyh9f0ad1d_0    conda-forge
jinja2-time               0.2.0                      py_2    conda-forge
krb5                      1.17.1               hddcf347_0    defaults
libarchive                3.3.3             h02796b4_1008    conda-forge
libcurl                   7.69.1               h051b688_0    defaults
libcxx                    10.0.0               h1af66ff_2    conda-forge
libedit                   3.1.20181209         hb402a30_0    defaults
libffi                    3.2.1             h4a8c4bd_1007    conda-forge
libiconv                  1.15              h0b31af3_1006    conda-forge
liblief                   0.9.0                h3e78482_1    conda-forge
libssh2                   1.9.0                ha12b0ac_1    defaults
libxml2                   2.9.10               hc06c4ae_1    conda-forge
lz4-c                     1.9.2                h4a8c4bd_1    conda-forge
lzo                       2.10              h1de35cc_1000    conda-forge
markupsafe                1.1.1            py37h9bfed18_1    conda-forge
mypy_extensions           0.4.3            py37hc8dfbb8_1    conda-forge
ncurses                   6.1               h0a44026_1002    conda-forge
networkx                  2.4                        py_0    defaults
openssl                   1.1.1g               h0b31af3_0    conda-forge
packaging                 20.1                       py_0    conda-forge
pathspec                  0.8.0              pyh9f0ad1d_0    conda-forge
pcre                      8.44                 h4a8c4bd_0    conda-forge
perl                      5.26.2            haec8ef5_1006    conda-forge
pip                       20.1               pyh9f0ad1d_0    conda-forge
pkginfo                   1.5.0.1                    py_0    conda-forge
pluggy                    0.13.1           py37hc8dfbb8_1    conda-forge
poyo                      0.5.0                      py_0    conda-forge
psutil                    5.7.0            py37h9bfed18_1    conda-forge
py                        1.8.1                      py_0    conda-forge
py-lief                   0.9.0            py37h0ceac7d_1    conda-forge
pycosat                   0.6.3           py37h9bfed18_1004    conda-forge
pycparser                 2.20                       py_0    conda-forge
pygments                  2.6.1                      py_0    defaults
pyopenssl                 19.1.0                     py_1    conda-forge
pyparsing                 2.4.7              pyh9f0ad1d_0    conda-forge
pysocks                   1.7.1            py37hc8dfbb8_1    conda-forge
python                    3.7.6                h359304d_2    defaults
python-dateutil           2.8.1                      py_0    conda-forge
python-libarchive-c       2.9                      py37_0    conda-forge
python-slugify            4.0.0              pyh9f0ad1d_1    conda-forge
python.app                2                       py37_10    defaults
python_abi                3.7                     1_cp37m    conda-forge
pytz                      2020.1             pyh9f0ad1d_0    conda-forge
pyyaml                    5.3.1            py37h9bfed18_0    conda-forge
readline                  7.0               hcfe32e1_1001    conda-forge
readme_renderer           24.0                     py37_0    defaults
regex                     2020.5.14        py37h9bfed18_0    conda-forge
requests                  2.23.0             pyh8c360ce_2    conda-forge
requests-toolbelt         0.9.1                      py_0    defaults
ripgrep                   12.1.0               h0b31af3_0    conda-forge
ruamel_yaml               0.15.80         py37h9bfed18_1001    conda-forge
setuptools                46.3.0           py37hc8dfbb8_0    conda-forge
six                       1.14.0                     py_1    conda-forge
soupsieve                 1.9.4            py37hc8dfbb8_1    conda-forge
sqlite                    3.31.1               ha441bb4_0    defaults
text-unidecode            1.3                        py_0    conda-forge
tk                        8.6.10               hbbe82c9_0    conda-forge
toml                      0.10.0                     py_0    conda-forge
tox                       3.15.0           py37hc8dfbb8_0    conda-forge
tox-conda                 0.2.1                      py_0    conda-forge
tqdm                      4.46.0             pyh9f0ad1d_0    conda-forge
tree                      1.8.0                h0b31af3_1    conda-forge
twine                     2.0.0                      py_0    defaults
typed-ast                 1.4.1            py37h0b31af3_0    conda-forge
typing_extensions         3.7.4.2                    py_0    conda-forge
unidecode                 1.1.1                      py_0    conda-forge
urllib3                   1.25.9                     py_0    conda-forge
virtualenv                16.7.5                     py_0    conda-forge
webencodings              0.5.1                    py37_1    defaults
wheel                     0.34.2                     py_1    conda-forge
whichcraft                0.6.1                      py_0    conda-forge
xz                        5.2.5                h0b31af3_0    conda-forge
yaml                      0.2.4                h0b31af3_0    conda-forge
zipp                      3.1.0                      py_0    conda-forge
zlib                      1.2.11            h0b31af3_1006    conda-forge
zstd                      1.4.4                h4b3e974_3    conda-forge

```
</p></details>



Discussion:

Resolving patch:
diff --git a/conda/cli/main_create.py b/conda/cli/main_create.py
--- a/conda/cli/main_create.py
+++ b/conda/cli/main_create.py
@@ -21,6 +21,10 @@ def execute(args, parser):
     if is_conda_environment(context.target_prefix):
         if paths_equal(context.target_prefix, context.root_prefix):
             raise CondaValueError("The target prefix is the base prefix. Aborting.")
+        if context.dry_run:
+            # Taking the "easy" way out, rather than trying to fake removing
+            # the existing environment before creating a new one.
+            raise CondaValueError("Cannot `create --dry-run` with an existing conda environment")
         confirm_yn("WARNING: A conda environment already exists at '%s'\n"
                    "Remove existing environment" % context.target_prefix,
                    default='no',


Test patch:
diff --git a/tests/test_create.py b/tests/test_create.py
--- a/tests/test_create.py
+++ b/tests/test_create.py
@@ -53,7 +53,8 @@
 from conda.core.subdir_data import create_cache_dir
 from conda.exceptions import CommandArgumentError, DryRunExit, OperationNotAllowed, \
     PackagesNotFoundError, RemoveError, conda_exception_handler, PackageNotInstalledError, \
-    DisallowedPackageError, DirectoryNotACondaEnvironmentError, EnvironmentLocationNotFound
+    DisallowedPackageError, DirectoryNotACondaEnvironmentError, EnvironmentLocationNotFound, \
+    CondaValueError
 from conda.gateways.anaconda_client import read_binstar_tokens
 from conda.gateways.disk.create import mkdir_p, extract_tarball
 from conda.gateways.disk.delete import rm_rf, path_is_clean
@@ -1760,6 +1761,12 @@ def test_create_dry_run_json(self):
         assert "python" in names
         assert "flask" in names
 
+    def test_create_dry_run_yes_safety(self):
+        with make_temp_env() as prefix:
+            with pytest.raises(CondaValueError):
+                run_command(Commands.CREATE, prefix, "--dry-run", "--yes")
+            assert exists(prefix)
+
     def test_packages_not_found(self):
         with make_temp_env() as prefix:
             with pytest.raises(PackagesNotFoundError) as exc: