`logfire clean --logs` fails on Windows with `PermissionError` and leaves the credentials file in place
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 35/100
Research direction
Start in logfire/_internal/cli/__init__.py, reading _cli_logging() and parse_clean around the files_to_delete loop. Reproduce with logfire clean --logs --yes on Windows and inspect test_clean[y] and test_clean[yes]. Done means cleanup removes the log, credentials, and read token without raising PermissionError; a linked open pull request already addresses this issue.
Written by the indexing model from the issue text.
Description
On Windows 11 with Python 3.11.9, at 90356e1 on main, in a directory containing .logfire/logfire_credentials.json, running logfire clean --logs --yes fails:
File ".../logfire/_internal/cli/__init__.py", line 132, in parse_clean
file.unlink(missing_ok=True)
PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: '...\.logfire\log.txt'
logfire_credentials.json is still there afterwards. _cli_logging() keeps a logging.FileHandler open on LOGFIRE_LOG_FILE for the whole command, and parse_clean runs inside it and unlinks that same file. POSIX allows deleting an open file, Windows does not. The log file is first in files_to_delete, so the loop stops before it reaches the credentials and read token.
This is also why test_clean[y] and test_clean[yes] fail on Windows.
Two possible fixes: close the log handler before deleting the log file, or delete the log file after the logging context has exited. I am happy to send a small PR with a regression test, whichever you prefer.
Investigated with AI assistance (Claude Code). I ran and checked the results above myself.
- Dominant language
- Python
- Stars
- 4.5k
- Forks
- 365
- Avg merge
- 1d 8h
- Merged PRs (30d)
- 153
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from pydantic/logfire
-
Windows: 16 tests in `tests/test_cli.py` fail, and the CI test job only runs on LinuxPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Docs: update the Playground cost estimate note for Gateway custom pricesPossibly taken @henricop claimed this 13 days ago. Open
Difficulty 1/5 Under an hour Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Maintainers usually reply within 1 day
-
Feature Request
Difficulty 4/5 3-5 days Newbie friendliness 56/100
Maintainers usually reply within 1 day
-
`force_flush()` deadlocks when a span exporter reads `get_tracer_provider().resource`Possibly taken @prassu017 claimed this 2 days ago. Open
Difficulty 3/5 1-2 days Newbie friendliness 35/100
Maintainers usually reply within 1 day
All issues in pydantic/logfire
Similar issues
-
documentation type/bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
add entry to blockOpen
Difficulty 1/5 Under an hour Newbie friendliness 65/100
StevenBlack/hosts#3299 ·
-
`garak --report` overwrites the input report when its name has no ".report"Possibly taken @0z5a claimed this today. Openneeds-triage
Difficulty 2/5 Half a day Newbie friendliness 72/100
Maintainers usually reply within 2 days
-
trace: Pi's 1-hour cache writes are priced at 1.25x, but billed at 2xPossibly taken @Shizoqua claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
microsoft/TokenEconomizer#221 ·
Maintainers usually reply within 1 day
-
plot_graph crashes when a mesh node has no m2m edgePossibly taken @tygvi claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
mllam/neural-lam#883 · 1 comment ·
Maintainers usually reply within 2 days