tmuxp icon indicating copy to clipboard operation
tmuxp copied to clipboard

ValueError: Server.colors must equal 88 or 256

Open mtrajano opened this issue 3 years ago • 17 comments

Step 1: Provide a summary of your problem

  • Example command breaking on fresh install, running tmuxp load mysession with the 4-pane-split configuration is returning the following error:
Traceback (most recent call last):
  File "/Users/trajano/Library/Python/3.9/bin/tmuxp", line 8, in <module>
    sys.exit(cli.cli())
  File "/Users/trajano/Library/Python/3.9/lib/python/site-packages/click/core.py", line 1025, in __call__
    return self.main(*args, **kwargs)
  File "/Users/trajano/Library/Python/3.9/lib/python/site-packages/click/core.py", line 955, in main
    rv = self.invoke(ctx)
  File "/Users/trajano/Library/Python/3.9/lib/python/site-packages/click/core.py", line 1517, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/trajano/Library/Python/3.9/lib/python/site-packages/click/core.py", line 1279, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/trajano/Library/Python/3.9/lib/python/site-packages/click/core.py", line 710, in invoke
    return callback(*args, **kwargs)
  File "/Users/trajano/Library/Python/3.9/lib/python/site-packages/click/decorators.py", line 18, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/Users/trajano/Library/Python/3.9/lib/python/site-packages/tmuxp/cli.py", line 959, in command_load
    load_workspace(config[-1], **tmux_options)
  File "/Users/trajano/Library/Python/3.9/lib/python/site-packages/tmuxp/cli.py", line 555, in load_workspace
    if builder.session_exists(session_name):
  File "/Users/trajano/Library/Python/3.9/lib/python/site-packages/tmuxp/workspacebuilder.py", line 102, in session_exists
    exists = self.server.has_session(session_name)
  File "/Users/trajano/Library/Python/3.9/lib/python/site-packages/libtmux/server.py", line 373, in has_session
    proc = self.cmd('has-session', '-t%s' % target_session)
  File "/Users/trajano/Library/Python/3.9/lib/python/site-packages/libtmux/server.py", line 128, in cmd
    raise ValueError('Server.colors must equal 88 or 256')
ValueError: Server.colors must equal 88 or 256

It looks like args.colors is set to a type of string which does not match the given color options. Looked into it and it seems like it's due to tmuxp pulling the pre-release version of click (8.0.0a1). I manually cloned the 7.1.2 to my site-packages and it's working again.

Need to either cast type (to be safe) and/or fix click constraint. I'm not super familiar with python but let me know if you would like me to get a pr out for this. Thanks!

Step 2: Provide tmuxp details

-------------------------
environment:
	dist: macOS-10.15.4-x86_64-i386-64bit
	arch: x86_64
	uname: Darwin; Mauricios-MacBook-Pro.local; 19.4.0
	version: Darwin Kernel Version 19.4.0: Wed Mar  4 22:28:40 PST 2020; root:xnu-6153.101.6~15/RELEASE_X86_64
-------------------------
python version: 3.9.0 (default, Nov 21 2020, 14:01:50)  [Clang 12.0.0 (clang-1200.0.32.27)]
system PATH: /Users/trajano/.nvm/versions/node/v12.18.2/bin:/Users/trajano/bin:/usr/local/bin:Library/Python/3.9/bin:/Users/trajano/.cargo/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/VMware Fusion.app/Contents/Public:/usr/local/go/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/Users/trajano/.composer/vendor/bin:/Users/trajano/.cargo/bin
tmux version: 3.1
libtmux version: 0.8.5
tmuxp version: 1.6.3
tmux path: /usr/local/bin/tmux
tmuxp path: /Users/trajano/Library/Python/3.9/lib/python/site-packages/tmuxp/__init__.py
shell: /bin/zsh
-------------------------

Step 3: Describe the problem:

Steps to reproduce:

  1. Fresh install on macOS X
  2. Copy sample 4-pane-split config and try to load sample session

Observed Results:

  • Crashed with ValueError: Server.colors must equal 88 or 256

Expected Results:

  • Loads session with the correct config

Relevant Code:

N/A

mtrajano avatar Nov 26 '20 05:11 mtrajano

Hi, im running into the very same issue

tmuxp -V ~> 1.6.3
tmux -V ~> 3.1b

alexhoo avatar Nov 27 '20 07:11 alexhoo

Hi, I am running into the same issue:

$ tmux -V
tmux 3.1c
$ tmuxp -V
tmuxp 1.6.3

diegodelemos avatar Nov 27 '20 17:11 diegodelemos

Hi, I am running into the same issue:

$ tmux -V tmux 1.8 $ tmuxp -V tmuxp 1.6.3

qiaocco avatar Dec 03 '20 06:12 qiaocco

Can confirm same issue with 1.6.3. Can confirm that you can fix it by replacing the click dependency. Since I use pipx for managing my tmuxp install, I did the following workaround:

pipx install tmuxp
cd ~/.local/pipx/venvs/tmuxp
source bin/activate
pip install click==7.1.2
<C-d> to close shell

Which patches it in the venv used for pipx.

amontalenti avatar Dec 06 '20 18:12 amontalenti

Same for me as @amontalenti. I also installed tmuxp using pipx and the tmuxp venv didn't include pip, so I installed click with

python -m pip install click==7.1.2

dougharris avatar Dec 07 '20 04:12 dougharris

I followed instructions to add click with no luck

python -m pip install click==7.1.2

still get

ValueError: Server.colors must equal 88 or 256

eduardoarandah avatar Dec 07 '20 18:12 eduardoarandah

is there any reliable way of running tmuxp without this issue? a prior version?

eduardoarandah avatar Dec 08 '20 20:12 eduardoarandah

There's a problem with the version specification of click in requirement/base.txt. See testing example in the PR I just submitted.

dougharris avatar Dec 09 '20 14:12 dougharris

Same for me as @amontalenti. I also installed tmuxp using pipx and the tmuxp venv didn't include pip, so I installed click with

python -m pip install click==7.1.2

This fixed it for me. Atleast until Dougs fix is merged

ShaunMWallace avatar Dec 12 '20 20:12 ShaunMWallace

In macOS version 11.1, what worked for me was:

pip3 install --user click==7.1.2

mauroporras avatar Dec 15 '20 05:12 mauroporras

Can confirm same issue with 1.6.3. Can confirm that you can fix it by replacing the click dependency. Since I use pipx for managing my tmuxp install, I did the following workaround:

pipx install tmuxp
cd ~/.local/pipx/venvs/tmuxp
source bin/activate
pip install click==7.1.2
<C-d> to close shell

Which patches it in the venv used for pipx.

I just ran the following command and it worked! pipx inject tmuxp click==7.1.2

BokilaLin avatar Dec 21 '20 08:12 BokilaLin

Same problem here, I am installing tmuxp in the conda base env tmuxp 1.6.3 tmux 3.0a

Forcing install of click==7.1.2 fixes the problem.

vmgustavo avatar Dec 21 '20 12:12 vmgustavo

If you try 1.6.4 or v1.7.0a4, is it any better?

tony avatar Jan 07 '21 00:01 tony

@tony I upgraded to 1.7.2 recently and this is working on my system now, thanks!

mtrajano avatar Feb 16 '21 02:02 mtrajano

Same error when system updated click to version 8 from 7.1.2 with tmuxp version 1.7.2.

Edit: been looking into this further. Yes, I am on Arch Linux. I've also filed a bug with the package at https://bugs.archlinux.org/task/70841, as tmuxp 1.7.2 does indicate appropriately that it doesn't support click 8 yet. It is possible I'll have to keep updates to python-click suppressed until support is added; not sure if pacman is clever enough to detect conflicts with semver-major package changes. Still prefer it over the glacial pace of debian-stable though :).

Iiridayn avatar May 13 '21 18:05 Iiridayn

Looks like changing line 1074 of cli.py (in command_load) from 'colors': colors, to 'colors': int(colors), fixes the issue for me. While it is frustrating that they decided to silently change default flag values to strings (presumably a side effect of part of their enhanced flag handling in https://github.com/pallets/click/pull/1618, though I don't see anything there that would change it), it is not itself unreasonable to have everything coming from the option parser be a string; so, while such a trivial change is moderately hacky, it is perhaps not unreasonably so. It would appear all other flag_values are strings already - so this would appear to be the only required change. (I also tested if I could set a flag value, but it was appropriately not recognized).

Iiridayn avatar May 14 '21 03:05 Iiridayn

This is the same issue as #678 - #679 looks like a better fix.

Iiridayn avatar May 14 '21 04:05 Iiridayn