damnever / pigar

:coffee: A tool to generate requirements.txt for Python project, and more than that. (IT IS NOT A PACKAGE MANAGEMENT TOOL)

Home Page:https://damnever.github.io/pigar/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

In Windows, 'os.rename' raises FileExistsError for overwrite

laoraid opened this issue · comments

Describe the bug
Visit https://docs.python.org/3/library/os.html#os.rename
Overwriting files in Windows raises FileExistsError.(__main__.py line 326)
According to the document, I think it would be better to use replace() for cross-platform.

To Reproduce
Steps to reproduce the behavior:

  1. Setup directories and files in windows
  2. Install pigar..
  3. Run pigar..
  4. See error..

Expected behavior
Overwrite requirements.txt.

Context (Environment)

  • OS: Windows 11
  • Version of Python: 3.11.5
  • Version of pigar: 2.1.1

Thank you for the report. Could you provide a detailed traceback? We would greatly appreciate if you could submit a Pull Request to directly address this issue.

Oh.. I see, did you mean this line?

os.rename(tmp_requirement_file, requirement_file)