Repository: conda/conda

Issue:
rsync error
## Current Behavior
after installing packages, I get this error:




```
rsync: change_dir "/.empty" failed: No such file or directory (2)
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1189) [sender=3.1.3]
WARNING conda.gateways.disk.delete:rmtree(55): Removing folder /anaconda/envs/ds/.condatmp the fast way (with rsync) failed.  Do you have rsync available?
```


### Steps to Reproduce
<!-- If the current behavior is a bug, please provide specific, minimal steps to independently reproduce.
     Include the exact conda commands that reproduce the issue and their output between the ticks below. -->
```
conda install <package>
```


## Expected Behavior

## Environment Information
<details open><summary><code>`conda info`</code></summary><p>
<!-- between the ticks below, paste the output of 'conda info' -->

```
  active environment : ds
   active env location : /anaconda/envs/ds
            shell level : 2
       user config file : /home/<user>/.condarc
 populated config files : /home/<user>/.condarc
          conda version : 4.6.2
    conda-build version : not installed
         python version : 3.7.2.final.0
       base environment : /anaconda  (writable)
           channel URLs : https://repo.anaconda.com/pkgs/main/linux-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/free/linux-64
                          https://repo.anaconda.com/pkgs/free/noarch
                          https://repo.anaconda.com/pkgs/r/linux-64
                          https://repo.anaconda.com/pkgs/r/noarch
                          https://conda.anaconda.org/conda-forge/linux-64
                          https://conda.anaconda.org/conda-forge/noarch
          package cache : /anaconda/pkgs
                          /home/<user>/.conda/pkgs
       envs directories : /anaconda/envs
                          /home/<user>/.conda/envs
               platform : linux-64
             user-agent : conda/4.6.2 requests/2.21.0 CPython/3.7.2 Linux/4.15.0-1037-azure ubuntu/16.04.5 glibc/2.23
                UID:GID : 1003:1003
             netrc file : None
           offline mode : False
```
</p></details>


<details open><summary><code>`conda config --show-sources`</code></summary><p>
<!-- between the ticks below, paste the output of 'conda config --show-sources' -->

```
==> /home/bjenkellefsen/.condarc <==
channels:
  - defaults
  - conda-forge
```
</p></details>


<details><summary><code>`conda list --show-channel-urls`</code></summary><p>
<!-- between the ticks below, paste the output of 'conda list --show-channel-urls' -->

```
# packages in environment at /anaconda/envs/ds:
#
# Name                    Version                   Build  Channel
_tflow_select             2.1.0                       gpu    anaconda
absl-py                   0.5.0                    pypi_0    pypi
alabaster                 0.7.12                   py36_0    defaults
anaconda                  custom           py36hbbc8b67_0    defaults
anaconda-client           1.7.2                    py36_0    defaults
anaconda-project          0.8.2                    py36_0    defaults
appdirs                   1.4.3            py36h28b3542_0    defaults
arrow-cpp                 0.11.1          py36hc7aa0dd_1001    conda-forge
asn1crypto                0.24.0                   py36_0    defaults
astor                     0.7.1                    pypi_0    pypi
astroid                   2.1.0                    py36_0    defaults
astropy                   3.1.1            py36h7b6447c_0    defaults
atomicwrites              1.3.0                      py_0    defaults
attrs                     18.2.0           py36h28b3542_0    defaults
automat                   0.7.0                    py36_0    defaults
babel                     2.6.0                    py36_0    defaults
backcall                  0.1.0                    py36_0    defaults
backports                 1.0                      py36_1    defaults
backports.os              0.1.1                    py36_0    defaults
backports.shutil_get_terminal_size 1.0.0                    py36_2    defaults
beautifulsoup4            4.7.1                    py36_1    defaults
bitarray                  0.8.3            py36h14c3975_0    defaults
bkcharts                  0.2                      py36_0    defaults
blas                      1.0                         mkl    defaults
blaze                     0.11.3                   py36_0    defaults
bleach                    3.1.0                    pypi_0    pypi
blosc                     1.14.4               hdbcaa40_0    defaults
bokeh                     1.0.4                    py36_0    defaults
boost-cpp                 1.68.0            h11c811c_1000    conda-forge
boto                      2.49.0                   py36_0    defaults
boto3                     1.9.33                     py_0    conda-forge
botocore                  1.12.33                    py_0    conda-forge
bottleneck                1.2.1            py36h035aef0_1    defaults
bz2file                   0.98                       py_0    conda-forge
bzip2                     1.0.6                h14c3975_5    defaults
c-ares                    1.15.0               h470a237_1    conda-forge
ca-certificates           2019.1.23                     0    anaconda
cairo                     1.14.12              h8948797_3    defaults
certifi                   2018.11.29               py36_0    anaconda
cffi                      1.11.5           py36he75722e_1    defaults
chardet                   3.0.4                    py36_1    defaults
click                     7.0                      py36_0    defaults
cloudpickle               0.7.0                      py_0    defaults
clyent                    1.2.2                    py36_1    defaults
colorama                  0.4.1                    py36_0    defaults
constantly                15.1.0           py36h28b3542_0    defaults
contextlib2               0.5.5                    py36_0    defaults
cryptography              2.5              py36h1ba5d50_0    defaults
cudatoolkit               10.0.130                      0    anaconda
cudnn                     7.3.1                cuda10.0_0    anaconda
cupti                     10.0.130                      0    anaconda
curl                      7.63.0            hbc83047_1000    defaults
cycler                    0.10.0                   py36_0    defaults
cymem                     1.31.2                   py36_0    conda-forge
cython                    0.29.4           py36he6710b0_0    defaults
cytoolz                   0.9.0.1          py36h14c3975_1    defaults
dask                      1.1.1                      py_0    defaults
dask-core                 1.1.1                      py_0    defaults
datashape                 0.5.4                    py36_1    defaults
dbus                      1.13.2               h714fa37_1    defaults
decorator                 4.3.2                    py36_0    defaults
defusedxml                0.5.0                    py36_1    defaults
dill                      0.2.8.2               py36_1000    conda-forge
distributed               1.25.3                   py36_0    defaults
docutils                  0.14                     py36_0    defaults
en-core-web-sm            2.0.0                    pypi_0    pypi
entrypoints               0.3                      py36_0    defaults
et_xmlfile                1.0.1                    py36_0    defaults
expat                     2.2.6                he6710b0_0    defaults
faiss-gpu                 1.4.0           py36_cuda8.0.61_1    pytorch
fastcache                 1.0.2            py36h14c3975_2    defaults
fasttext                  0.8.22                   pypi_0    pypi
filelock                  3.0.10                   py36_0    defaults
flask                     1.0.2                    py36_1    defaults
flask-cors                3.0.7                    py36_0    defaults
fontconfig                2.13.0               h9420a91_0    defaults
freetype                  2.9.1                h8a8886c_1    defaults
fribidi                   1.0.5                h7b6447c_0    defaults
gast                      0.2.0                    pypi_0    pypi
gensim                    3.5.0                    py36_0    conda-forge
get_terminal_size         1.0.0                haa9412d_0    defaults
gevent                    1.4.0            py36h7b6447c_0    defaults
glib                      2.56.2               hd408876_0    defaults
glob2                     0.6                      py36_1    defaults
gmp                       6.1.2                h6c8ec71_1    defaults
gmpy2                     2.0.8            py36h10f8cd9_2    defaults
graphite2                 1.3.12               h23475e2_2    defaults
graphviz                  2.40.1               h21bd128_2    anaconda
greenlet                  0.4.15           py36h7b6447c_0    defaults
grpcio                    1.15.0                   pypi_0    pypi
gst-plugins-base          1.14.0               hbbd80ab_1    defaults
gstreamer                 1.14.0               hb453b48_1    defaults
h5py                      2.8.0            py36h989c5e5_3    defaults
harfbuzz                  1.8.8                hffaf4a1_0    defaults
hdf5                      1.10.2               hba1933b_1    defaults
heapdict                  1.0.0                    py36_2    defaults
html5lib                  1.0.1                    py36_0    defaults
hyperlink                 18.0.0                   py36_0    defaults
icu                       58.2                 h9c2bf20_1    defaults
idna                      2.8                      py36_0    defaults
imageio                   2.4.1                    py36_0    defaults
imagesize                 1.1.0                    py36_0    defaults
importlib_metadata        0.7                      py36_0    defaults
incremental               17.5.0                   py36_0    defaults
intel-openmp              2019.1                      144    defaults
ipykernel                 5.1.0            py36h39e3cac_0    defaults
ipython                   7.2.0            py36h39e3cac_0    defaults
ipython_genutils          0.2.0                    py36_0    defaults
ipywidgets                7.4.2                    py36_0    anaconda
isort                     4.3.4                    py36_0    defaults
itsdangerous              1.1.0                    py36_0    defaults
jbig                      2.1                  hdba287a_0    defaults
jdcal                     1.4                      py36_0    defaults
jedi                      0.13.2                   py36_0    defaults
jeepney                   0.4                      py36_0    defaults
jinja2                    2.10                     py36_0    defaults
jmespath                  0.9.3                      py_1    conda-forge
jpeg                      9b                   h024ee3a_2    defaults
jsonschema                2.6.0                    py36_0    defaults
jupyter                   1.0.0                    py36_7    anaconda
jupyter_client            5.2.4                    py36_0    defaults
jupyter_console           6.0.0                    py36_0    defaults
jupyter_core              4.4.0                    py36_0    defaults
jupyterlab                0.35.4                   py36_0    conda-forge
jupyterlab_launcher       0.13.1                   py36_0    defaults
jupyterlab_server         0.2.0                    py36_0    defaults
jupyterthemes             0.20.0                     py_0    conda-forge
keras                     2.2.4                         0    anaconda
keras-applications        1.0.6                    py36_0    anaconda
keras-base                2.2.4                    py36_0    anaconda
keras-preprocessing       1.0.5                    py36_0    anaconda
keyring                   17.1.1                   py36_0    defaults
kiwisolver                1.0.1            py36hf484d3e_0    defaults
krb5                      1.16.1               h173b8e3_7    defaults
lazy-object-proxy         1.3.1            py36h14c3975_2    defaults
lesscpy                   0.13.0                     py_1    conda-forge
libarchive                3.3.3                h5d8350f_2    defaults
libcurl                   7.63.0            h20c2e04_1000    defaults
libedit                   3.1.20170329         h6b74fdf_2    defaults
libevent                  2.1.8                h1ba5d50_0    defaults
libffi                    3.2.1                hd88cf55_4    defaults
libgcc                    7.2.0                h69d50b8_2    defaults
libgcc-ng                 8.2.0                hdf63c60_1    defaults
libgfortran-ng            7.3.0                hdf63c60_0    defaults
libgpuarray               0.7.6                h470a237_3    conda-forge
libiconv                  1.15              h14c3975_1004    conda-forge
liblief                   0.9.0                h7725739_1    defaults
libpng                    1.6.35               hbc83047_0    defaults
libprotobuf               3.5.2                hd28b015_1    conda-forge
libsodium                 1.0.16               h1bed415_0    defaults
libssh2                   1.8.0                h1ba5d50_4    defaults
libstdcxx-ng              8.2.0                hdf63c60_1    defaults
libtiff                   4.0.9                he85c1e1_2    defaults
libtool                   2.4.6                h7b6447c_5    defaults
libuuid                   1.0.3                h1bed415_2    defaults
libxcb                    1.13                 h1bed415_1    defaults
libxml2                   2.9.8                h26e45fe_1    defaults
libxslt                   1.1.32               h1312cb7_0    defaults
llvmlite                  0.27.0           py36hd408876_0    defaults
locket                    0.2.0                    py36_1    defaults
lsh                       0.3.0                    pypi_0    pypi
lxml                      4.3.0            py36hefd8a0e_0    defaults
lz4-c                     1.8.1.2              h14c3975_0    defaults
lzo                       2.10                 h49e0be7_2    defaults
mako                      1.0.7                      py_1    conda-forge
markdown                  3.0.1                    pypi_0    pypi
markupsafe                1.1.0            py36h7b6447c_0    defaults
matplotlib                3.0.2            py36h5429711_0    defaults
mccabe                    0.6.1                    py36_1    defaults
mistune                   0.8.4            py36h7b6447c_0    defaults
mkl                       2019.1                      144    defaults
mkl-service               1.1.2            py36he904b0f_5    defaults
mkl_fft                   1.0.10           py36ha843d7b_0    defaults
mkl_random                1.0.2            py36hd81dba3_0    defaults
more-itertools            5.0.0                    py36_0    defaults
mpc                       1.1.0                h10f8cd9_1    defaults
mpfr                      4.0.1                hdf1c602_3    defaults
mpmath                    1.1.0                    py36_0    defaults
msgpack-numpy             0.4.3.2                    py_0    conda-forge
msgpack-python            0.6.1            py36hfd86e86_1    defaults
multipledispatch          0.6.0                    py36_0    defaults
murmurhash                0.28.0           py36hfc679d8_0    conda-forge
nbconvert                 5.4.0                    py36_1    anaconda
nbformat                  4.4.0                    py36_0    defaults
ncurses                   6.1                  he6710b0_1    defaults
networkx                  2.2                      py36_1    defaults
ninja                     1.8.2            py36h6bb024c_1    defaults
nltk                      3.4                      py36_1    defaults
nose                      1.3.7                    py36_2    defaults
notebook                  5.7.4                    py36_0    anaconda
numba                     0.42.0           py36h962f231_0    defaults
numexpr                   2.6.9            py36h9e4a6bb_0    defaults
numpy                     1.15.4           py36h7e9f1db_0    defaults
numpy-base                1.15.4           py36hde5b4d6_0    defaults
numpydoc                  0.8.0                    py36_0    defaults
odo                       0.5.1                    py36_0    defaults
olefile                   0.46                     py36_0    defaults
openpyxl                  2.5.14                     py_0    defaults
openssl                   1.1.1                h7b6447c_0    anaconda
packaging                 19.0                     py36_0    defaults
pandas                    0.24.1           py36he6710b0_0    defaults
pandoc                    1.19.2.1             hea2e7c5_1    defaults
pandocfilters             1.4.2                    py36_1    defaults
pango                     1.42.4               h049681c_0    defaults
parquet-cpp               1.5.1                         3    conda-forge
parso                     0.3.2                    py36_0    defaults
partd                     0.3.9                    py36_0    defaults
patchelf                  0.9                  he6710b0_3    defaults
path.py                   11.5.0                   py36_0    defaults
pathlib2                  2.3.3                    py36_0    defaults
patsy                     0.5.1                    py36_0    defaults
pcre                      8.42                 h439df22_0    defaults
pep8                      1.7.1                    py36_0    defaults
pexpect                   4.6.0                    py36_0    defaults
pickleshare               0.7.5                    py36_0    defaults
pillow                    5.4.1            py36h34e0f95_0    defaults
pip                       19.0.1                   py36_0    defaults
pixman                    0.34.0               hceecf20_3    defaults
pkginfo                   1.5.0.1                  py36_0    defaults
plac                      0.9.6                      py_1    conda-forge
pluggy                    0.8.1                    py36_0    defaults
ply                       3.11                     py36_0    defaults
popt                      1.16              h1cef754_2002    conda-forge
preshed                   1.0.1            py36hfc679d8_0    conda-forge
prometheus_client         0.5.0                    py36_0    defaults
prompt_toolkit            2.0.8                      py_0    defaults
protobuf                  3.6.1                    pypi_0    pypi
psutil                    5.5.0            py36h7b6447c_0    defaults
ptyprocess                0.6.0                    py36_0    defaults
py                        1.7.0                    py36_0    defaults
py-lief                   0.9.0            py36h7725739_1    defaults
pyarrow                   0.11.1          py36hbbcf98d_1002    conda-forge
pyasn1                    0.4.4            py36h28b3542_0    defaults
pyasn1-modules            0.2.2                    py36_0    defaults
pybind11                  2.2.4            py36h2d50403_1    conda-forge
pycodestyle               2.5.0                    py36_0    defaults
pycosat                   0.6.3            py36h14c3975_0    defaults
pycparser                 2.19                     py36_0    defaults
pycrypto                  2.6.1            py36h14c3975_9    defaults
pycurl                    7.43.0.2         py36h1ba5d50_0    defaults
pydot                     1.3.0                    py36_1    anaconda
pyflakes                  2.1.0                    py36_0    defaults
pygments                  2.3.1                    py36_0    defaults
pygpu                     0.7.6            py36h7eb728f_0    conda-forge
pylint                    2.2.2                    py36_0    defaults
pyodbc                    4.0.25           py36he6710b0_0    defaults
pyopengl                  3.1.1a1                  py36_0    defaults
pyopenssl                 19.0.0                   py36_0    defaults
pyparsing                 2.3.1                    py36_0    defaults
pyqt                      5.9.2            py36h05f1152_2    defaults
pysocks                   1.6.8                    py36_0    defaults
pytables                  3.4.4            py36ha205bf6_0    defaults
pytest                    4.2.0                    py36_0    defaults
pytest-arraydiff          0.3              py36h39e3cac_0    defaults
pytest-astropy            0.5.0                    py36_0    defaults
pytest-doctestplus        0.2.0                    py36_0    defaults
pytest-openfiles          0.3.2                    py36_0    defaults
pytest-remotedata         0.3.1                    py36_0    defaults
python                    3.6.8                h0371630_0    defaults
python-dateutil           2.7.5                    py36_0    defaults
python-libarchive-c       2.8                      py36_6    defaults
pytorch                   1.0.0           py3.6_cuda9.0.176_cudnn7.4.1_1    pytorch
pytz                      2018.9                   py36_0    defaults
pywavelets                1.0.1            py36hdd07704_0    defaults
pyyaml                    3.13             py36h14c3975_0    defaults
pyzmq                     17.1.2           py36h14c3975_0    defaults
qt                        5.9.7                h5867ecd_1    defaults
qtawesome                 0.5.6                      py_0    defaults
qtconsole                 4.4.3                    py36_0    defaults
qtpy                      1.6.0                      py_0    defaults
readline                  7.0                  h7b6447c_5    defaults
regex                     2017.11.09               py36_0    conda-forge
requests                  2.21.0                   py36_0    defaults
rope                      0.11.0                   py36_0    defaults
rsync                     3.1.3             h84994c4_1002    conda-forge
ruamel_yaml               0.15.46          py36h14c3975_0    defaults
s3transfer                0.1.13                py36_1001    conda-forge
scikit-image              0.14.1           py36he6710b0_0    defaults
scikit-learn              0.20.2           py36hd81dba3_0    defaults
scipy                     1.2.0            py36h7c811a0_0    defaults
seaborn                   0.9.0                    py36_0    defaults
secretstorage             3.1.0                    py36_0    defaults
send2trash                1.5.0                    py36_0    defaults
service_identity          17.0.0           py36h28b3542_0    defaults
setuptools                39.1.0                   pypi_0    pypi
simplegeneric             0.8.1                    py36_2    defaults
singledispatch            3.4.0.3                  py36_0    defaults
sip                       4.19.8           py36hf484d3e_0    defaults
six                       1.12.0                   py36_0    defaults
smart_open                1.7.1                      py_0    conda-forge
snappy                    1.1.7                hbae5bb6_3    defaults
snowballstemmer           1.2.1                    py36_0    defaults
sortedcollections         1.1.2                    py36_0    defaults
sortedcontainers          2.1.0                    py36_0    defaults
soupsieve                 1.7.1                    py36_0    defaults
spacy                     2.0.13           py36hf8a1672_0    conda-forge
sphinx                    1.8.4                    py36_0    defaults
sphinxcontrib             1.0                      py36_1    defaults
sphinxcontrib-websupport  1.1.0                    py36_1    defaults
spyder                    3.3.2                    py36_0    defaults
spyder-kernels            0.4.2                    py36_0    defaults
sqlalchemy                1.2.17           py36h7b6447c_0    defaults
sqlite                    3.26.0               h7b6447c_0    defaults
statsmodels               0.9.0            py36h035aef0_0    defaults
sympy                     1.3                      py36_0    defaults
tblib                     1.3.2                    py36_0    defaults
tensorboard               1.9.0                    py36_0    conda-forge
tensorflow                1.9.0                    py36_0    conda-forge
tensorflow-base           1.9.0           mkl_py36h2ca6a6a_0    defaults
tensorflow-gpu            1.9.0                hf154084_0    defaults
termcolor                 1.1.0                    pypi_0    pypi
terminado                 0.8.1                    py36_1    defaults
testpath                  0.4.2                    py36_0    defaults
theano                    1.0.3                    py36_0    conda-forge
thinc                     6.10.3           py36hf8a1672_3    conda-forge
thrift-cpp                0.11.0               h02b749d_3    defaults
tk                        8.6.8                hbc83047_0    defaults
toolz                     0.9.0                    py36_0    defaults
tornado                   5.1.1            py36h7b6447c_0    defaults
tqdm                      4.29.1                     py_0    defaults
traitlets                 4.3.2                    py36_0    defaults
twisted                   18.7.0           py36h14c3975_1    defaults
typed-ast                 1.1.0            py36h14c3975_0    defaults
ujson                     1.35             py36h470a237_1    conda-forge
unicodecsv                0.14.1                   py36_0    defaults
unixodbc                  2.3.7                h14c3975_0    defaults
urllib3                   1.24.1                   py36_0    defaults
wcwidth                   0.1.7                    py36_0    defaults
webencodings              0.5.1                    py36_1    defaults
werkzeug                  0.14.1                   py36_0    defaults
wheel                     0.32.3                   py36_0    defaults
widgetsnbextension        3.4.2                    py36_0    anaconda
wrapt                     1.11.1           py36h7b6447c_0    defaults
wurlitzer                 1.0.2                    py36_0    defaults
xlrd                      1.2.0                    py36_0    defaults
xlsxwriter                1.1.2                    py36_0    defaults
xlwt                      1.3.0                    py36_0    defaults
xz                        5.2.4                h14c3975_4    defaults
yaml                      0.1.7                had09818_2    defaults
zeromq                    4.2.5                hf484d3e_1    defaults
zict                      0.1.3                    py36_0    defaults
zlib                      1.2.11               h7b6447c_3    defaults
zope                      1.0                      py36_1    defaults
zope.interface            4.5.0            py36h14c3975_0    defaults
zstd                      1.3.3                         1    conda-forge
```
</p></details>



Discussion:
Something I did made the problem go away. I will close it for now.
I've suddenly started getting this error in my container build pipeline, so if you or anyone else happen to remember why this is, that'd be rad.

```
rsync: change_dir "/.empty" failed: No such file or directory (2)
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1196) [sender=3.1.2]
WARNING conda.gateways.disk.delete:rmtree(54): Removing folder /opt/conda/.condatmp the fast way (with rsync) failed.  Do you have rsync available?
rsync: change_dir "/.empty" failed: No such file or directory (2)
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1196) [sender=3.1.2]
WARNING: 'conda clean --source-cache' is deprecated.
    Use 'conda build purge-all' to remove source cache files.
WARNING conda.gateways.disk.delete:rmtree(54): Removing folder /opt/conda/pkgs/cache the fast way (with rsync) failed.  Do you have rsync available?
```
It's not an error, it's a warning.  Conda tries to use rsync to remove files more quickly.  If that doesn't work, it's harmless - you see the output you posted, and conda does its thing a slower way.  Maybe we need to just silence that error a bit better.
I've heard that Conda's having issues with 4.6.3, so that may be why I've got a lot of warnings and errors popping up suddenly. https://github.com/jupyter/docker-stacks/issues/807#issuecomment-463715818 ?
That particular part is new in 4.6.3.

Resolving patch:
diff --git a/conda/exports.py b/conda/exports.py
--- a/conda/exports.py
+++ b/conda/exports.py
@@ -285,8 +285,12 @@ def cleanup(self, _warn=False, _warnings=_warnings):
                 _rm_rf(self.name)
             self._closed = True
             if _warn and _warnings.warn:
-                _warnings.warn("Implicitly cleaning up {!r}".format(self),
-                               _warnings.ResourceWarning)
+                try:
+                    _warnings.warn("Implicitly cleaning up {!r}".format(self),
+                                   _warnings.ResourceWarning)
+                except AttributeError:
+                    _warnings.warn("Implicitly cleaning up {!r}".format(self),
+                                   RuntimeWarning)
 
     def __exit__(self, exc, value, tb):
         self.cleanup()
diff --git a/conda/gateways/disk/delete.py b/conda/gateways/disk/delete.py
--- a/conda/gateways/disk/delete.py
+++ b/conda/gateways/disk/delete.py
@@ -7,9 +7,9 @@
 import fnmatch
 from logging import getLogger
 from os import rename, unlink, walk, makedirs, getcwd, rmdir, listdir
-from os.path import abspath, dirname, isdir, join, split, exists
+from os.path import abspath, dirname, isdir, join, split, exists, isfile, normpath, basename
 import shutil
-from subprocess import Popen, PIPE, check_call, CalledProcessError
+from subprocess import check_output, STDOUT, CalledProcessError
 import sys
 
 from . import MAX_TRIES, exp_backoff_fn
@@ -27,16 +27,25 @@
 
 def rmtree(path, *args, **kwargs):
     # subprocessing to delete large folders can be quite a bit faster
+    path = normpath(path)
     if on_win:
         try:
-            check_call('rd /s /q "{}"'.format(path), shell=True)
+            # the fastest way seems to be using DEL to recursively delete files
+            # https://www.ghacks.net/2017/07/18/how-to-delete-large-folders-in-windows-super-fast/
+            # However, this is not entirely safe, as it can end up following symlinks to folders
+            # https://superuser.com/a/306618/184799
+            # so, we stick with the slower, but hopefully safer way.  Maybe if we figured out how
+            #    to scan for any possible symlinks, we could do the faster way.
+            # out = check_output('DEL /F/Q/S *.* > NUL 2> NUL'.format(path), shell=True,
+            #                    stderr=STDOUT, cwd=path)
+            out = check_output('RD /S /Q "{}" > NUL 2> NUL'.format(path), shell=True,
+                               stderr=STDOUT)
         except CalledProcessError as e:
-            if e.returncode == 5:
-                # skip permission errors
-                log.warn("")
-                pass
-            else:
+            if e.returncode != 5:
+                log.error("Removing folder {} the fast way failed.  Output was: {}".format(out))
                 raise
+            else:
+                log.debug("removing dir contents the fast way failed.  Output was: {}".format(out))
     else:
         try:
             makedirs('.empty')
@@ -44,18 +53,17 @@ def rmtree(path, *args, **kwargs):
             pass
         # yes, this looks strange.  See
         #    https://unix.stackexchange.com/a/79656/34459
-        #    https://web.archive.org/web/20130929001850/http://linuxnote.net/jianingy/en/linux/a-fast-way-to-remove-huge-number-of-files.html
+        #    https://web.archive.org/web/20130929001850/http://linuxnote.net/jianingy/en/linux/a-fast-way-to-remove-huge-number-of-files.html  # NOQA
         rsync = which('rsync')
-        if rsync:
+        if rsync and isdir('.empty'):
             try:
-                check_call([rsync, '-a', '--delete', join(getcwd(), '.empty') + "/", path + "/"])
+                out = check_output(
+                    [rsync, '-a', '--delete', join(getcwd(), '.empty') + "/", path + "/"],
+                    stderr=STDOUT)
             except CalledProcessError:
-                log.warn("Removing folder {} the fast way (with rsync) failed.  "
-                         "Do you have rsync available?".format(path))
-                shutil.rmtree(path)
-        else:
-            shutil.rmtree(path)
-        shutil.rmtree('.empty')
+                log.debug("removing dir contents the fast way failed.  Output was: {}".format(out))
+            shutil.rmtree('.empty')
+    shutil.rmtree(path)
 
 
 def unlink_or_rename_to_trash(path):
@@ -68,25 +76,36 @@ def unlink_or_rename_to_trash(path):
         make_writable(path)
         unlink(path)
     except EnvironmentError:
-        try:
-            rename(path, path + ".trash")
-        except EnvironmentError:
-            if on_win:
-                # on windows, it is important to use the rename program, as just using python's
-                #    rename leads to permission errors when files are in use.
-                condabin_dir = join(context.conda_prefix, "condabin")
-                trash_script = join(condabin_dir, 'rename_tmp.bat')
-                if exists(trash_script):
-                    _dirname, _fn = split(path)
-                    p = Popen(['cmd.exe', '/C', trash_script, _dirname, _fn, _fn + ".trash"],
-                              stdout=PIPE, stderr=PIPE)
-                    stdout, stderr = p.communicate()
-                else:
-                    log.debug("{} is missing.  Conda was not installed correctly or has been "
-                              "corrupted.  Please file an issue on the conda github repo."
-                              .format(trash_script))
-            log.warn("Could not remove or rename {}.  Please remove this file manually (you may "
-                     "need to reboot to free file handles)".format(path))
+        if not fnmatch.fnmatch(path, '*.conda_trash*'):
+            try:
+                rename(path, path + ".conda_trash")
+            except EnvironmentError:
+                if on_win:
+                    # on windows, it is important to use the rename program, as just using python's
+                    #    rename leads to permission errors when files are in use.
+                    condabin_dir = join(context.conda_prefix, "condabin")
+                    trash_script = join(condabin_dir, 'rename_tmp.bat')
+                    if exists(trash_script):
+                        _dirname, _fn = split(path)
+                        dest_fn = path + ".conda_trash"
+                        counter = 1
+                        while isfile(dest_fn):
+                            dest_fn = dest_fn.splitext[0] + '.conda_trash_{}'.format(counter)
+                            counter += 1
+                        try:
+                            out = check_output(['cmd.exe', '/C', trash_script, _dirname, _fn,
+                                                basename(dest_fn)],
+                                               stderr=STDOUT)
+                        except CalledProcessError:
+                            log.debug("renaming file path {} to trash failed.  Output was: {}"
+                                      .format(path, out))
+
+                    else:
+                        log.debug("{} is missing.  Conda was not installed correctly or has been "
+                                  "corrupted.  Please file an issue on the conda github repo."
+                                  .format(trash_script))
+                log.warn("Could not remove or rename {}.  Please remove this file manually (you "
+                         "may need to reboot to free file handles)".format(path))
 
 
 def remove_empty_parent_paths(path):
@@ -132,10 +151,10 @@ def delete_trash(prefix):
     exclude = set(['envs'])
     for root, dirs, files in walk(prefix, topdown=True):
         dirs[:] = [d for d in dirs if d not in exclude]
-        for basename in files:
-            if (fnmatch.fnmatch(basename, "*.trash") or
-                    fnmatch.fnmatch(basename, "*" + CONDA_TEMP_EXTENSION)):
-                filename = join(root, basename)
+        for fn in files:
+            if (fnmatch.fnmatch(fn, "*.conda_trash*") or
+                    fnmatch.fnmatch(fn, "*" + CONDA_TEMP_EXTENSION)):
+                filename = join(root, fn)
                 try:
                     unlink(filename)
                     remove_empty_parent_paths(filename)
@@ -188,7 +207,7 @@ def path_is_clean(path):
     if not clean:
         for root, dirs, fns in walk(path):
             for fn in fns:
-                if not (fnmatch.fnmatch(fn, "*.trash") or
+                if not (fnmatch.fnmatch(fn, "*.conda_trash*") or
                         fnmatch.fnmatch(fn, "*" + CONDA_TEMP_EXTENSION)):
                     return False
     return True


Test patch: