eli64s / readme-ai

README file generator, powered by large language model APIs 👾
MIT License
1.34k stars 143 forks source link

Error generating readme: [WinError 5] Access is denied #94

Open ucukertz opened 3 months ago

ucukertz commented 3 months ago

OS: Windows 10 I have tried running the shell as administrator and it still gives the exact same error. Is there anything else I could try?

PS D:\dev\ti\projects\PROJECTNAME> readmeai -r . --api GEMINI -o ai.md -m gemini-pro
► INFO | 2024-03-21 10:50:40 | readmeai.config.settings | Loaded configuration file: settings/blacklist.toml
► INFO | 2024-03-21 10:50:40 | readmeai.config.settings | Loaded configuration file: settings/commands.toml
► INFO | 2024-03-21 10:50:40 | readmeai.config.settings | Loaded configuration file: settings/languages.toml
► INFO | 2024-03-21 10:50:40 | readmeai.config.settings | Loaded configuration file: settings/markdown.toml
► INFO | 2024-03-21 10:50:40 | readmeai.config.settings | Loaded configuration file: settings/parsers.toml
► INFO | 2024-03-21 10:50:40 | readmeai.config.settings | Loaded configuration file: settings/prompts.toml
► INFO | 2024-03-21 10:50:40 | readmeai.core.utils | GEMINI settings FOUND in environment!
► INFO | 2024-03-21 10:50:40 | readmeai._agent | Repository validated: repository='.' full_name='' host_domain='local' host='local' name='.'
► INFO | 2024-03-21 10:50:40 | readmeai._agent | LLM API settings: api='GEMINI' base_url='https://api.openai.com/v1/chat/completions' context_window=3999 encoder='cl100k_base' model='gemini-pro' temperature=0.9 tokens=650 top_p=0.9
Traceback (most recent call last):
  File "D:\Users\USERNAME\AppData\Local\Programs\Python\Python312\Lib\site-packages\readmeai\_agent.py", line 77, in readme_agent
    asyncio.run(readme_generator(conf, output_file))
  File "D:\Users\USERNAME\AppData\Local\Programs\Python\Python312\Lib\asyncio\runners.py", line 194, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "D:\Users\USERNAME\AppData\Local\Programs\Python\Python312\Lib\asyncio\runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Users\USERNAME\AppData\Local\Programs\Python\Python312\Lib\asyncio\base_events.py", line 684, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "D:\Users\USERNAME\AppData\Local\Programs\Python\Python312\Lib\site-packages\readmeai\_agent.py", line 86, in readme_generator
    await clone_repository(conf.config.git.repository, temp_dir)
  File "D:\Users\USERNAME\AppData\Local\Programs\Python\Python312\Lib\site-packages\readmeai\services\git.py", line 83, in clone_repository
    await remove_hidden_contents(temp_dir_path)
  File "D:\Users\USERNAME\AppData\Local\Programs\Python\Python312\Lib\site-packages\readmeai\services\git.py", line 100, in remove_hidden_contents
    shutil.rmtree(item)
  File "D:\Users\USERNAME\AppData\Local\Programs\Python\Python312\Lib\shutil.py", line 808, in rmtree
    return _rmtree_unsafe(path, onexc)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Users\USERNAME\AppData\Local\Programs\Python\Python312\Lib\shutil.py", line 631, in _rmtree_unsafe
    _rmtree_unsafe(fullname, onexc)
  File "D:\Users\USERNAME\AppData\Local\Programs\Python\Python312\Lib\shutil.py", line 631, in _rmtree_unsafe
    _rmtree_unsafe(fullname, onexc)
  File "D:\Users\USERNAME\AppData\Local\Programs\Python\Python312\Lib\shutil.py", line 636, in _rmtree_unsafe
    onexc(os.unlink, fullname, err)
  File "D:\Users\USERNAME\AppData\Local\Programs\Python\Python312\Lib\shutil.py", line 634, in _rmtree_unsafe
    os.unlink(fullname)
PermissionError: [WinError 5] Access is denied: 'D:\\Users\\USERNAME\\AppData\\Local\\Temp\\tmp760n5qjo\\.git\\objects\\pack\\pack-86f33272c58b623035530fab3cbf693de6534b94.idx'  

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "D:\Users\USERNAME\AppData\Local\Programs\Python\Python312\Scripts\readmeai.exe\__main__.py", line 7, in <module>
  File "D:\Users\USERNAME\AppData\Local\Programs\Python\Python312\Lib\site-packages\click\core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Users\USERNAME\AppData\Local\Programs\Python\Python312\Lib\site-packages\click\core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "D:\Users\USERNAME\AppData\Local\Programs\Python\Python312\Lib\site-packages\click\core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Users\USERNAME\AppData\Local\Programs\Python\Python312\Lib\site-packages\click\core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Users\USERNAME\AppData\Local\Programs\Python\Python312\Lib\site-packages\readmeai\cli\main.py", line 51, in main
    readme_agent(
  File "D:\Users\USERNAME\AppData\Local\Programs\Python\Python312\Lib\site-packages\readmeai\_agent.py", line 80, in readme_agent
    raise ReadmeGeneratorError(exc, traceback.format_exc()) from exc
readmeai._exceptions.ReadmeGeneratorError: ("Error generating readme: [WinError 5] Access is denied: 'D:\\\\Users\\\\USERNAME\\\\AppData\\\\Local\\\\Temp\\\\tmp760n5qjo\\\\.git\\\\objects\\\\pack\\\\pack-86f33272c58b623035530fab3cbf693de6534b94.idx'", 'Traceback (most recent call last):\n  File "D:\\Users\\USERNAME\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\site-packages\\readmeai\\_agent.py", line 77, in readme_agent\n    asyncio.run(readme_generator(conf, output_file))\n  File "D:\\Users\\USERNAME\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\asyncio\\runners.py", line 194, in run\n    return runner.run(main)\n           ^^^^^^^^^^^^^^^^\n  File "D:\\Users\\USERNAME\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\asyncio\\runners.py", line 118, in run\n    return self._loop.run_until_complete(task)\n           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n  File "D:\\Users\\USERNAME\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\asyncio\\base_events.py", line 684, in run_until_complete\n    return future.result()\n           ^^^^^^^^^^^^^^^\n  File "D:\\Users\\USERNAME\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\site-packages\\readmeai\\_agent.py", line 86, in readme_generator\n    await clone_repository(conf.config.git.repository, temp_dir)\n  File "D:\\Users\\USERNAME\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\site-packages\\readmeai\\services\\git.py", line 83, in clone_repository\n    await remove_hidden_contents(temp_dir_path)\n  File "D:\\Users\\USERNAME\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\site-packages\\readmeai\\services\\git.py", line 100, in remove_hidden_contents\n    shutil.rmtree(item)\n  File "D:\\Users\\USERNAME\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\shutil.py", line 808, in rmtree\n    return _rmtree_unsafe(path, onexc)\n           ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n  File "D:\\Users\\USERNAME\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\shutil.py", line 631, in _rmtree_unsafe\n    _rmtree_unsafe(fullname, onexc)\n  File "D:\\Users\\USERNAME\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\shutil.py", line 631, in _rmtree_unsafe\n    _rmtree_unsafe(fullname, onexc)\n  File "D:\\Users\\USERNAME\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\shutil.py", line 636, in _rmtree_unsafe\n    onexc(os.unlink, fullname, err)\n  File "D:\\Users\\USERNAME\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\shutil.py", line 634, in _rmtree_unsafe\n    os.unlink(fullname)\nPermissionError: [WinError 5] Access is denied: \'D:\\\\Users\\\\USERNAME\\\\AppData\\\\Local\\\\Temp\\\\tmp760n5qjo\\\\.git\\\\objects\\\\pack\\\\pack-86f33272c58b623035530fab3cbf693de6534b94.idx\'\n')
msrouchou commented 3 months ago

I am also encountering the same issue on Win11. Python 3.10.11

jSydorowicz21 commented 2 months ago

Also ran into this issue, the pr above by @Zxilly fixed this issue for me. Worth implementing.

thomasBontempsTecrisViattech commented 1 month ago

Hello, I also have this error.

I try to add the @Zxilly update but it don't change my problem. Here the error : image

I got Windows 11 and I use python 3.9.18

Is there something else to try ?

Zxilly commented 1 month ago

@thomasBontempsTecrisViattech It's obvious that you didn't apply the patch correctly. image image