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

misleading suggestion: python3-pygments should be pygments #116

Open
tomasohara opened this issue Sep 17, 2023 · 3 comments
Open

misleading suggestion: python3-pygments should be pygments #116

tomasohara opened this issue Sep 17, 2023 · 3 comments
Assignees

Comments

@tomasohara
Copy link

The usage for colout gives a misleading suggestion:

$ echo "fubar" | colout "fubar" Green;
[colout] ERROR: Unknown color: Green (maybe you forgot to install python3-pygments?)

$ pip install python3-pygments?
ERROR: Invalid requirement: 'python3-pygments?'

$ pip install pygments
Requirement already satisfied: pygments in ...

Note that it would be good to check for pygments before suggesting it.

@nojhan nojhan self-assigned this Oct 27, 2023
@kierun
Copy link

kierun commented Jul 16, 2024

I install colout via pipx and added the dependency. However, I still get a warning that it is not loaded:

; pipx inject --force colout Pygments
  injected package pygments into venv colout
done! ✨  🌟  ✨
√ ; date | colout ".*" red --debug
[…]
[colout] WARNING: error while executing the pygment module, syntax coloring is not available
[…]

Yet, the output is in red. If I try the same thing with a Python file, none of the output is colored.

; /usr/bin/cat src/pynpc/pynpc/console.py| colout -t python
# -*- coding: utf-8 -*-
[…]
[colout] ERROR: Unknown color: Python (maybe you forgot to install python3-pygments?)

@mcint
Copy link

mcint commented Jul 18, 2024

Noting other debug steps (and other minor errors).

That --debug flag is weakly encouraging. I've done the same pipx inject colout pygments to no effect. I've run the ~/.local/pipx/venvs/colout/bin/python, and successfully imported pygments components. Does this package, or does pipx, modify the python path in some way not overcome by the pipx inject ...?.

$ ~/.local/pipx/venvs/colout/bin/python -c 'import sys, pygments; print("\n".join(map(repr,sys.path))); print(f"{pygments.__file__=}")'
''
'/usr/lib/python310.zip'
'/usr/lib/python3.10'
'/usr/lib/python3.10/lib-dynload'
'/home/user/.local/pipx/venvs/colout/lib/python3.10/site-packages'
'/home/user/.local/pipx/shared/lib/python3.10/site-packages'
pygments.__file__='/home/user/.local/pipx/venvs/colout/lib/python3.10/site-packages/pygments/__init__.py'

I wasn't able to make use, or sense of the --source nor --resource options. Source suggested --resource all, which returned with colout: error: unrecognized arguments: all.

$ seq 3| colout .   # works, with color
1
2
3
$ seq 3| colout . --resources
$ seq 3| colout . --source
[colout] ERROR: Lexer %r is not available. Run with "--resources all" to see the options.
$ seq 3| colout . --source --resources all
usage: colout [-h] [-i] [-g] [-c] [-l SCALE] [-a] [-t] [-T DIR] [-P DIR] [-d COLORMAP] [-r] [-s] [-e CHAR] [-E CHAR] [--debug]
              REGEX [COLOR] [STYLE]
colout: error: unrecognized arguments: all

Thankfully no one is typosquatting it, but the handwritten error message makes reference to "the pygment module". I'd hate to see someone download a nasty surprise in trying to get things working.

@kierun
Copy link

kierun commented Jul 18, 2024

@nojhan Anything you need for me to debug this further, please have no hesitation to ask.

@mcint Thank you! I did not notice the potential typosquating. 😱

; pwd
/home/yg/.local/pipx/venvs/colout
√ ; rg "pygment" | rg -v pygments
pipx_metadata.json:                    "__Path__": "/home/yg/.local/pipx/venvs/colout/bin/pygmentize",
pipx_metadata.json:                "pygmentize"
pipx_metadata.json:                    "__Path__": "/home/yg/.local/pipx/venvs/colout/bin/pygmentize",
pipx_metadata.json:            "pygmentize",
lib/python3.12/site-packages/colout/colout.py:        logging.warning("error while executing the pygment module, syntax coloring is not available")

It's just a typo in the error message…

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

No branches or pull requests

4 participants