Open mdeguzis opened 2 years ago
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?
Fixed tmuxp:
$ tmuxp freeze --force -f yaml --yes --quiet
Save to: /home/deguzim/.tmuxp/work.yaml [/home/deguzim/.tmuxp/work.yaml]:
Submitted PR: https://github.com/tmux-python/libtmux/pull/397
@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
?
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.
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
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)
@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?
@mdeguzis Does v0.15.0a1 change anything with this?
v0.15.0a1: GitHub release, git tag, PyPI package
pip install libtmux==0.15.0a1
$ 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?
@mdeguzis
pip install libtmux==0.15.0a1 --pre
Does that work?
If not, https://github.com/tmux-python/tmuxp/pull/805 may be needed
pip install --user 'git+https://github.com/tmux-python/tmuxp.git@libtmux-v0.15'
pipx install --suffix=@libtmux-v0.15 'tmuxp @ git+https://github.com/tmux-python/tmuxp.git@libtmux-v0.15'
@mdeguzis P.S. If you do above, you may need to pip uninstall libtmux
and pip uninstall tmuxp
first.
pip3 uninstall libtmux
pip3 uninstall tmuxp
$ pip3 install --user 'git+https://github.com/tmux-python/tmuxp.git@libtmux-v0.15'a
Collecting git+https://github.com/tmux-python/tmuxp.git@libtmux-v0.15a
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 --suffix=@libtmux-v0.15 'tmuxp @ git+https://github.com/tmux-python/tmuxp.git@libtmux-v0.15'
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.
@mdeguzis Typo, trailing a:
pip3 install --user 'git+https://github.com/tmux-python/tmuxp.git@libtmux-v0.15'a
Do:
pip3 install --user 'git+https://github.com/tmux-python/tmuxp.git@libtmux-v0.15'
It's not master since it's a PR for libtmux-v0.15
: https://github.com/tmux-python/tmuxp/pull/805
libtmux v0.15 isn't in master yet
$ pip3 install --user 'git+https://github.com/tmux-python/tmuxp.git@libtmux-v0.15'
Collecting git+https://github.com/tmux-python/tmuxp.git@libtmux-v0.15
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.
See: https://github.com/tmux-python/tmuxp/issues/794
Started new server, protocol mismatch. tmuxp seems to be using /usr/bin/tmux instead of what I have aliased.
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:This really should be the other way around.
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: