-
Notifications
You must be signed in to change notification settings - Fork 301
Description
Describe the bug
After installing llmstack library, when running llmstack
on Windows, the CLI fails to start due to a locked temp file used as the --env-file
for docker compose
. This is caused by NamedTemporaryFile
keeping the file open, which prevents Docker from accessing it.
Error
C:\Users\raman\AppData\Local\Temp\tmp4mjbq6gt: The process cannot access the file because it is being used by another process.Traceback (most recent call last):
File "", line 198, in _run_module_as_main
File "", line 88, in run_code
File "D:\Practice\GenAI\Multi-Agents.venv\Scripts\llmstack.exe_main.py", line 10, in
sys.exit(main())
~~~~^^
File "D:\Practice\GenAI\Multi-Agents.venv\Lib\site-packages\llmstack\cli.py", line 317, in main
start(llmstack_environment)
~~~~~^^^^^^^^^^^^^^^^^^^^^^
File "D:\Practice\GenAI\Multi-Agents.venv\Lib\site-packages\llmstack\cli.py", line 221, in start
for _, line in docker_logs:
^^^^^^^^^^^
File "D:\Practice\GenAI\Multi-Agents.venv\Lib\site-packages\python_on_whales\utils.py", line 295, in stream_stdout_and_stderr
raise DockerException(full_cmd, exit_code, stderr=full_stderr)
python_on_whales.exceptions.DockerException: The docker command executed was C:\Program Files\Docker\Docker\resources\bin\docker.EXE compose --file D:\Practice\GenAI\Multi-Agents.venv\Lib\site-packages\llmstack\docker-compose.yml --env-file C:\Users\raman\AppData\Local\Temp\tmp4mjbq6gt up --detach --pull missing.
It returned with code 1
The content of stdout can be found above the stacktrace (it wasn't captured).
The content of stderr is 'open C:\Users\raman\AppData\Local\Temp\tmp4mjbq6gt: The process cannot access the file because it is being used by another process.
'
Version
Version of LLMStack this issue is seen in: 0.2.6.
Environment
I am running it on Windows. Faced a similar issue in Mac as well
Root cause
Python's NamedTemporaryFile holds an open file handle, which causes access conflicts on Windows due to exclusive locks.
Proposed fix
Switch to using NamedTemporaryFile(delete=False) and close the file before passing its path to Docker. Clean up the file afterward.
Offer to contribute
I’m interested in contributing a fix for this issue. If maintainers are okay with this approach, I can submit a PR