Skip to content

libtmux is picking up the wrong tmux version #396

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
mdeguzis opened this issue Aug 11, 2022 · 14 comments
Open

libtmux is picking up the wrong tmux version #396

mdeguzis opened this issue Aug 11, 2022 · 14 comments

Comments

@mdeguzis
Copy link

mdeguzis commented Aug 11, 2022

See: tmux-python/tmuxp#794

Started new server, protocol mismatch. tmuxp seems to be using /usr/bin/tmux instead of what I have aliased.

$ tmux -V
tmux.orig 2.8

$ /usr/bin/tmux -V
tmux 1.8

The problem for me is https://github.com/tmux-python/libtmux/blob/master/libtmux/common.py#L241
Your search paths are then placing the system paths AFTER the custom patch which tmux pulls up:

241     def __init__(self, *args: t.Any, **kwargs: t.Any) -> None:
242         tmux_bin = which(
243             "tmux",
244             default_paths=kwargs.get(
245                 "tmux_search_paths",
246                 ["/bin", "/sbin", "/usr/bin", "/usr/sbin", "/usr/local/bin"],
247             ),
248             append_env_path=kwargs.get("append_env_path", True),
249         )

This really should be the other way around.

$ which tmux
tmux=/apollo/env/envImprovement/bin/tmux

I'd hate to have to fork this, so can we just perform a subprocess.run which tmux instead? Why do we need to search paths?

tmuxp:

-------------------------
environment:
        dist: Linux-5.4.204-124.362.amzn2int.x86_64-x86_64-with-glibc2.2.5
        arch: x86_64
        uname: Linux; dev-dsk-deguzim-1a-fa82568b.us-east-1.amazon.com; 5.4.204-124.362.amzn2int.x86_64
        version: #1 SMP Wed Jul 13 03:24:31 UTC 2022
-------------------------

tmux version: 1.8
libtmux version: 0.12.0
tmuxp version: 1.12.1
tmux path: /usr/bin/tmux
tmuxp path: /home/deguzim/.local/lib/python3.7/site-packages/tmuxp
shell: /bin/zsh
-------------------------
tmux sessions:

        protocol version mismatch (client 7, server 8)
tmux windows:

        protocol version mismatch (client 7, server 8)
tmux panes:

        protocol version mismatch (client 7, server 8)
tmux global options:

        protocol version mismatch (client 7, server 8)
tmux window options:

        protocol version mismatch (client 7, server 8)
@mdeguzis
Copy link
Author

mdeguzis commented Aug 11, 2022

The problem is how this code detects the version. It needs to be using regex, not list indices:

$ tmuxp freeze --force -f yaml --yes --quiet
DEBUG:
['/apollo/env/envImprovement/bin/tmux', '-V']
DEBUG:
b'tmux.orig 2.8\n'
b''

This code needs to go away in favor of regex:

version = proc.stdout[0].split("tmux ")[1]

Test

>>> ver = "tmux 1.8"
>>> import re
>>> re.search('[0-9]{1}.[0-9]', ver).group(0)
'2.8'

>>> ver = "tmux 2.3"
>>> re.search('[0-9]{1}.[0-9]', ver).group(0)
'2.3'

Tmux versions can have a letter after it as well, so this regex should work

# tmux 3.3a · tmux 3.3 · tmux 3.2a · tmux 3.2 · tmux 3.1c · tmux 3.1b · tmux
[0-9]{1}.[0-9]

Will you accept a CR for this?

@mdeguzis
Copy link
Author

Fixed tmuxp:

$ tmuxp freeze --force -f yaml --yes --quiet
Save to: /home/deguzim/.tmuxp/work.yaml [/home/deguzim/.tmuxp/work.yaml]: 

Submitted PR: #397

@tony
Copy link
Member

tony commented Aug 17, 2022

@mdeguzis can you look at the tests? Can you elaborate a bit more on the PR and what it's fixing?

How are you installing tmux? e.g. why is the name of it tmux.orig?

@mdeguzis
Copy link
Author

It's just how tmux from our company is done, I don't see why a regex that picks up the version N.N is a bad thing, it should not be using .split to pull the version and accessing an index. I have 0 problems when using version detection based on regex. Our company probably appends orig, since the system tmux exists and is very old (1.8).

As far as the tests, throwing different strings at it like tmux.orig 2.8 would be ideal.

@rockandska
Copy link
Contributor

Why do we need to search paths?

Not directly related to the issue, but I had the same concern about the reason to force the paths instead of relaying on PATH env

@tony
Copy link
Member

tony commented Aug 21, 2022

It's just how tmux from our company is done, I don't see why a regex that picks up the version N.N is a bad thing, it should not be using .split to pull the version and accessing an index. I have 0 problems when using version detection based on regex. Our company probably appends orig, since the system tmux exists and is very old (1.8).

@mdeguzis We welcome PRs that improve support and compatibility

On that note, are you still committed to doing #397? Since this is the first time I've seen this case - it needs a champion to take it to the finish line (while preserving the behavior that works)

@tony
Copy link
Member

tony commented Aug 21, 2022

@rockandska

Not directly related to the issue, but I had the same concern about the reason to force the paths instead of relaying on PATH env

I'm happy to have better support in this regard. Are you open to making a PR for this simplification?

@tony
Copy link
Member

tony commented Aug 28, 2022

@mdeguzis Does v0.15.0a1 change anything with this?

v0.15.0a1: GitHub release, git tag, PyPI package

pip install libtmux==0.15.0a1

@mdeguzis
Copy link
Author

$ pip3 install libtmux==0.15.0a1
Defaulting to user installation because normal site-packages is not writeable
Collecting libtmux==0.15.0a1
  Using cached libtmux-0.15.0a1-py3-none-any.whl (33 kB)
Installing collected packages: libtmux
  Attempting uninstall: libtmux
    Found existing installation: libtmux 0.14.2
    Uninstalling libtmux-0.14.2:
      Successfully uninstalled libtmux-0.14.2
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.                                                        
tmuxp 1.13.1 requires libtmux<0.15.0,>=0.14.0, but you have libtmux 0.15.0a1 which is incompatible.

What tag of tmuxp works for this lib version?

@tony
Copy link
Member

tony commented Aug 29, 2022

@mdeguzis

pip install libtmux==0.15.0a1 --pre

Does that work?

If not, tmux-python/tmuxp#805 may be needed

pip install --user 'git+https://github.com/tmux-python/[email protected]'
pipx install [email protected] 'tmuxp @ git+https://github.com/tmux-python/[email protected]'

@tony
Copy link
Member

tony commented Aug 29, 2022

@mdeguzis P.S. If you do above, you may need to pip uninstall libtmux and pip uninstall tmuxp first.

@mdeguzis
Copy link
Author

pip3 uninstall libtmux
pip3 uninstall tmuxp

$ pip3 install --user 'git+https://github.com/tmux-python/[email protected]'a                                                                                                        
Collecting git+https://github.com/tmux-python/[email protected]
  Cloning https://github.com/tmux-python/tmuxp.git (to revision libtmux-v0.15a) to /tmp/pip-req-build-o6j9st1k
  Running command git clone --quiet https://github.com/tmux-python/tmuxp.git /tmp/pip-req-build-o6j9st1k
  warning: You appear to have cloned an empty repository.
  WARNING: Did not find branch or tag 'libtmux-v0.15a', assuming revision or ref.
  error: subprocess-exited-with-error

  × git rev-parse HEAD did not run successfully.
  │ exit code: 128
  ╰─> [2 lines of output]
      HEAD
      fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree.
      Use '--' to separate paths from revisions, like this:
      'git <command> [<revision>...] -- [<file>...]'
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× git rev-parse HEAD did not run successfully.
│ exit code: 128
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.


$ pip3 install [email protected] 'tmuxp @ git+https://github.com/tmux-python/[email protected]'

Usage:   
  /usr/bin/python3 -m pip install [options] <requirement specifier> [package-index-options] ...
  /usr/bin/python3 -m pip install [options] -r <requirements file> [package-index-options] ...
  /usr/bin/python3 -m pip install [options] [-e] <vcs project url> ...
  /usr/bin/python3 -m pip install [options] [-e] <local project path> ...
  /usr/bin/python3 -m pip install [options] <archive url/path> ...

no such option: --suffix

In the past I would just checkout master/mainline/branch and do pip3 install -e .. I'll defer to you on what I should be running.

@tony
Copy link
Member

tony commented Aug 29, 2022

@mdeguzis Typo, trailing a:
pip3 install --user 'git+https://github.com/tmux-python/[email protected]'a

Do:
pip3 install --user 'git+https://github.com/tmux-python/[email protected]'

It's not master since it's a PR for libtmux-v0.15: tmux-python/tmuxp#805
image

libtmux v0.15 isn't in master yet

@mdeguzis
Copy link
Author

$  pip3 install --user 'git+https://github.com/tmux-python/[email protected]'
Collecting git+https://github.com/tmux-python/[email protected]
  Cloning https://github.com/tmux-python/tmuxp.git (to revision libtmux-v0.15) to /tmp/pip-req-build-7ekjpwtu
  Running command git clone --quiet https://github.com/tmux-python/tmuxp.git /tmp/pip-req-build-7ekjpwtu
  warning: You appear to have cloned an empty repository.
  WARNING: Did not find branch or tag 'libtmux-v0.15', assuming revision or ref.
  error: subprocess-exited-with-error
  
  × git rev-parse HEAD did not run successfully.
  │ exit code: 128
  ╰─> [2 lines of output]
      HEAD
      fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree.
      Use '--' to separate paths from revisions, like this:
      'git <command> [<revision>...] -- [<file>...]'
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× git rev-parse HEAD did not run successfully.
│ exit code: 128
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants