Repository: conda/conda

Issue:
Why need PrefixReplaceLinkAction? It breaks Windows permissions.
**I'm submitting a...**
  - [x] bug report
  - [ ] feature request


## Current Behavior

If the conda environment is read-only to Users, installing as admin packages with files that have "prefix_placeholder" overwrite these files permissions to have no access to Users and makes these packages unusable.

### Steps to Reproduce
1. There is a base installation of Anaconda in C:\Anaconda with permissions inherited from C:\:
* Administrators read/write 
* Users read-only
2. However, C:\Anaconda\Library\Qt5Core.dll permissions are different and explicit:
* Administrators read/write 
* Administrator user read/write
* Users - no access
3. `conda uninstall qt` and `conda install qt` as administrator user do not change anything
4. Upon further investigation it turns out that in C:\Anaconda\pkgs\qt-5.9.6-vc14h62aca36_0\info\paths.json the entry for Qt5Core.dll has prefix placeholder:

```
    {
      "_path": "Library/bin/Qt5Core.dll",
      "file_mode": "binary",
      "path_type": "hardlink",
      "prefix_placeholder": "C:/qt5/_h_env",
      "sha256": "50886da211b4acaacc015e18f52fe44c2a07500f05fd09a9cb3a5c026a5eaba4",
      "size_in_bytes": 5241344
    },
```
5. The TRACE output of `conda install qt` shows that in this case PrefixReplaceLinkAction is used:

```
TRACE conda.core.path_actions:verify(385): copying C:\Anaconda\pkgs\qt-5.9.6-vc14h62aca36_0\Library\bin\Qt5Core.dll => C:\Users\labdsvm-admin\tmp6f8xpxgo\a39281e8-cb0c-4f01-9d32-e22b2209f393
TRACE conda.gateways.disk.create:_do_copy(275): copying C:\Anaconda\pkgs\qt-5.9.6-vc14h62aca36_0\Library\bin\Qt5Core.dll => C:\Users\labdsvm-admin\tmp6f8xpxgo\a39281e8-cb0c-4f01-9d32-e22b2209f393
TRACE conda.core.path_actions:verify(390): rewriting prefixes in C:\Anaconda\Library\bin\Qt5Core.dll
```

6. The temp directory is created by mkdtemp() and the [documentation](https://docs.python.org/3/library/tempfile.html#tempfile.mkdtemp) says that 

> The directory is readable, writable, and searchable only by the creating user ID. 

7. This operation first copies the file from pkgs folder to temporary folder that is only writable by current user and later it hardlinks the file from this directory into C:\Anaconda\Library\bin. 

```
TRACE conda.core.path_actions:execute(415): linking C:\Users\labdsvm-admin\tmp6f8xpxgo\a39281e8-cb0c-4f01-9d32-e22b2209f393 => C:\Anaconda\Library\bin\Qt5Core.dll
TRACE conda.gateways.disk.create:create_link(321): hard linking C:\Users\labdsvm-admin\tmp6f8xpxgo\a39281e8-cb0c-4f01-9d32-e22b2209f393 => C:\Anaconda\Library\bin\Qt5Core.dll
```

8. The hardlinks retain source file's permissions, so now, the DLL is not readable by other Users.


## Expected Behavior
I do not understand why the treatment for files with prefix_placeholder is so radically different. Why conda cannot hardlink the file from pkgs folder as other files? Why copy into temp folder with specifically minimal permissions? 

The workaround could be to not use system temp folder, but create a temp folder in conda pkgs directory so that permissions are retained.

## Environment Information
<details open><summary><code>`conda info`</code></summary><p>
<!-- between the ticks below, paste the output of 'conda info' -->

```
C:\Users\labdsvm-admin>conda info

     active environment : None
       user config file : C:\Users\labdsvm-admin\.condarc
 populated config files :
          conda version : 4.5.5
    conda-build version : 3.10.9
         python version : 3.6.4.final.0
       base environment : C:\Anaconda  (writable)
           channel URLs : https://repo.anaconda.com/pkgs/main/win-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/free/win-64
                          https://repo.anaconda.com/pkgs/free/noarch
                          https://repo.anaconda.com/pkgs/r/win-64
                          https://repo.anaconda.com/pkgs/r/noarch
                          https://repo.anaconda.com/pkgs/pro/win-64
                          https://repo.anaconda.com/pkgs/pro/noarch
                          https://repo.anaconda.com/pkgs/msys2/win-64
                          https://repo.anaconda.com/pkgs/msys2/noarch
          package cache : C:\Anaconda\pkgs
                          C:\Users\labdsvm-admin\AppData\Local\conda\conda\pkgs
       envs directories : C:\Anaconda\envs
                          C:\Users\labdsvm-admin\AppData\Local\conda\conda\envs
                          C:\Users\labdsvm-admin\.conda\envs
               platform : win-64
             user-agent : conda/4.5.5 requests/2.18.4 CPython/3.6.4 Windows/10 Windows/10.0.14393
          administrator : True
             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' -->

```
C:\Users\labdsvm-admin>conda config --show-sources

```
</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' -->

```
C:\Users\labdsvm-admin>conda list --show-channel-urls
# packages in environment at C:\Anaconda:
#
# Name                    Version                   Build  Channel
_ipyw_jlab_nb_ext_conf    0.1.0            py36he6757f0_0    defaults
_nb_ext_conf              0.4.0                    py36_1    defaults
absl-py                   0.2.0                     <pip>
adal                      0.5.1                     <pip>
alabaster                 0.7.10           py36hcd07829_0    defaults
anaconda                  custom           py36h363777c_0    defaults
anaconda-client           1.6.9                    py36_0    defaults
anaconda-project          0.8.2            py36hfad2e28_0    defaults
applicationinsights       0.11.3                    <pip>
asn1crypto                0.24.0                   py36_0    defaults
astor                     0.6.2                     <pip>
astroid                   1.6.1                    py36_0    defaults
astropy                   2.0.3            py36hfa6e2cd_0    defaults
attrs                     17.4.0                   py36_0    defaults
azure                     3.0.0                     <pip>
azure-batch               4.1.3                     <pip>
azure-common              1.1.9                     <pip>
azure-cosmosdb-nspkg      2.0.2                     <pip>
azure-cosmosdb-table      1.0.2                     <pip>
azure-datalake-store      0.0.19                    <pip>
azure-eventgrid           0.1.0                     <pip>
azure-graphrbac           0.40.0                    <pip>
azure-keyvault            0.3.7                     <pip>
azure-mgmt                2.0.0                     <pip>
azure-mgmt-advisor        1.0.1                     <pip>
azure-mgmt-applicationinsights 0.1.1                     <pip>
azure-mgmt-authorization  0.30.0                    <pip>
azure-mgmt-batch          5.0.0                     <pip>
azure-mgmt-batchai        1.0.1                     <pip>
azure-mgmt-billing        0.1.0                     <pip>
azure-mgmt-cdn            2.0.0                     <pip>
azure-mgmt-cognitiveservices 2.0.0                     <pip>
azure-mgmt-commerce       1.0.1                     <pip>
azure-mgmt-compute        3.0.1                     <pip>
azure-mgmt-consumption    2.0.0                     <pip>
azure-mgmt-containerinstance 0.3.1                     <pip>
azure-mgmt-containerregistry 1.0.1                     <pip>
azure-mgmt-containerservice 3.0.1                     <pip>
azure-mgmt-cosmosdb       0.3.1                     <pip>
azure-mgmt-datafactory    0.4.0                     <pip>
azure-mgmt-datalake-analytics 0.3.0                     <pip>
azure-mgmt-datalake-nspkg 2.0.0                     <pip>
azure-mgmt-datalake-store 0.3.0                     <pip>
azure-mgmt-devtestlabs    2.2.0                     <pip>
azure-mgmt-dns            1.2.0                     <pip>
azure-mgmt-eventgrid      0.4.0                     <pip>
azure-mgmt-eventhub       1.2.0                     <pip>
azure-mgmt-hanaonazure    0.1.0                     <pip>
azure-mgmt-iothub         0.4.0                     <pip>
azure-mgmt-iothubprovisioningservices 0.1.0                     <pip>
azure-mgmt-keyvault       0.40.0                    <pip>
azure-mgmt-loganalytics   0.1.0                     <pip>
azure-mgmt-logic          2.1.0                     <pip>
azure-mgmt-machinelearningcompute 0.4.0                     <pip>
azure-mgmt-managementpartner 0.1.0                     <pip>
azure-mgmt-marketplaceordering 0.1.0                     <pip>
azure-mgmt-media          0.2.0                     <pip>
azure-mgmt-monitor        0.4.0                     <pip>
azure-mgmt-msi            0.1.0                     <pip>
azure-mgmt-network        1.7.1                     <pip>
azure-mgmt-notificationhubs 1.0.0                     <pip>
azure-mgmt-nspkg          2.0.0                     <pip>
azure-mgmt-powerbiembedded 1.0.0                     <pip>
azure-mgmt-rdbms          0.1.0                     <pip>
azure-mgmt-recoveryservices 0.2.0                     <pip>
azure-mgmt-recoveryservicesbackup 0.1.1                     <pip>
azure-mgmt-redis          5.0.0                     <pip>
azure-mgmt-relay          0.1.0                     <pip>
azure-mgmt-reservations   0.1.0                     <pip>
azure-mgmt-resource       1.2.2                     <pip>
azure-mgmt-scheduler      1.1.3                     <pip>
azure-mgmt-search         1.0.0                     <pip>
azure-mgmt-servermanager  1.2.0                     <pip>
azure-mgmt-servicebus     0.4.0                     <pip>
azure-mgmt-servicefabric  0.1.0                     <pip>
azure-mgmt-sql            0.8.6                     <pip>
azure-mgmt-storage        1.5.0                     <pip>
azure-mgmt-subscription   0.1.0                     <pip>
azure-mgmt-trafficmanager 0.40.0                    <pip>
azure-mgmt-web            0.34.1                    <pip>
azure-nspkg               2.0.0                     <pip>
azure-servicebus          0.21.1                    <pip>
azure-servicefabric       6.1.2.9                   <pip>
azure-servicemanagement-legacy 0.20.6                    <pip>
azure-storage             0.36.0                    <pip>
azure-storage-blob        1.1.0                     <pip>
azure-storage-common      1.1.0                     <pip>
azure-storage-file        1.1.0                     <pip>
azure-storage-nspkg       3.0.0                     <pip>
azure-storage-queue       1.1.0                     <pip>
azureml                   0.2.7                     <pip>
babel                     2.5.3                    py36_0    defaults
backports                 1.0              py36h81696a8_1    defaults
backports.shutil_get_terminal_size 1.0.0            py36h79ab834_2    defaults
beautifulsoup4            4.6.0            py36hd4cc5e8_1    defaults
bitarray                  0.8.1            py36hfa6e2cd_1    defaults
bkcharts                  0.2              py36h7e685f7_0    defaults
blaze                     0.11.3           py36h8a29ca5_0    defaults
bleach                    2.1.2                    py36_0    defaults
bleach                    1.5.0                     <pip>
bokeh                     0.12.13          py36h047fa9f_0    defaults
boto                      2.48.0           py36h1a776d2_1    defaults
boto3                     1.7.4                    py36_0    defaults
botocore                  1.10.4                   py36_0    defaults
bottleneck                1.2.1            py36hd119dfa_0    defaults
bz2file                   0.98                     py36_0    defaults
bzip2                     1.0.6                    vc14_1  [vc14]  conda-forge
ca-certificates           2018.03.07                    0    defaults
cached-property           1.4.2                     <pip>
certifi                   2018.4.16                py36_0    defaults
cffi                      1.11.4           py36hfa6e2cd_0    defaults
chainer                   4.0.0                     <pip>
chainerrl                 0.3.0                     <pip>
chardet                   3.0.4            py36h420ce6e_1    defaults
click                     6.7              py36hec8c647_0    defaults
cloudpickle               0.5.2                    py36_1    defaults
clyent                    1.2.2            py36hb10d595_1    defaults
cntk-gpu                  2.5.1                     <pip>
colorama                  0.3.9            py36h029ae33_0    defaults
comtypes                  1.1.4                    py36_0    defaults
conda                     4.5.5                    py36_0    defaults
conda-build               3.10.9                   py36_0    defaults
conda-env                 2.6.0                h36134e3_1    defaults
conda-verify              2.0.0            py36h065de53_0    defaults
configparser              3.5.0                     <pip>
console_shortcut          0.1.1                h6bb2dd7_3    defaults
contextlib2               0.5.5            py36he5d52c0_0    defaults
cryptography              2.1.4            py36he1d7878_0    defaults
cuda90                    1.0                           0    pytorch
cupy                      4.0.0                     <pip>
curl                      7.59.0                   vc14_1  [vc14]  conda-forge
cycler                    0.10.0           py36h009560c_0    defaults
cython                    0.27.3           py36h22f4c84_0    defaults
cytoolz                   0.9.0            py36hfa6e2cd_0    defaults
dask                      0.16.1                   py36_0    defaults
dask-core                 0.16.1                   py36_0    defaults
databricks-cli            0.7.2                     <pip>
datashape                 0.5.4            py36h5770b85_0    defaults
decorator                 4.2.1                    py36_0    defaults
distributed               1.20.2                   py36_0    defaults
dlib                      19.9                np111py36_0    conda-forge
docutils                  0.14             py36h6012d8f_0    defaults
entrypoints               0.2.3            py36hfd66bb0_2    defaults
et_xmlfile                1.0.1            py36h3d2d736_0    defaults
fastcache                 1.0.2            py36hfa6e2cd_2    defaults
fastparquet               0.1.5                    py36_0    conda-forge
fastrlock                 0.3                       <pip>
filelock                  2.0.13           py36h20000bf_0    defaults
flask                     0.12.2           py36h98b5e8f_0    defaults
flask-cors                3.0.3            py36h8a3855d_0    defaults
freetype                  2.8.1                    vc14_0  [vc14]  conda-forge
future                    0.16.0                    <pip>
futures                   3.1.1                     <pip>
gast                      0.2.0                     <pip>
gensim                    3.4.0               py36_vc14_0  [vc14]  conda-forge
get_terminal_size         1.0.0                h38e98db_0    defaults
gevent                    1.2.2            py36h342a76c_0    defaults
glob2                     0.6              py36hdf76b57_0    defaults
graphviz                  0.8.2                     <pip>
greenlet                  0.4.12           py36ha00ad21_0    defaults
grpcio                    1.11.0                    <pip>
gym                       0.10.5                    <pip>
h5py                      2.7.1            py36he54a1c3_0    defaults
hdf5                      1.10.1                   vc14_2  [vc14]  conda-forge
heapdict                  1.0.0                    py36_2    defaults
html5lib                  1.0.1            py36h047fa9f_0    defaults
html5lib                  1.0.1                     <pip>
icc_rt                    2017.0.4             h97af966_0    defaults
icu                       58.2                     vc14_0  [vc14]  conda-forge
idna                      2.6              py36h148d497_1    defaults
imageio                   2.3.0                    py36_0    defaults
imagesize                 0.7.1            py36he29f638_0    defaults
intel-openmp              2018.0.0             hd92c6cd_8    defaults
ipykernel                 4.8.0                    py36_0    defaults
ipython                   6.2.1            py36h9cf0123_1    defaults
ipython_genutils          0.2.0            py36h3c5d0ee_0    defaults
ipywidgets                7.1.1                    py36_0    defaults
isodate                   0.6.0                     <pip>
isort                     4.2.15           py36h6198cc5_0    defaults
itsdangerous              0.24             py36hb6c5a24_1    defaults
jdcal                     1.3              py36h64a5255_0    defaults
jedi                      0.11.1                   py36_0    defaults
jinja2                    2.10             py36h292fed1_0    defaults
jmespath                  0.9.3            py36h0745840_0    defaults
jpeg                      9b                       vc14_2  [vc14]  conda-forge
jsonschema                2.6.0            py36h7636477_0    defaults
jupyter_client            5.2.2                    py36_0    defaults
jupyter_console           5.2.0            py36h6d89b47_1    defaults
jupyter_core              4.4.0            py36h56e9d50_0    defaults
jupyterlab                0.31.4                   py36_0    defaults
jupyterlab_launcher       0.10.2                   py36_0    defaults
Keras                     2.1.6                     <pip>
kiwisolver                1.0.1            py36h12c3424_0    defaults
krb5                      1.14.6                   vc14_0  [vc14]  conda-forge
lazy-object-proxy         1.3.1            py36hd1c21d2_0    defaults
libcurl                   7.58.0               h7602738_0    defaults
libiconv                  1.14                     vc14_4  [vc14]  conda-forge
libpng                    1.6.34                   vc14_0  [vc14]  conda-forge
libprotobuf               3.5.2                    vc14_0  [vc14]  conda-forge
libpython                 2.1                      py36_0    defaults
libssh2                   1.8.0                    vc14_2  [vc14]  conda-forge
libtiff                   4.0.9                    vc14_0  [vc14]  conda-forge
libxml2                   2.9.5                    vc14_1  [vc14]  conda-forge
libxslt                   1.1.32                   vc14_0  [vc14]  conda-forge
lightgbm                  2.1.0                     <pip>
llvmlite                  0.21.0           py36he0b0552_0    defaults
locket                    0.2.0            py36hfed976d_1    defaults
lxml                      4.2.1                    py36_0    conda-forge
lzo                       2.10                     vc14_0  [vc14]  conda-forge
Markdown                  2.6.11                    <pip>
markupsafe                1.0              py36h0e26971_1    defaults
mccabe                    0.6.1            py36hb41005a_1    defaults
menuinst                  1.4.11           py36hfa6e2cd_0    defaults
mistune                   0.8.3                    py36_0    defaults
mkl                       2018.0.1             h2108138_4    defaults
mkl-service               1.1.2            py36h57e144c_4    defaults
mpmath                    1.0.0            py36hacc8adf_2    defaults
msgpack-python            0.5.1            py36he980bc4_0    defaults
msrest                    0.4.28                    <pip>
msrestazure               0.4.28                    <pip>
multipledispatch          0.4.9            py36he44c36e_0    defaults
mxnet-cu90                1.1.0.post0               <pip>
nb_anacondacloud          1.4.0                    py36_0    defaults
nb_conda                  2.2.0                    py36_0    defaults
nb_conda_kernels          2.1.0                    py36_0    defaults
nbconvert                 5.3.1            py36h8dc0fde_0    defaults
nbformat                  4.4.0            py36h3a5bc1b_0    defaults
nbpresent                 3.0.2                    py36_0    defaults
networkx                  2.1                      py36_0    defaults
nltk                      3.2.5            py36h76d52bb_0    defaults
nose                      1.3.7            py36h1c3779e_2    defaults
notebook                  5.4.0                    py36_0    defaults
numba                     0.36.2          np111py36hf5cdf1b_0    defaults
numexpr                   2.6.4            py36h30784b8_0    defaults
numpy                     1.14.2                    <pip>
numpy                     1.11.3           py36h4a99626_4    defaults
numpydoc                  0.7.0            py36ha25429e_0    defaults
oauthlib                  2.0.7                     <pip>
odo                       0.5.1            py36h7560279_0    defaults
olefile                   0.45.1                   py36_0    defaults
onnx                      1.1.1                    py36_0    conda-forge
opencv-python             3.4.0.12                  <pip>
openpyxl                  2.4.10                   py36_0    defaults
openssl                   1.0.2o               h8ea7d77_0    defaults
packaging                 16.8             py36ha0986f6_1    defaults
pandas                    0.22.0           py36h6538335_0    defaults
pandoc                    1.19.2.1             hb2460c7_1    defaults
pandocfilters             1.4.2            py36h3ef6317_1    defaults
parso                     0.1.1            py36hae3edee_0    defaults
partd                     0.3.8            py36hc8e763b_0    defaults
path.py                   10.5             py36h2b94a8f_0    defaults
pathlib2                  2.3.0            py36h7bfb78b_0    defaults
patsy                     0.5.0                    py36_0    defaults
pep8                      1.7.1                    py36_0    defaults
pickleshare               0.7.4            py36h9de030f_0    defaults
Pillow                    5.1.0                     <pip>
pillow                    5.1.0            py36h0738816_0    defaults
pip                       9.0.1            py36h226ae91_4    defaults
pip                       10.0.1                    <pip>
pkginfo                   1.4.1            py36hb0f9cfa_1    defaults
pluggy                    0.6.0            py36hc7daf1e_0    defaults
ply                       3.10             py36h1211beb_0    defaults
prompt_toolkit            1.0.15           py36h60b8f86_0    defaults
protobuf                  3.5.2               py36_vc14_0  [vc14]  conda-forge
protobuf                  3.5.2.post1               <pip>
psutil                    5.4.5            py36hfa6e2cd_0    defaults
py                        1.5.2            py36hbcfbabc_0    defaults
py4j                      0.10.7                    <pip>
PyAudio                   0.2.11                    <pip>
pycodestyle               2.3.1            py36h7cc55cd_0    defaults
pycosat                   0.6.3            py36h413d8a4_0    defaults
pycparser                 2.18             py36hd053e01_1    defaults
pycrypto                  2.6.1            py36hfa6e2cd_7    defaults
pycurl                    7.43.0.1         py36h74b6da3_0    defaults
pydocumentdb              2.3.1                     <pip>
pydot                     1.2.4                     <pip>
pyflakes                  1.6.0            py36h0b975d6_0    defaults
pyglet                    1.3.2                     <pip>
pygments                  2.2.0            py36hb010967_0    defaults
PyJWT                     1.6.1                     <pip>
pylint                    1.8.2                    py36_0    defaults
pyodbc                    4.0.23           py36h6538335_0    defaults
pyopenssl                 17.5.0           py36h5b7d817_0    defaults
pyparsing                 2.2.0            py36h785a196_1    defaults
PyQt5_sip                 4.19.11                   <pip>
pysocks                   1.6.7            py36h698d350_1    defaults
pytables                  3.4.2            py36h71138e3_2    defaults
pytest                    3.3.2                    py36_0    defaults
python                    3.6.4                h6538335_1    defaults
python-dateutil           2.6.1            py36h509ddcb_1    defaults
pytorch                   0.4.0           py36_cuda90_cudnn7he774522_1  [cuda90]  pytorch
pytz                      2017.3           py36h1d3fa6b_0    defaults
pywavelets                0.5.2            py36hc649158_0    defaults
pywin32                   222              py36hfa6e2cd_0    defaults
pywinpty                  0.5              py36h6538335_1    defaults
pyyaml                    3.12             py36h1d1928f_1    defaults
pyzmq                     16.0.3           py36he714bf5_0    defaults
qt                        5.9.6            vc14h62aca36_0    defaults
qtawesome                 0.4.4            py36h5aa48f6_0    defaults
qtpy                      1.3.1            py36hb8717c5_0    defaults
requests                  2.18.4           py36h4371aae_1    defaults
requests-oauthlib         0.8.0                     <pip>
rope                      0.10.7           py36had63a69_0    defaults
ruamel_yaml               0.15.35          py36hfa6e2cd_1    defaults
s3transfer                0.1.13                   py36_0    defaults
scikit-learn              0.19.1           py36h53aea1b_0    defaults
scipy                     1.0.0            py36h1260518_0    defaults
send2trash                1.4.2                    py36_0    defaults
setuptools                38.4.0                   py36_0    defaults
simplegeneric             0.8.1                    py36_2    defaults
singledispatch            3.4.0.3          py36h17d0c80_0    defaults
sip                       4.19.8           py36h6538335_0    defaults
six                       1.11.0                    <pip>
six                       1.11.0           py36h4db2310_1    defaults
smart_open                1.5.7                    py36_0    defaults
snowballstemmer           1.2.1            py36h763602f_0    defaults
sortedcollections         0.5.3            py36hbefa0ab_0    defaults
sortedcontainers          1.5.9                    py36_0    defaults
sphinx                    1.6.6                    py36_0    defaults
sphinxcontrib             1.0              py36hbbac3d2_1    defaults
sphinxcontrib-websupport  1.0.1            py36hb5e5916_1    defaults
sqlalchemy                1.2.1            py36hfa6e2cd_0    defaults
sqlite                    3.24.0               h7602738_0    defaults
statsmodels               0.8.0            py36h6189b4c_0    defaults
sympy                     1.1.1            py36h96708e0_0    defaults
tabulate                  0.8.2                     <pip>
tblib                     1.3.2            py36h30f5020_0    defaults
tensorboard               1.7.0                     <pip>
tensorflow-gpu            1.7.0                     <pip>
termcolor                 1.1.0                     <pip>
terminado                 0.8.1                    py36_1    defaults
testpath                  0.3.1            py36h2698cfe_0    defaults
thrift                    0.11.0                   py36_0    conda-forge
tk                        8.6.7                    vc14_0  [vc14]  conda-forge
toolz                     0.9.0                    py36_0    defaults
torchvision               0.2.1                     <pip>
tornado                   4.5.3                    py36_0    defaults
traitlets                 4.3.2            py36h096827d_0    defaults
typing                    3.6.2            py36hb035bda_0    defaults
unicodecsv                0.14.1           py36h6450c06_0    defaults
urllib3                   1.22             py36h276f60a_0    defaults
vc                        14                   h0510ff6_3    defaults
vs2015_runtime            14.0.25123                    3    defaults
wcwidth                   0.1.7            py36h3d5aa90_0    defaults
webencodings              0.5.1                     <pip>
webencodings              0.5.1            py36h67c50ae_1    defaults
werkzeug                  0.14.1                   py36_0    defaults
wheel                     0.30.0           py36h6c3ec14_1    defaults
widgetsnbextension        3.1.0                    py36_0    defaults
win_inet_pton             1.0.1            py36he67d7fd_1    defaults
win_unicode_console       0.5              py36hcdbd4b5_0    defaults
wincertstore              0.2              py36h7fe50ca_0    defaults
winpty                    0.4.3                    vc14_2  [vc14]  conda-forge
wrapt                     1.10.11          py36he5f5981_0    defaults
xgboost                   0.71                      <pip>
xlrd                      1.1.0            py36h1cb58dc_1    defaults
xlsxwriter                1.0.2            py36hf723b7d_0    defaults
xlwings                   0.11.5                   py36_0    defaults
xlwt                      1.3.0            py36h1a4751e_0    defaults
yaml                      0.1.7                    vc14_0  [vc14]  conda-forge
zict                      0.1.3            py36h2d8e73e_0    defaults
zlib                      1.2.11                   vc14_0  [vc14]  conda-forge
```
</p></details>



Discussion:
You filed this in the wrong place. Please re-file at https://github.com/ContinuumIO/anaconda-issues

I disagree, the question is about PrefixReplaceLinkAction, which is unrelated to any specific package. The qt is not the only package that becomes inaccessible due to permissions error.
AFAICT, your issue here is that the permission on the QtCore DLL are incorrect. If they were ok then you would have no issue here. Another possible issue is that this file doesn't need any prefix replacement at all.

Is my understanding incorrect?
I would tell there are several points:
1. Why do we need prefix replacement at all? I'm afraid I have not find any explanation on that - could you, please, point me into the right direction?
2. If the prefix replacement is indeed important, at least in this case, then, can you justify using a temporary directory with limited access rights to process these files? It creates permission issues and, really, the problem would be solved if the temporary directory in created in target conda environment, similar to what conda-build does.
3. If both points above are justified - then that would be an issue for Anaconda.

Thank you,
Oleh Khoma
> 1. Why do we need prefix replacement at all? I'm afraid I have not find any explanation on that - could you, please, point me into the right direction?

During the build process of certain bits of software (Unix-first stuff mostly, often stuff built using Autotools, but CMake-built software is not exempt from this either) record paths they are told about. These paths are used in the C or C++ code to load auxiliary files (or whatever), but of course they won't exist on the end user's machine so we must re-write them. It's not good to do this though and I sometimes try to make the software dynamic in this regard instead.

> 2. If the prefix replacement is indeed important, at least in this case, then, can you justify using a temporary directory with limited access rights to process these files? It creates permission issues and, really, the problem would be solved if the temporary directory in created in target conda environment, similar to what conda-build does.

@kalefranz, can you answer this, seems like a fair point but I would guess it's more complicated than that?

From my perspective, I can make this problem go away for Qt (and probably will do), by fixing the perms on Qt and making sure it doesn't suffer binary prefix replacement if not necessary, but that's on the anaconda-issues side of things.

Re-opening for further discussion, cheers.

Resolving patch:
diff --git a/conda/core/link.py b/conda/core/link.py
--- a/conda/core/link.py
+++ b/conda/core/link.py
@@ -7,7 +7,6 @@
 from os.path import basename, dirname, isdir, join
 from subprocess import CalledProcessError
 import sys
-from tempfile import mkdtemp
 from traceback import format_exception_only
 import warnings
 
@@ -279,7 +278,8 @@ def _prepare(cls, transaction_context, target_prefix, unlink_precs, link_precs,
         sp = get_python_site_packages_short_path(python_version)
         transaction_context['target_site_packages_short_path'] = sp
 
-        transaction_context['temp_dir'] = mkdtemp()
+        transaction_context['temp_dir'] = join(target_prefix, '.condatmp')
+        mkdir_p(transaction_context['temp_dir'])
 
         unlink_action_groups = tuple(ActionGroup(
             'unlink',


Test patch: