tmuxp icon indicating copy to clipboard operation
tmuxp copied to clipboard

Trouble fetching the session_id when tmux server is already running

Open Gigibeau opened this issue 2 years ago • 8 comments

Step 1: Provide a summary of your problem

There is a fetching error when trying to start a tmuxp session while already hosting a tmux server. No matter if I create a new session or append to the current one.

Step 2: Provide tmuxp details

-------------------------
environment:
	dist: macOS-13.1-arm64-arm-64bit
	arch: arm64
	uname: Darwin; MacBook-Pro-2.local; 22.2.0
	version: Darwin Kernel Version 22.2.0: Fri Nov 11 02:03:51 PST 2022; root:xnu-8792.61.2~4/RELEASE_ARM64_T6000
-------------------------
python version: 3.11.1 (main, Dec 23 2022, 09:25:23) [Clang 14.0.0 (clang-1400.0.29.202)]

tmux version: 3.3
libtmux version: 0.20.0
tmuxp version: 1.26.0
tmux path: /opt/homebrew/bin/tmux
tmuxp path: /opt/homebrew/Cellar/tmuxp/1.26.0/libexec/lib/python3.11/site-packages/tmuxp
shell: /bin/zsh
-------------------------
tmux sessions:
	config: 6 windows (created Wed Jan 25 15:17:20 2023)
	xxx: 4 windows (created Wed Jan 25 15:17:20 2023) (attached)
	xxx28: 1 windows (created Wed Jan 25 16:07:11 2023)
	rust: 2 windows (created Wed Jan 25 15:17:20 2023)



tmux windows:
	1: home* (2 panes) [168x53] [layout 6447,168x53,0,0{123x53,0,0,0,44x53,124,0,1}] @0 (active)
	2: nvim- (1 panes) [168x53] [layout bdff,168x53,0,0,2] @1
	3: logs (3 panes) [80x24] [layout 8f3c,80x24,0,0{40x24,0,0[40x12,0,0,3,40x11,0,13,4],39x24,41,0,5}] @2
	4: all-logs (1 panes) [168x53] [layout be03,168x53,0,0,6] @3



tmux panes:
	0: [123x53] [history 301/64096, 128133 bytes] %0 (active)
	1: [44x53] [history 9/64096, 3934 bytes] %1



tmux global options:
	@plugin jlipps/tmux-safekill
	activity-action other
	assume-paste-time 1
	base-index 1
	bell-action any
	default-command "which reattach-to-user-namespace > /dev/null && reattach-to-user-namespace -l /bin/zsh || /bin/zsh"
	default-shell /bin/zsh
	default-size 80x24
	destroy-unattached off
	detach-on-destroy on
	display-panes-active-colour colour33
	display-panes-colour colour166
	display-panes-time 1000
	display-time 750
	history-limit 64096
	key-table root
	lock-after-time 0
	lock-command "lock -np"
	message-command-style "fg=#eee8d5,bg=#073642"
	message-style "fg=#eee8d5,bg=#073642"
	mouse on
	prefix C-q
	prefix2 None
	renumber-windows off
	repeat-time 0
	set-titles off
	set-titles-string "#S:#I:#W - \"#T\" #{session_alerts}"
	silence-action other
	status on
	status-bg #002b36
	status-fg cyan
	status-format[0] "#[align=left range=left #{E:status-left-style}]#[push-default]#{T;=/#{status-left-length}:status-left}#[pop-default]#[norange default]#[list=on align=#{status-justify}]#[list=left-marker]<#[list=right-marker]>#[list=on]#{W:#[range=window|#{window_index} #{E:window-status-style}#{?#{&&:#{window_last_flag},#{!=:#{E:window-status-last-style},default}}, #{E:window-status-last-style},}#{?#{&&:#{window_bell_flag},#{!=:#{E:window-status-bell-style},default}}, #{E:window-status-bell-style},#{?#{&&:#{||:#{window_activity_flag},#{window_silence_flag}},#{!=:#{E:window-status-activity-style},default}}, #{E:window-status-activity-style},}}]#[push-default]#{T:window-status-format}#[pop-default]#[norange default]#{?window_end_flag,,#{window-status-separator}},#[range=window|#{window_index} list=focus #{?#{!=:#{E:window-status-current-style},default},#{E:window-status-current-style},#{E:window-status-style}}#{?#{&&:#{window_last_flag},#{!=:#{E:window-status-last-style},default}}, #{E:window-status-last-style},}#{?#{&&:#{window_bell_flag},#{!=:#{E:window-status-bell-style},default}}, #{E:window-status-bell-style},#{?#{&&:#{||:#{window_activity_flag},#{window_silence_flag}},#{!=:#{E:window-status-activity-style},default}}, #{E:window-status-activity-style},}}]#[push-default]#{T:window-status-current-format}#[pop-default]#[norange list=on default]#{?window_end_flag,,#{window-status-separator}}}#[nolist align=right range=right #{E:status-right-style}]#[push-default]#{T;=/#{status-right-length}:status-right}#[pop-default]#[norange default]"
	status-format[1] "#[align=centre]#{P:#{?pane_active,#[reverse],}#{pane_index}[#{pane_width}x#{pane_height}]#[default] }"
	status-interval 1
	status-justify left
	status-keys emacs
	status-left "#[fg=#073642,bg=#eee8d5,bold] #S #[fg=#eee8d5,bg=#93a1a1,nobold,nounderscore,noitalics]#[fg=#15161E,bg=#93a1a1,bold] #[fg=#93a1a1,bg=#002b36]"
	status-left-length 100
	status-left-style NONE
	status-position bottom
	status-right "#[fg=#586e75,bg=#002b36,nobold,nounderscore,noitalics]#[fg=#93a1a1,bg=#586e75] #{prefix_highlight} #[fg=#657b83,bg=#586e75,nobold,nounderscore,noitalics]#[fg=#93a1a1,bg=#657b83] #[fg=#93a1a1,bg=#657b83,nobold,nounderscore,noitalics]#[fg=#15161E,bg=#93a1a1,bold] #(tmux-mem-cpu-load --interval 1 -g 5 -a 0) "
	status-right-length 100
	status-right-style NONE
	status-style "fg=#586e75,bg=#073642"
	update-environment[0] DISPLAY
	update-environment[1] KRB5CCNAME
	update-environment[2] SSH_ASKPASS
	update-environment[3] SSH_AUTH_SOCK
	update-environment[4] SSH_AGENT_PID
	update-environment[5] SSH_CONNECTION
	update-environment[6] WINDOWID
	update-environment[7] XAUTHORITY
	update-environment[8] KITTY_LISTEN_ON
	visual-activity off
	visual-bell off
	visual-silence off
	word-separators "!\"#$%&'()*+,-./:;<=>?@[\\]^`{|}~"



tmux window options:
	cursor-colour none
	cursor-style default
	aggressive-resize off
	allow-passthrough off
	allow-rename off
	alternate-screen on
	automatic-rename on
	automatic-rename-format "#{b:pane_current_path}"
	clock-mode-colour colour64
	clock-mode-style 24
	copy-mode-match-style bg=cyan,fg=black
	copy-mode-current-match-style bg=magenta,fg=black
	copy-mode-mark-style bg=red,fg=black
	fill-character ''
	main-pane-height 24
	main-pane-width 80
	mode-keys vi
	mode-style "fg=#eee8d5,bg=#073642"
	monitor-activity off
	monitor-bell on
	monitor-silence 0
	other-pane-height 0
	other-pane-width 0
	pane-active-border-style "fg=#eee8d5"
	pane-base-index 0
	pane-border-format "#{?pane_active,#[reverse],}#{pane_index}#[default] \"#{pane_title}\""
	pane-border-indicators colour
	pane-border-lines single
	pane-border-status off
	pane-border-style "fg=#073642"
	pane-colours
	popup-style default
	popup-border-style default
	popup-border-lines single
	remain-on-exit off
	remain-on-exit-format "Pane is dead (#{?#{!=:#{pane_dead_status},},status #{pane_dead_status},}#{?#{!=:#{pane_dead_signal},},signal #{pane_dead_signal},}, #{t:pane_dead_time})"
	scroll-on-clear on
	synchronize-panes off
	window-active-style fg=colour12,bg=default
	window-size latest
	window-style fg=colour10,bg=default
	window-status-activity-style "underscore,fg=#839496,bg=#002b36"
	window-status-bell-style reverse
	window-status-current-format "#[fg=#002b36,bg=#eee8d5]#[fg=#b58900,bg=#eee8d5] #I #[fg=#eee8d5,bg=#b58900] #{b:window_name} #[fg=#b58900,bg=#002b36,nobold]"
	window-status-current-style fg=colour166,bg=default,bright
	window-status-format "#[fg=#002b36,bg=#002b36]#[default] #I  #{b:window_name} #[fg=#002b36,bg=#002b36,nobold,nounderscore,noitalics]"
	window-status-last-style default
	window-status-separator ''
	window-status-style "NONE,fg=#839496,bg=#002b36"
	wrap-search on
	xterm-keys on

Step 3: Describe the problem:

Steps to reproduce:

Already hosting a tmux server, having a xxx.tmuxp.yaml file with multiple windows and trying to execute it with tmuxp load xxx.tmuxp.yaml.

Observed Results:

When trying to create a new session:

Traceback (most recent call last):
  File "/opt/homebrew/bin/tmuxp", line 8, in <module>
    sys.exit(cli.cli())
             ^^^^^^^^^
  File "/opt/homebrew/Cellar/tmuxp/1.26.0/libexec/lib/python3.11/site-packages/tmuxp/cli/__init__.py", line 134, in cli
    command_load(
  File "/opt/homebrew/Cellar/tmuxp/1.26.0/libexec/lib/python3.11/site-packages/tmuxp/cli/load.py", line 642, in command_load
    load_workspace(
  File "/opt/homebrew/Cellar/tmuxp/1.26.0/libexec/lib/python3.11/site-packages/tmuxp/cli/load.py", line 448, in load_workspace
    _load_attached(builder, detached)
  File "/opt/homebrew/Cellar/tmuxp/1.26.0/libexec/lib/python3.11/site-packages/tmuxp/cli/load.py", line 184, in _load_attached
    builder.build()
  File "/opt/homebrew/Cellar/tmuxp/1.26.0/libexec/lib/python3.11/site-packages/tmuxp/workspace/builder.py", line 242, in build
    session = self.server.new_session(
              ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/tmuxp/1.26.0/libexec/lib/python3.11/site-packages/libtmux/server.py", line 494, in new_session
    return Session.from_session_id(
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/tmuxp/1.26.0/libexec/lib/python3.11/site-packages/libtmux/session.py", line 85, in from_session_id
    session = fetch_obj(
              ^^^^^^^^^^
  File "/opt/homebrew/Cellar/tmuxp/1.26.0/libexec/lib/python3.11/site-packages/libtmux/neo.py", line 244, in fetch_obj
    raise ObjectDoesNotExist(
libtmux._internal.query_list.ObjectDoesNotExist: Could not find session_id=$7 for list-sessions

When trying to append the windows:

Traceback (most recent call last):
  File "/opt/homebrew/bin/tmuxp", line 8, in <module>
    sys.exit(cli.cli())
             ^^^^^^^^^
  File "/opt/homebrew/Cellar/tmuxp/1.26.0/libexec/lib/python3.11/site-packages/tmuxp/cli/__init__.py", line 134, in cli
    command_load(
  File "/opt/homebrew/Cellar/tmuxp/1.26.0/libexec/lib/python3.11/site-packages/tmuxp/cli/load.py", line 642, in command_load
    load_workspace(
  File "/opt/homebrew/Cellar/tmuxp/1.26.0/libexec/lib/python3.11/site-packages/tmuxp/cli/load.py", line 450, in load_workspace
    _load_append_windows_to_current_session(builder)
  File "/opt/homebrew/Cellar/tmuxp/1.26.0/libexec/lib/python3.11/site-packages/tmuxp/cli/load.py", line 237, in _load_append_windows_to_current_session
    builder.build(current_attached_session, append=True)
  File "/opt/homebrew/Cellar/tmuxp/1.26.0/libexec/lib/python3.11/site-packages/tmuxp/workspace/builder.py", line 261, in build
    assert session.id
AssertionError

When no tmux server is running it works as usual though. This was no issue before I updated to the newest version through brew, I don't know which version I was on before.

Expected Results:

Starting the tmuxp session as usual.

Relevant Code:

Its quite a big configuration and to anonymizing it would take some time. I assume this has nothing to do with the config right? If I'm wrong I'm happy to provide it if needed (:.

Gigibeau avatar Jan 25 '23 15:01 Gigibeau

What an interesting coincidence. I faced the same issue just now, three hours after you. It is happening with all my configs. I'm including one as reference but there's nothing special to it really.

session_name: coralillo
start_directory: /some/path/that/exists
windows:
- focus: 'true'
  layout: 66e2,211x58,0,0,13
  options: {}
  panes:
  - pipenv run pytest -xvv
  window_name: shell
- layout: 66e3,211x58,0,0,14
  options: {}
  panes:
  - focus: 'true'
    shell_command: nvim
  window_name: editor

categulario avatar Jan 25 '23 18:01 categulario

ran into the same issue, rolling back to older version 1.24.1 didn't work. then I tried kill tmux server tmux kill-server, restart, tmuxp worked, maybe something releated to tmux server status?

dcai avatar Jan 30 '23 01:01 dcai

Thank you everyone above. If we can get a way to reproduce this (perhaps on pytest) that would be very convenient.

@dcai Have you tried tmuxp v1.27.0? (New release this morning)

tony avatar Jan 30 '23 03:01 tony

In regards to v1.27.0 - @categulario @Gigibeau : Does anything change with this?

tony avatar Jan 30 '23 03:01 tony

@tony yes I have tried 1.27 1.25 and 1.24.1, that doesnt make any difference, only killing tmux server worked for me.

my os is macos 13.1.

dcai avatar Jan 30 '23 03:01 dcai

@tony 1.27 did the trick for me, at least for now (:

Gigibeau avatar Jan 30 '23 08:01 Gigibeau

@tony 1.27 works for me

categulario avatar Jan 30 '23 15:01 categulario

Good to know it works now @Gigibeau and @categulario !

@dcai Can you show your tmuxp -V and tmux -V? Maybe there's a package that is out of date? If not perhaps you can give more info on reproducing? (Maybe you have an issue, but it's a different one, or maybe it's the same as other's have, not sure yet!)

tony avatar Jan 30 '23 19:01 tony