watchfiles: _rust_notify.WatchfilesRustInternalError: error in underlying watcher: IO error for operation on : No such file or directory (os error 2)
Description
Details
This error occurs on uvicorn startup in a docker environment (based on python:3.11-slim) when using the uvicorn --reload flag.
The path is pointing to the python3 executable of my virtual environment i.e. /backend/app/.ignore/venv/bin/python3.
Full stack trace:
Attaching to backend-1
backend-1 | INFO: Will watch for changes in these directories: ['/backend/app/src']
backend-1 | INFO: Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit)
backend-1 | INFO: Started reloader process [1] using WatchFiles
backend-1 | Traceback (most recent call last):
backend-1 | File "/opt/venv/bin/uvicorn", line 8, in <module>
backend-1 | sys.exit(main())
backend-1 | File "/opt/venv/lib/python3.10/site-packages/click/core.py", line 1157, in __call__
backend-1 | return self.main(*args, **kwargs)
backend-1 | File "/opt/venv/lib/python3.10/site-packages/click/core.py", line 1078, in main
backend-1 | rv = self.invoke(ctx)
backend-1 | File "/opt/venv/lib/python3.10/site-packages/click/core.py", line 1434, in invoke
backend-1 | return ctx.invoke(self.callback, **ctx.params)
backend-1 | File "/opt/venv/lib/python3.10/site-packages/click/core.py", line 783, in invoke
backend-1 | return __callback(*args, **kwargs)
backend-1 | File "/opt/venv/lib/python3.10/site-packages/uvicorn/main.py", line 410, in main
backend-1 | run(
backend-1 | File "/opt/venv/lib/python3.10/site-packages/uvicorn/main.py", line 572, in run
backend-1 | ChangeReload(config, target=server.run, sockets=[sock]).run()
backend-1 | File "/opt/venv/lib/python3.10/site-packages/uvicorn/supervisors/basereload.py", line 52, in run
backend-1 | for changes in self:
backend-1 | File "/opt/venv/lib/python3.10/site-packages/uvicorn/supervisors/basereload.py", line 71, in __next__
backend-1 | return self.should_restart()
backend-1 | File "/opt/venv/lib/python3.10/site-packages/uvicorn/supervisors/watchfilesreload.py", line 84, in should_restart
backend-1 | changes = next(self.watcher)
backend-1 | File "/opt/venv/lib/python3.10/site-packages/watchfiles/main.py", line 121, in watch
backend-1 | raw_changes = watcher.watch(debounce, step, rust_timeout, stop_event)
backend-1 | _rust_notify.WatchfilesRustInternalError: error in underlying watcher: IO error for operation on /backend/app/.ignore/venv/bin/python3: No such file or directory (os error 2)
Workaround
Specifically adding watchfiles==0.21.0 as a dependency to my project resolves the issue.
Example Code
No response
Watchfiles Output
No response
Operating System & Architecture
docker on WSL2
Environment
docker on WSL2
Python & Watchfiles Version
0.21.0
Rust & Cargo Version
No response
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 5
- Comments: 24 (11 by maintainers)
@samuelcolvin I wouldn’t call this a very thorough test, but I did install the new version from a wheel, and the error does NOT pop up where it used to previously. Just before the installation I was able to trigger the error with v0.23 (within 10 seconds or so after uvicorn launch), and with the new version I did not get any errors after about 3 minutes of interacting with the app.
Turns out there’s no env var to enable debug, but I think I have enough to fix this.
It should be fixed with the latest release on pypi.
This issue still persists on Windows WSL2, any quick fixes for it?
UPDATE : Had to Install Rust through the CLI to fix this
That’s great news, thank you.
I’ll wait a day or two to see if someone else can also check it and confirm the error is gone, then make a release.
I am getting same error, also Docker on WSL2 (Ubuntu 22.04).
I get error on
0.22.0and0.23.0but not0.21.0I am encountering the same issue with the
python:3.12image in a Docker environment.Downgrading from “0.22.0” to “0.21.0” fix the problem.