watchfiles icon indicating copy to clipboard operation
watchfiles copied to clipboard

_rust_notify.WatchfilesRustInternalError: error in underlying watcher: IO error for operation on <python path>: No such file or directory (os error 2)

Open pavdwest opened this issue 3 weeks ago • 0 comments

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

pavdwest avatar Jun 10 '24 09:06 pavdwest