tmux-python/tmuxp

list index out of range for sample yaml

bedge opened this issue · 4 comments

bedge commented

Step 1: Provide a summary of your problem

Trying to load the sample session:
https://github.com/tmux-python/tmuxp#load-a-tmux-session

fails with stack trace:

[I] ➜  tmuxp load ~/tmp/sample.yaml
[Loading] /Users/edgeb1/tmp/sample.yaml
list index out of range
Traceback (most recent call last):
  File "/Users/edgeb1/.pyenv/versions/3.9.0/bin/tmuxp", line 8, in <module>
    sys.exit(cli.cli())
  File "/Users/edgeb1/.pyenv/versions/3.9.0/lib/python3.9/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/Users/edgeb1/.pyenv/versions/3.9.0/lib/python3.9/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/Users/edgeb1/.pyenv/versions/3.9.0/lib/python3.9/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/edgeb1/.pyenv/versions/3.9.0/lib/python3.9/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/edgeb1/.pyenv/versions/3.9.0/lib/python3.9/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/Users/edgeb1/.pyenv/versions/3.9.0/lib/python3.9/site-packages/click/decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/Users/edgeb1/.pyenv/versions/3.9.0/lib/python3.9/site-packages/tmuxp/cli/load.py", line 573, in command_load
    load_workspace(config[-1], **tmux_options)
  File "/Users/edgeb1/.pyenv/versions/3.9.0/lib/python3.9/site-packages/tmuxp/cli/load.py", line 418, in load_workspace
    _load_attached(builder, detached)
  File "/Users/edgeb1/.pyenv/versions/3.9.0/lib/python3.9/site-packages/tmuxp/cli/load.py", line 159, in _load_attached
    builder.build()
  File "/Users/edgeb1/.pyenv/versions/3.9.0/lib/python3.9/site-packages/tmuxp/workspacebuilder.py", line 217, in build
    assert self.sconf["session_name"] == session.name
  File "/Users/edgeb1/.pyenv/versions/3.9.0/lib/python3.9/site-packages/libtmux/common.py", line 347, in __getattr__
    val = self._info[self.formatter_prefix + key]
TypeError: 'NoneType' object is not subscriptable

Granted, I did just upgrade a bunch of python libs, but I don't know what specific library change is causing this.
Picked up a new version of tmuxp as well.

Step 2: Provide tmuxp details

  • Include output of tmuxp debug-info
[I] ➜ tmuxp debug-info
-------------------------
environment:
	dist: macOS-10.15.7-x86_64-i386-64bit
	arch: x86_64
	uname: Darwin; edgeb1-F0MD6R; 19.6.0
	version: Darwin Kernel Version 19.6.0: Mon Apr 18 21:50:40 PDT 2022; root:xnu-6153.141.62~1/RELEASE_X86_64
-------------------------
python version: 3.9.0 (default, Dec  9 2020, 10:07:40)  [Clang 12.0.0 (clang-1200.0.32.27)]
system PATH: /Users/edgeb1/.pyenv/versions/3.9.0/bin:/usr/local/Cellar/pyenv/2.3.3/libexec:/usr/local/Cellar/pyenv/2.3.3/plugins/python-build/bin:/Users/edgeb1/.rbenv/shims:/Users/edgeb1/.pyenv/shims:/Users/edgeb1/.pyenv/bin:/Users/edgeb1/.zinit/plugins/vim---vim/src:/Users/edgeb1/.zinit/plugins/docker---compose:/Users/edgeb1/.zinit/plugins/junegunn---fzf-bin:/Users/edgeb1/.zinit/polaris/bin:/Users/edgeb1/.bin:/Users/edgeb1/venv/p3/bin:/usr/local/opt/go/libexec/bin:/Users/edgeb1/golang/bin:/usr/local/opt/openjdk/bin:/usr/local/bin/aws:/usr/local/opt/libtool/libexec/gnubin:/usr/local/opt/grep/libexec/gnubin:/usr/local/opt/gnu-which/libexec/gnubin:/usr/local/opt/gnu-tar/libexec/gnubin:/usr/local/opt/gnu-sed/libexec/gnubin:/usr/local/opt/gawk/libexec/gnubin:/usr/local/opt/findutils/libexec/gnubin:/usr/local/opt/coreutils/libexec/gnubin:/usr/local/sbin:/usr/local/bin:.git/safe/../../bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin:/usr/local/share/dotnet:/opt/X11/bin:/Library/Apple/usr/bin:/Users/edgeb1/.local/bin:/Users/edgeb1/.fzf/bin
tmux version: 3.3
libtmux version: 0.14.0
tmuxp version: 1.13.0
tmux path: /usr/local/bin/tmux
tmuxp path: /Users/edgeb1/.pyenv/versions/3.9.0/lib/python3.9/site-packages/tmuxp
shell: /usr/local/bin/zsh
-------------------------
tmux sessions:
	a-local: 8 windows (created Sat Aug  6 12:34:51 2022)
	nghc: 15 windows (created Sat Aug  6 12:34:51 2022) (attached)

tmux windows:
	0: nghcZ (2 panes) [198x61] [layout 459e,198x61,0,0{99x61,0,0,8,98x61,100,0,23}] @8
	1: sh (1 panes) [198x61] [layout b8c6,198x61,0,0,9] @9
	2: tess (1 panes) [198x61] [layout 5c8f,198x61,0,0,10] @10
	3: git* (1 panes) [198x61] [layout 5c90,198x61,0,0,11] @11 (active)
	4: sb- (1 panes) [198x61] [layout 5c91,198x61,0,0,12] @12
	5: sb2 (1 panes) [80x24] [layout 5962,80x24,0,0,13] @13
	6: sb3 (1 panes) [80x24] [layout 5963,80x24,0,0,14] @14
	7: dev (1 panes) [198x61] [layout 5c94,198x61,0,0,15] @15
	8: dev3 (1 panes) [80x24] [layout 5965,80x24,0,0,16] @16
	9: dev4 (1 panes) [80x24] [layout 5966,80x24,0,0,17] @17
	10: prd2 (1 panes) [198x61] [layout 5c97,198x61,0,0,18] @18
	11: prd5x (1 panes) [198x60] [layout 5a98,198x60,0,0,19] @19
	12: vnv5x (1 panes) [198x60] [layout da8f,198x60,0,0,20] @20
	13: jk (1 panes) [198x61] [layout dc90,198x61,0,0,21] @21
	14: zsh (1 panes) [198x61] [layout dc91,198x61,0,0,22] @22

tmux panes:
	1: [198x60] [history 2521/5000, 1388636 bytes] %11 (active)

tmux global options:
	@logging-filename "#{session_name}-#{window_name}-#{pane_index}.log"
	@logging-path /Users/edgeb1/log/tmux/%Y-%m-%d
	@pane_resize 5
	@plugin christoomey/vim-tmux-navigator
	activity-action other
	assume-paste-time 1
	base-index 0
	bell-action any
	default-command "reattach-to-user-namespace -l /usr/local/bin/zsh"
	default-shell /usr/local/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 4000
	history-limit 5000
	key-table root
	lock-after-time 0
	lock-command "lock -np"
	message-command-style bg=black,fg=yellow
	message-style bg=colour235,fg=colour166
	mouse on
	prefix `
	prefix2 None
	renumber-windows off
	repeat-time 500
	set-titles off
	set-titles-string "#S:#I:#W - \"#T\" #{session_alerts}"
	silence-action other
	status on
	status-bg default
	status-fg default
	status-format[0] "#[align=left range=left #{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} #{window-status-style}#{?#{&&:#{window_last_flag},#{!=:#{window-status-last-style},default}}, #{window-status-last-style},}#{?#{&&:#{window_bell_flag},#{!=:#{window-status-bell-style},default}}, #{window-status-bell-style},#{?#{&&:#{||:#{window_activity_flag},#{window_silence_flag}},#{!=:#{window-status-activity-style},default}}, #{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 #{?#{!=:#{window-status-current-style},default},#{window-status-current-style},#{window-status-style}}#{?#{&&:#{window_last_flag},#{!=:#{window-status-last-style},default}}, #{window-status-last-style},}#{?#{&&:#{window_bell_flag},#{!=:#{window-status-bell-style},default}}, #{window-status-bell-style},#{?#{&&:#{||:#{window_activity_flag},#{window_silence_flag}},#{!=:#{window-status-activity-style},default}}, #{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 #{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 centre
	status-keys vi
	status-left "#[fg=green]#H #[fg=black]• #[fg=green,bright]#(uname -r | cut -c 1-6)#[default]"
	status-left-length 20
	status-left-style default
	status-position bottom
	status-right "#[fg=green,bg=default,bright]#(tmux-mem-cpu-load) #[fg=red,dim,bg=default]#(uptime | cut -f 4-5 -d \" \" | cut -f 1 -d \",\") #[fg=white,bg=default]%a%l:%M:%S %p#[default] #[fg=blue]%Y-%m-%d"
	status-right-length 140
	status-right-style default
	status-style bright
	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
	visual-activity off
	visual-bell off
	visual-silence off
	word-separators " "

tmux window options:
	aggressive-resize off
	allow-rename off
	alternate-screen on
	automatic-rename on
	automatic-rename-format "#{?pane_in_mode,[tmux],#{pane_current_command}}#{?pane_dead,[dead],}"
	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
	main-pane-height 24
	main-pane-width 80
	mode-keys vi
	mode-style bg=yellow,fg=black
	monitor-activity off
	monitor-bell on
	monitor-silence 0
	other-pane-height 0
	other-pane-width 0
	pane-active-border-style "#{?pane_in_mode,fg=yellow,#{?synchronize-panes,fg=red,fg=green}}"
	pane-base-index 1
	pane-border-format "#{pane_index} #{pane_title}"
	pane-border-lines single
	pane-border-status bottom
	pane-border-style default
	remain-on-exit off
	synchronize-panes off
	window-active-style fg=default,bg=colour234
	window-size latest
	window-style fg=colour247,bg=colour235
	window-status-activity-style reverse
	window-status-bell-style reverse
	window-status-current-format "  #{window_index} #{window_name}  "
	window-status-current-style "fg=#000000,bg=yellow"
	window-status-format "#{window_index} #{window_name}"
	window-status-last-style default
	window-status-separator " "
	window-status-style fg=brightblue
	wrap-search on
	xterm-keys on
  • Include any other pertinant system info not captured
[I] ➜ pipdeptree -p tmuxp
Warning!!! Possibly conflicting dependencies found:
* aws-amicleaner==0.2.2
 - awscli [required: Any, installed: ?]
* aws-sam-translator==1.49.0
 - jsonschema [required: ~=3.2, installed: 4.9.1]
* gitlab-v4==0.0.7
 - urllib3 [required: ==1.26.6, installed: 1.26.11]
 - certifi [required: ==2021.5.30, installed: 2022.6.15]
 - requests [required: ==2.26.0, installed: 2.28.1]
 - idna [required: ==3.2, installed: 3.3]
 - charset-normalizer [required: ==2.0.4, installed: 2.1.0]
* httpcore==0.15.0
 - h11 [required: >=0.11,<0.13, installed: 0.13.0]
* httpx==0.23.0
 - rfc3986 [required: >=1.3,<2, installed: 2.0.0]
* jmespath-terminal==0.2.1
 - jmespath [required: >=0.4.1,<=1.0.0, installed: 1.0.1]
 - urwid [required: ==1.2.2, installed: 2.1.2]
* molecule==4.0.1
 - cerberus [required: >=1.3.1,!=1.3.4,!=1.3.3, installed: 1.3.4]
* navify-aws-sso-login==0.3.2
 - PyYAML [required: >=6.0, installed: 5.4.1]
* Terrascan==0.2.3
 - pyhcl [required: >=0.4.4, installed: ?]
------------------------------------------------------------------------
tmuxp==1.13.0
  - click [required: >=8,<9, installed: 8.1.3]
  - colorama [required: >=0.3.9, installed: 0.4.5]
  - kaptan [required: >=0.5.10, installed: 0.5.12]
    - PyYAML [required: >=3.13,<6, installed: 5.4.1]
  - libtmux [required: >=0.14.0,<0.15.0, installed: 0.14.0]
  - ```

### Step 3: Describe the problem:

Updated pip dependencies for another package and tmuxp ceased working.
I rolled back pyyaml to 5.4.1 (was upgraded to 6.0), no change

#### Steps to reproduce:

1. ... copy sample yaml (https://github.com/tmux-python/tmuxp#load-a-tmux-session) to ~/tmp/sample.yaml
2. ... run `tmuxp load ~/tmp/sample.yaml`


#### Observed Results:

- What happened? This could be a description, log output, etc.

[I] ➜ tmuxp load ~/tmp/sample.yaml
[Loading] /Users/edgeb1/tmp/sample.yaml
list index out of range
Traceback (most recent call last):
File "/Users/edgeb1/.pyenv/versions/3.9.0/bin/tmuxp", line 8, in
sys.exit(cli.cli())
File "/Users/edgeb1/.pyenv/versions/3.9.0/lib/python3.9/site-packages/click/core.py", line 1130, in call
return self.main(*args, **kwargs)
File "/Users/edgeb1/.pyenv/versions/3.9.0/lib/python3.9/site-packages/click/core.py", line 1055, in main
rv = self.invoke(ctx)
File "/Users/edgeb1/.pyenv/versions/3.9.0/lib/python3.9/site-packages/click/core.py", line 1657, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/Users/edgeb1/.pyenv/versions/3.9.0/lib/python3.9/site-packages/click/core.py", line 1404, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/Users/edgeb1/.pyenv/versions/3.9.0/lib/python3.9/site-packages/click/core.py", line 760, in invoke
return __callback(*args, **kwargs)
File "/Users/edgeb1/.pyenv/versions/3.9.0/lib/python3.9/site-packages/click/decorators.py", line 26, in new_func
return f(get_current_context(), *args, **kwargs)
File "/Users/edgeb1/.pyenv/versions/3.9.0/lib/python3.9/site-packages/tmuxp/cli/load.py", line 573, in command_load
load_workspace(config[-1], **tmux_options)
File "/Users/edgeb1/.pyenv/versions/3.9.0/lib/python3.9/site-packages/tmuxp/cli/load.py", line 418, in load_workspace
_load_attached(builder, detached)
File "/Users/edgeb1/.pyenv/versions/3.9.0/lib/python3.9/site-packages/tmuxp/cli/load.py", line 159, in _load_attached
builder.build()
File "/Users/edgeb1/.pyenv/versions/3.9.0/lib/python3.9/site-packages/tmuxp/workspacebuilder.py", line 217, in build
assert self.sconf["session_name"] == session.name
File "/Users/edgeb1/.pyenv/versions/3.9.0/lib/python3.9/site-packages/libtmux/common.py", line 347, in getattr
val = self._info[self.formatter_prefix + key]
TypeError: 'NoneType' object is not subscriptable


#### Expected Results:

Create a tmux session

- What did you expect to happen?

#### Relevant Code:

[I] ➜ cat ~/tmp/sample.yaml
session_name: 4-pane-split
windows:

  • window_name: dev window
    layout: tiled
    shell_command_before:
    • cd ~/ # run as a first command in all panes
      panes:
    • shell_command: # pane no. 1
      • cd /var/log # run multiple commands in this pane
      • ls -al | grep .log
    • echo second pane # pane no. 2
    • echo third pane # pane no. 3
    • echo forth pane # pane no. 4
tony commented

@bedge Interestingly, this works for me (Ubuntu on WSL2)

Can you try this without a tmux config (-f /dev/null)? Without other tmux sessions (-L mysess)?

tmuxp load config.yaml -L test -f /dev/null

If you try that, is anything different?

Any more clues?

bedge commented

@tony
That works: tmuxp load ~/tmp/sample.yaml -L test -f /dev/null
as does: tmuxp load ~/tmp/sample.yaml -L test

tmuxp load ~/tmp/sample.yaml -L "" fails in the same way.

So here's where I remember to add - I already have another tmux session running from before I upgraded anything.

Was there a change with the socket name default handling where not providing a socket name now collides with any existing sessions?

I killed off my many months old tmux to test this theory (something I usually avoid at all costs as I expect do most tmux users), and, yes,
tmuxp load ~/tmp/sample.yaml works now.

...both with and without the existing session running.

I'll close this as a corner case of straddling multi-version configurations. I wouldn't even know how to recreate the issues now.

Thanks for the suggestions.

tony commented

Thanks for the very detailed response. This issue looks like it'll be helpful if anyone in a similar case happens upon it!

So here's where I remember to add - I already have another tmux session running from before I upgraded anything.

That can cause funky results. You may end up getting "protocol" errors if you do that, it varies case by case

If anything else comes up feel free to mention

bedge commented

Thanks for the very detailed response. This issue looks like it'll be helpful if anyone in a similar case happens upon it!

Yep, that's the idea - I'll see my own comment when I forget and do it again :)