kaizendorks / pymongo_inmemory

A mongo mocking library with an ephemeral MongoDB running in memory.
MIT License
40 stars 13 forks source link

pymongo_inmemory raises PermissionError: [WinError 5] Accès refusé: #41

Closed marcdexet-cnrs closed 3 years ago

marcdexet-cnrs commented 3 years ago

Describe the bug pymongo_inmemory raises PermissionError: [WinError 5] Accès refusé: 'C:\Workdirs\MAJIS\test_pymongo\.venv\lib\site-packages\pymongo_inmemory\downloader\..\.cache\bin\Install-Compass.ps1'

To Reproduce

  1. Create a new virtual env with python 3.8 on windows 10
  2. pip install pymongo-inmemory
  3. run following script
    
    import pymongo_inmemory

cli = pymongo_inmemory.MongoClient()

cli['test-db']['test-collection'].insert_one({'foo': 'bar'}).inserted_id

4. You could see the mentionned exception

**Expected behavior**

No exception

**Logs**

(.venv) PS C:\Workdirs\MyProject\test_pymongo> python .\run_pymongo.py Traceback (most recent call last): File ".\run_pymongo.py", line 3, in cli = pymongo_inmemory.MongoClient() File "C:\Workdirs\MyProject\test_pymongo.venv\lib\site-packages\pymongo_inmemory_pim.py", line 8, in init self._mongod = Mongod() File "C:\Workdirs\MyProject\test_pymongo.venv\lib\site-packages\pymongo_inmemory\mongod.py", line 65, in init download() File "C:\Workdirs\MyProject\test_pymongo.venv\lib\site-packages\pymongo_inmemory\downloader__init__.py", line 245, in download shutil.rmtree(bin_dir) File "C:\Users\my_user.pyenv\pyenv-win\versions\3.8.2\lib\shutil.py", line 737, in rmtree return _rmtree_unsafe(path, onerror) File "C:\Users\my_user.pyenv\pyenv-win\versions\3.8.2\lib\shutil.py", line 615, in _rmtree_unsafe onerror(os.unlink, fullname, sys.exc_info()) File "C:\Users\my_user.pyenv\pyenv-win\versions\3.8.2\lib\shutil.py", line 613, in _rmtree_unsafe os.unlink(fullname) PermissionError: [WinError 5] Accès refusé: 'C:\Workdirs\MyProject\test_pymongo\.venv\lib\site-packages\pymongo_inmemory\downloader\..\.cache\bin\Install-Compass.ps1'



**Screenshots**
If logs are not applicable, add screenshots.

**Context:**
 - OS: Windows
 - Version of pymongo_inmemory 0.2.1
 - Version of mongo you are downloading ?
 - Any other additional information about context
      - Use of pyenv
ekarademir commented 3 years ago

Hi @marcdexet-cnrs thank you for the bug report. I'll try to reproduce and see what is causing it.

ekarademir commented 3 years ago

I've replicated the issue. Now trying to find the root cause.

ekarademir commented 3 years ago

Found the root cause and working on a solution.

ekarademir commented 3 years ago

Relates to #10