Skip to content
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

ValueError: Server.colors must equal 88 or 256 #649

Open
mtrajano opened this issue Nov 26, 2020 · 17 comments
Open

ValueError: Server.colors must equal 88 or 256 #649

mtrajano opened this issue Nov 26, 2020 · 17 comments
Labels
bug Something isn't working

Comments

@mtrajano
Copy link

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

@alexhoo
Copy link

alexhoo commented Nov 27, 2020

Hi, im running into the very same issue

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

@diegodelemos
Copy link

Hi, I am running into the same issue:

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

@qiaocco
Copy link

qiaocco commented Dec 3, 2020

Hi, I am running into the same issue:

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

@amontalenti
Copy link

amontalenti commented Dec 6, 2020

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.

@dougharris
Copy link
Contributor

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

@eduardoarandah
Copy link

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
Copy link

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

dougharris added a commit to dougharris/tmuxp that referenced this issue Dec 9, 2020
It was installing click 8.0.0.1a

Addresses tmux-python#649
@dougharris
Copy link
Contributor

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

@ShaunMWallace
Copy link

ShaunMWallace commented Dec 12, 2020

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

@mauroporras
Copy link
Contributor

In macOS version 11.1, what worked for me was:

pip3 install --user click==7.1.2

@BokilaLin
Copy link

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

@vmgustavo
Copy link

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.

tony pushed a commit that referenced this issue Jan 7, 2021
It was installing click 8.0.0.1a

Addresses #649
tony pushed a commit that referenced this issue Jan 7, 2021
It was installing click 8.0.0.1a

Addresses #649
@tony
Copy link
Member

tony commented Jan 7, 2021

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

@joseph-flinn joseph-flinn added the bug Something isn't working label Jan 18, 2021
@mtrajano
Copy link
Author

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

@Iiridayn
Copy link

Iiridayn commented May 13, 2021

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
Copy link

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 pallets/click#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 added a commit to Iiridayn/tmuxp that referenced this issue May 14, 2021
It appears click 8 decided to change `flag_value`s to strings - somewhat
reasonably. This commit is backward compatible with click 7, so I'll
leave the dependency alone til a more through evaluation can be
conducted.
@Iiridayn Iiridayn mentioned this issue May 14, 2021
@Iiridayn
Copy link

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

tony added a commit that referenced this issue Jun 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.