tmuxp icon indicating copy to clipboard operation
tmuxp copied to clipboard

Commands are not run in the correct pane

Open sdelafond opened this issue 8 years ago • 16 comments

session_name: test
windows:
- panes:
  - shell_command: tmux display-message -p '#{window_index}'
- focus: true
  panes:
  - shell_command: tmux display-message -p '#{window_index}'

Both windows will show "1" as output, instead of "0" in the 1st and "1" in the second, so it appears that whichever windows has focus:true will somehow be used to actually run the commands...

sdelafond avatar Feb 22 '17 11:02 sdelafond

@sdelafond This happened in the most recent versions of tmux when how panes are split changed.

WorkspaceBuilder will need to get updated, because the previous way it used to split and traverse panes relied on behavior that was actually undefined.

tony avatar Feb 23 '17 16:02 tony

All right, no problem. Once that's fixed I'll make sure to upload the new version to Debian ;)

sdelafond avatar Feb 23 '17 16:02 sdelafond

@sdelafond I mistakenly correlated #127 to this issue. #127 fixes separate issue with pane ordering in recent versions of tmux. 1.2.6 is live.

After looking closer at the behavior in the original issue, I can confirm that the behavior you pointed out still happens.

The reason why is WorkspaceBuilder creates each window and runs its commands sequentially.

In order to get this behavior to work, as listed in the YAML config, tmuxp would have to create windows ahead of time, then go back to each window and build the panes, run the commands, etc. Which is fine w/ me.

Anything in particular #217 gets in the way of? I'm just trying to gauge the urgency.

tony avatar Feb 24 '17 22:02 tony

No urgency at all, I just came across this behavior and was surprised. I'll package and upload 1.6 anyway :)

I would have to look at the code for WorkspaceBuilder, but I'm not sure I understand why creating windows sequentially, and immediately building their panes with associated commands (like you're describing it does in 1.2.6) doesn't result in each window having its correct #{window_index} when queried via tmux. I'm probably missing something obvious heh...

sdelafond avatar Feb 25 '17 08:02 sdelafond

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

This bot is used to handle issues where the issue hasn't been discussed or has gone out of date. If an issue isn't resolved and handled in a certain period of time, it may be closed. If you would like your issue re-opened, please create a fresh issue with the latest, up to date information and mention this issue in it.

stale[bot] avatar Nov 11 '17 22:11 stale[bot]

Quick bump :)

sdelafond avatar Nov 13 '17 07:11 sdelafond

Thank you for updating this issue. It is no longer marked as stale.

stale[bot] avatar Nov 13 '17 07:11 stale[bot]

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

This bot is used to handle issues where the issue hasn't been discussed or has gone out of date. If an issue isn't resolved and handled in a certain period of time, it may be closed. If you would like your issue re-opened, please create a fresh issue with the latest, up to date information and mention this issue in it.

stale[bot] avatar Jan 12 '18 08:01 stale[bot]

Last bump. I tried recently and the issue was still present.

sdelafond avatar Jan 12 '18 08:01 sdelafond

Thank you for updating this issue. It is no longer marked as stale.

stale[bot] avatar Jan 12 '18 08:01 stale[bot]

@sdelafond I pinned the issue which should exempt it from the bot.

tony avatar Jan 12 '18 14:01 tony

Hi @sdelafond,

I am trying to clean up our older issues, and you are first one on the list.

I tried this tmuxp 1.3.5 (from Ubuntu repos) and our latest 1.5.1 and I received the correct results on (0 and 1) for the respective windows.

As this has been open for a while, and I cannot reproduce it, can you please let me know if you are still having this issue? If so, anymore details would be appreciated.

Thanks!

rfoliva avatar Feb 18 '19 20:02 rfoliva

Hi @rfoliva, I definitely still see the issue here.

With the test.yaml from my 1st comment, using 1.4.0, I get "0" echoed in both windows instead of "0" and "1". Same thing with 1.5.0a (FTR libtmux is 0.8.0 in that latter case).

I also tested with a brand new user having no special .bash* or .tmux.conf config files, just to make sure my own shell/tmux settings didn't interfere:

adduser foo
mkdir ~foo/.tmuxp
cat > ~foo/.tmuxp/test.yaml
...
^D
sudo -i -u foo
tmupx load test

Thanks a lot for looking into it so far :)

sdelafond avatar Feb 19 '19 07:02 sdelafond

Hi @sdelafond,

So I can try to reproduce this, would you please send the following for me?

Step 1: Provide tmuxp details

  • Python version
  • system PATH
  • tmux version
  • tmuxp version
  • tmux path
  • tmuxp path,
  • libtmux version
  • shell
  • output of tmux list-sessions, tmux list-windows, tmux list-panes
  • output of tmux show-options -g, tmux show-window-options -g
  • output of tmuxp freeze <SESSION_NAME>

Step 2: Describe your environment

  • Architecture: _____
  • OS version: _____

Thanks, Ricardo

rfoliva avatar Feb 20 '19 05:02 rfoliva

Here it is:

# uname -a
Linux foo 4.19.0-2-amd64 #1 SMP Debian 4.19.16-1 (2019-01-17) x86_64 GNU/Linux
# python -V
Python 2.7.15+
# python3 -V
Python 3.7.2+
# dpkg -l *tmux* | ...
python3-libtmux 0.8.0-1
python3-tmuxp   1.5.0a-1
tmux            2.8-2
tmuxp           1.5.0a-1
# which tmux
/bin/tmux
# which tmuxp
/bin/tmuxp
# echo $SHELL
/bin/bash
# tmux list-sessions
test: 2 windows (created Wed Feb 20 10:22:55 2019) [159x80] (attached)
# tmux list-window
0: bash* (1 panes) [159x80] [layout b83e,159x80,0,0,1] @1 (active)
1: bash- (1 panes) [159x80] [layout b83f,159x80,0,0,2] @2
# tmux list-panes
0: [159x80] [history 0/2000, 0 bytes] %1 (active)
# tmux show-options -g
activity-action other
assume-paste-time 1
base-index 0
bell-action any
default-command ""
default-shell "/bin/bash"
destroy-unattached off
detach-on-destroy on
display-panes-active-colour red
display-panes-colour blue
display-panes-time 1000
display-time 750
history-limit 2000
key-table "root"
lock-after-time 0
lock-command "lock -np"
message-command-style fg=yellow,bg=black
message-style fg=black,bg=yellow
mouse off
prefix C-b
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-interval 15
status-justify left
status-keys emacs
status-left "[#S] "
status-left-length 10
status-left-style default
status-position bottom
status-right " \"#{=21:pane_title}\" %H:%M %d-%b-%y"
status-right-length 40
status-right-style default
status-style fg=black,bg=green
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 show-window-options -g
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 blue
clock-mode-style 24
force-height 0
force-width 0
main-pane-height 24
main-pane-width 80
mode-keys emacs
mode-style fg=black,bg=yellow
monitor-activity off
monitor-bell on
monitor-silence 0
other-pane-height 0
other-pane-width 0
pane-active-border-style fg=green
pane-base-index 0
pane-border-format "#{?pane_active,#[reverse],}#{pane_index}#[default] \"#{pane_title}\""
pane-border-status off
pane-border-style default
remain-on-exit off
synchronize-panes off
window-active-style default
window-status-activity-style reverse
window-status-bell-style reverse
window-status-current-format "#I:#W#{?window_flags,#{window_flags}, }"
window-status-current-style default
window-status-format "#I:#W#{?window_flags,#{window_flags}, }"
window-status-last-style default
window-status-separator " "
window-status-style default
window-style default
wrap-search on
xterm-keys on
# tmuxp freeze test
Convert to [yaml]:
session_name: test
windows:
- focus: 'true'
  layout: b83e,159x80,0,0,1
  options: {}
  panes:
  - focus: 'true'
    shell_command: python3
  start_directory: /home/foo
  window_name: bash
- layout: b83f,159x80,0,0,2
  options: {}
  panes:
  - focus: 'true'
    shell_command: bash
  start_directory: /home/foo
  window_name: bash

The test user I created to reproduce this doesn't have any specific bash or tmux configuration, I basically just used useradd foo and then copied test.yaml under ~foo/.tmuxp

sdelafond avatar Feb 20 '19 09:02 sdelafond

@rfoliva did you have luck reproducing this with the additional information ?

sdelafond avatar Apr 01 '19 09:04 sdelafond