new_session raises TmuxObjectDoesNotExist even though the session name is new
Opened this issue · 3 comments
saijayanth59 commented
TravisDart commented
I have this problem, as well. Previously my code was working, and now it is not. I have rolled back the libtmux version back to 0.38.0, which was released before I initially created my project, and the library continues to fail. I suspect this is an issue outside of libtmux and either tmux or my OS has some new issue.
TravisDart commented
This is a minimal example that reproduces this error:
FROM python:3.14-alpine
RUN apk add --no-cache tmux docker bash --update
RUN pip install libtmux==0.46.2
RUN cat <<'EOF' > /root/example.py
import libtmux
session = libtmux.Server(colors=256).new_session(session_name="test")
EOF
CMD ["python", "/root/example.py"]
Run with:
docker build -f example.Dockerfile -t example-image:latest .
docker run --rm example-image:latest
Output:
Traceback (most recent call last):
File "/root/example.py", line 2, in <module>
session = libtmux.Server(colors=256).new_session(session_name="test")
File "/usr/local/lib/python3.14/site-packages/libtmux/server.py", line 585, in new_session
return Session.from_session_id(
~~~~~~~~~~~~~~~~~~~~~~~^
server=self,
^^^^^^^^^^^^
session_id=session_formatters["session_id"],
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File "/usr/local/lib/python3.14/site-packages/libtmux/session.py", line 139, in from_session_id
session = fetch_obj(
obj_key="session_id",
...<2 lines>...
server=server,
)
File "/usr/local/lib/python3.14/site-packages/libtmux/neo.py", line 255, in fetch_obj
raise exc.TmuxObjectDoesNotExist(
...<4 lines>...
)
libtmux.exc.TmuxObjectDoesNotExist: Could not find object
Any help would be appreciated.
TravisDart commented
I was able to fix this by using Debian Slim instead of Alpine.
Updated Dockerfile:
FROM python:3.14-slim
RUN apt-get update && apt-get install -y tmux bash
WORKDIR /root
RUN pip install libtmux==0.46.2
RUN cat <<'EOF' > /root/example.py
import libtmux
session = libtmux.Server(colors=256).new_session(session_name="test")
print(session)
EOF
CMD ["python", "/root/example.py"]
Run with:
docker build -f example.Dockerfile -t example-image:latest .
docker run --rm example-image:latest
Output:
Session($0 test)
Seems like the OP would be fine using Ubuntu, so not sure why this is happening. Also see this related issue.
