zegervdv / homebrew-zathura

Homebrew formulae to build Zathura on Mac OS X
538 stars 41 forks source link

cannot install zathura on Mac: pygments #121

Closed gheej closed 5 months ago

gheej commented 5 months ago

Hi! I use Macbook Air with MacOS Sonoma 14.4. Before updating to Sonoma my zathura installation worked, but after the update it stopped working. So I removed zathura, girara, untapped the repo, then tapped it again and tried installing zathura again with brew install zathura It fails with an error

==> Installing zathura from zegervdv/zathura
==> meson ..
==> ninja
Last 15 lines from /Users/user/Library/Logs/Homebrew/zathura/02.ninja:
../zathura/shortcuts.c:1414:29: error: incompatible integer to pointer conversion initializing 'void *' with an expression of type 'int' [-Wint-conversion]
  girara_argument_t arg = { GIRARA_HIDE, NULL };
                            ^~~~~~~~~~~
../zathura/shortcuts.c:1414:42: error: incompatible pointer to integer conversion initializing 'int' with an expression of type 'void *' [-Wint-conversion]
  girara_argument_t arg = { GIRARA_HIDE, NULL };
                                         ^~~~
/Library/Developer/CommandLineTools/usr/lib/clang/15.0.0/include/stddef.h:89:16: note: expanded from macro 'NULL'
#  define NULL ((void*)0)
               ^~~~~~~~~~
6 errors generated.
[59/68] Compiling C object libzathura.a.p/zathura_synctex.c.o
[60/68] Compiling C object libzathura.a.p/zathura_types.c.o
[61/68] Compiling C object libzathura.a.p/zathura_render.c.o
[62/68] Compiling C object libzathura.a.p/zathura_utils.c.o
ninja: build stopped: subcommand failed.

How do I install zathura?

zegervdv commented 5 months ago

I’m guessing Sonoma ships with a newer clang version which turned this kind of conversion into an error.

You could test locally by adding the -Wno-error=implicit-int flag. To do this, type brew edit zathura , then in the install method at the beginning add the line ENV.append_to_cflags “-Wno-error=implicit-int”.

Let me know if that fixes it for you.

zegervdv commented 5 months ago

Correction, that should be -Wno-error=int-conversion.

gheej commented 5 months ago

So, I've put ENV.append_to_cflags "-Wno-error=int-conversion" in the line right after def install before

    # Set Homebrew prefix
    ENV["PREFIX"] = prefix

Then I saved changes and tried installing zathura again, receiving an error

==> Installing zathura from zegervdv/zathura
==> meson ..
==> ninja
Last 15 lines from /Users/user/Library/Logs/Homebrew/zathura/02.ninja:
  File "/opt/homebrew/opt/sphinx-doc/bin/sphinx-build", line 5, in <module>
    from sphinx.cmd.build import main
  File "/opt/homebrew/Cellar/sphinx-doc/7.2.6_2/libexec/lib/python3.12/site-packages/sphinx/cmd/build.py", line 21, in <module>
    from sphinx.application import Sphinx
  File "/opt/homebrew/Cellar/sphinx-doc/7.2.6_2/libexec/lib/python3.12/site-packages/sphinx/application.py", line 21, in <module>
    from pygments.lexer import Lexer  # NoQA: TCH002
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ModuleNotFoundError: No module named 'pygments'
[61/68] Compiling C object libzathura.a.p/zathura_types.c.o
[62/68] Compiling C object libzathura.a.p/zathura_shortcuts.c.o
[63/68] Compiling C object zathura.p/zathura_main.c.o
[64/68] Compiling C object libzathura.a.p/zathura_utils.c.o
[65/68] Compiling C object libzathura.a.p/zathura_database-sqlite.c.o
[66/68] Compiling C object libzathura.a.p/zathura_zathura.c.o
ninja: build stopped: subcommand failed.

If reporting this issue please do so at (not Homebrew/brew or Homebrew/homebrew-core):
  https://github.com/zegervdv/homebrew-zathura/issues

What should I do to finally install zathura?

zegervdv commented 5 months ago

Add depends_on "pygments" => :build after the line with sphinx-doc.

gheej commented 5 months ago

Did it, seems that nothing have changed

==> Installing zathura from zegervdv/zathura
==> meson ..
==> ninja
Last 15 lines from /Users/user/Library/Logs/Homebrew/zathura/02.ninja:
/opt/homebrew/opt/sphinx-doc/bin/sphinx-build -b man -D version=0.5.2 -D release=0.5.2 /private/tmp/zathura-20240331-89649-zk86jy/zathura-0.5.2/doc/man /private/tmp/zathura-20240331-89649-zk86jy/zathura-0.5.2/build/doc
Traceback (most recent call last):
  File "/opt/homebrew/opt/sphinx-doc/bin/sphinx-build", line 5, in <module>
    from sphinx.cmd.build import main
  File "/opt/homebrew/Cellar/sphinx-doc/7.2.6_2/libexec/lib/python3.12/site-packages/sphinx/cmd/build.py", line 21, in <module>
    from sphinx.application import Sphinx
  File "/opt/homebrew/Cellar/sphinx-doc/7.2.6_2/libexec/lib/python3.12/site-packages/sphinx/application.py", line 21, in <module>
    from pygments.lexer import Lexer  # NoQA: TCH002
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ModuleNotFoundError: No module named 'pygments'
[63/68] Compiling C object libzathura.a.p/zathura_shortcuts.c.o
[64/68] Compiling C object libzathura.a.p/zathura_zathura.c.o
[65/68] Compiling C object libzathura.a.p/zathura_database-sqlite.c.o
[66/68] Compiling C object zathura.p/zathura_main.c.o
ninja: build stopped: subcommand failed.

If reporting this issue please do so at (not Homebrew/brew or Homebrew/homebrew-core):
  https://github.com/zegervdv/homebrew-zathura/issues
zegervdv commented 5 months ago

Maybe less clean, but a way to get pygments into the python environment is to run $(brew --prefix python@3.12)/bin/python3 -m pip install pygments.

gheej commented 5 months ago

When I run the above command I obtain

WARNING: The directory '/Users/user/Library/Caches/pip' or its parent directory is not owned or is not writable by the current user. The cache has been disabled. Check the permissions and owner of that directory. If executing pip with sudo, you should use sudo's -H flag.
error: externally-managed-environment

× This environment is externally managed
╰─> To install Python packages system-wide, try brew install
    xyz, where xyz is the package you are trying to
    install.

    If you wish to install a non-brew-packaged Python package,
    create a virtual environment using python3 -m venv path/to/venv.
    Then use path/to/venv/bin/python and path/to/venv/bin/pip.

    If you wish to install a non-brew packaged Python application,
    it may be easiest to use pipx install xyz, which will manage a
    virtual environment for you. Make sure you have pipx installed.

note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
hint: See PEP 668 for the detailed specification.

When I try to follow the advice of Homebrew by running brew install pygments It says pygments is already installed:

==> Downloading https://formulae.brew.sh/api/formula.jws.json
####################################################################################################################################################### 100.0%
==> Downloading https://formulae.brew.sh/api/cask.jws.json
####################################################################################################################################################### 100.0%
Warning: pygments 2.17.2 is already installed and up-to-date.
To reinstall 2.17.2, run:
  brew reinstall pygments

What to do now to install zathura?

zegervdv commented 5 months ago

You can try disabling building the docs all together by adding this back: https://github.com/zegervdv/homebrew-zathura/commit/59bbcde42f8ca21dacd39f82a7b642493ed64329

gheej commented 5 months ago

Wow, that worked! Thanks!