{"action":"created","issue":{"url":"https://api.github.com/repos/conda/conda-env/issues/124","labels_url":"https://api.github.com/repos/conda/conda-env/issues/124/labels{/name}","comments_url":"https://api.github.com/repos/conda/conda-env/issues/124/comments","events_url":"https://api.github.com/repos/conda/conda-env/issues/124/events","html_url":"https://github.com/conda/conda-env/issues/124","id":94954341,"number":124,"title":"`conda.install.rm_rf` can't delete old environments in Windows + Python 2.7","user":{"login":"campos-ddc","id":893630,"avatar_url":"https://avatars.githubusercontent.com/u/893630?v=3","gravatar_id":"","url":"https://api.github.com/users/campos-ddc","html_url":"https://github.com/campos-ddc","followers_url":"https://api.github.com/users/campos-ddc/followers","following_url":"https://api.github.com/users/campos-ddc/following{/other_user}","gists_url":"https://api.github.com/users/campos-ddc/gists{/gist_id}","starred_url":"https://api.github.com/users/campos-ddc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/campos-ddc/subscriptions","organizations_url":"https://api.github.com/users/campos-ddc/orgs","repos_url":"https://api.github.com/users/campos-ddc/repos","events_url":"https://api.github.com/users/campos-ddc/events{/privacy}","received_events_url":"https://api.github.com/users/campos-ddc/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-07-14T14:15:57Z","updated_at":"2015-07-14T18:13:52Z","closed_at":null,"body":"This issue hit me when trying to use `--force` option in `conda env create` (I added this in #102), and it revealed a possible problem with how conda handles links in Windows + Python 2.7.\r\n\r\n# Symptom\r\n\r\nTrying to delete an environment (not active) from within Python fails because the original file being linked is locked by Windows.\r\n\r\n# Context\r\n\r\n* Windows\r\n* Python 2.7 (`os.islink` does not work here, which might affect the `rm_rf` function from `conda.install`)\r\n\r\n# Reproducing\r\n\r\nThis command line is enough to reproduce the problem:\r\n\r\n```bat\r\n$ conda create -n test pyyaml && python -c \"import yaml;from conda.install import rm_rf;rm_rf('C:\\\\Miniconda\\\\envs\\\\test')\"\r\nFetching package metadata: ......\r\n\r\n#\r\n# To activate this environment, use:\r\n# > activate test\r\n#\r\n\r\nTraceback (most recent call last):\r\n  File \"<string>\", line 1, in <module>\r\n  File \"C:\\Miniconda\\lib\\site-packages\\conda\\install.py\", line 204, in rm_rf\r\n    shutil.rmtree(path)\r\n  File \"C:\\Miniconda\\lib\\shutil.py\", line 247, in rmtree\r\n    rmtree(fullname, ignore_errors, onerror)\r\n  File \"C:\\Miniconda\\lib\\shutil.py\", line 247, in rmtree\r\n    rmtree(fullname, ignore_errors, onerror)\r\n  File \"C:\\Miniconda\\lib\\shutil.py\", line 252, in rmtree\r\n    onerror(os.remove, fullname, sys.exc_info())\r\n  File \"C:\\Miniconda\\lib\\shutil.py\", line 250, in rmtree\r\n    os.remove(fullname)\r\nWindowsError: [Error 5] Acesso negado: 'C:\\\\Miniconda\\\\envs\\\\test\\\\Lib\\\\site-packages\\\\yaml.dll'\r\n```\r\n\r\nNote that when I import `pyyaml`, I'm locking file `C:\\\\Miniconda\\\\Lib\\\\site-packages\\\\yaml.dll` (root environment), but that also prevents me from deleting `C:\\\\Miniconda\\\\envs\\\\test\\\\Lib\\\\site-packages\\\\yaml.dll` (another hard link).\r\n\r\n# Solution?\r\n\r\nMaybe we should add some improved support for detecting and unlinking hardlinks in Windows with Python 2.7, and handle those cases individually instead of trying to `shutil.rmtree` everything.\r\n\r\nPossibly from [jarako.windows](https://bitbucket.org/jaraco/jaraco.windows/src/default/jaraco/windows/filesystem/__init__.py#cl-76) or [ntfs/fs.py](https://github.com/sid0/ntfs/blob/master/ntfsutils/fs.py#L88)"},"comment":{"url":"https://api.github.com/repos/conda/conda-env/issues/comments/121327700","html_url":"https://github.com/conda/conda-env/issues/124#issuecomment-121327700","issue_url":"https://api.github.com/repos/conda/conda-env/issues/124","id":121327700,"user":{"login":"campos-ddc","id":893630,"avatar_url":"https://avatars.githubusercontent.com/u/893630?v=3","gravatar_id":"","url":"https://api.github.com/users/campos-ddc","html_url":"https://github.com/campos-ddc","followers_url":"https://api.github.com/users/campos-ddc/followers","following_url":"https://api.github.com/users/campos-ddc/following{/other_user}","gists_url":"https://api.github.com/users/campos-ddc/gists{/gist_id}","starred_url":"https://api.github.com/users/campos-ddc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/campos-ddc/subscriptions","organizations_url":"https://api.github.com/users/campos-ddc/orgs","repos_url":"https://api.github.com/users/campos-ddc/repos","events_url":"https://api.github.com/users/campos-ddc/events{/privacy}","received_events_url":"https://api.github.com/users/campos-ddc/received_events","type":"User","site_admin":false},"created_at":"2015-07-14T18:13:52Z","updated_at":"2015-07-14T18:13:52Z","body":"Should I move it there?"}}