-
Notifications
You must be signed in to change notification settings - Fork 93
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
libgs cannot be found on python 3.8 alpine and slim images #260
Comments
Oh no, this is a source of constant pain. Can you help me debug it so I can add more workarounds and hints to the code?
diff --git a/plugins/latex2svg.py b/plugins/latex2svg.py
index c2919efd..085be7f7 100755
--- a/plugins/latex2svg.py
+++ b/plugins/latex2svg.py
@@ -71,8 +71,15 @@ if not hasattr(os.environ, 'LIBGS') and not libgs:
homebrew_libgs = '/usr/local/opt/ghostscript/lib/libgs.dylib'
if os.path.exists(homebrew_libgs):
default_params['libgs'] = homebrew_libgs
+ if sys.platform == 'linux':
+ # On Alpine Linux, find_library() may not work even though the library
+ # is in usual paths. Try some candidates before failing hard.
+ for linux_libgs in ['/usr/lib/libgs.so', '/usr/lib/libgs.so.10']:
+ if os.path.exists(linux_libgs):
+ default_params['libgs'] = linux_libgs
+ break
if not default_params['libgs']:
Thanks in advance! |
On the Alpine image:
On the slim image:
|
Hm, neither of them is really GhostScript tho :) So the error was, in fact, correct. It's usually a part of a LaTeX installation, i.e. unlikely to be present in the image by default. Here's the package in Alpine and here in Debian. If you install it explicitly, I think it could maybe work even without the patch above. Let me know if the patch is ultimately needed or not -- thanks! |
Now after proper installation on the slim image the following are installed:
It still fails. Rather annoying that the python slim image puts everything in a weird folder. |
For alpine:
Here it is properly installed in /usr/lib but I still get an error "Warning: libgs not found" while loading |
Great, can you try with the above patch now? |
Sorry, missed your other message above. Yeah, the weird This is I think what could cover both cases: diff --git a/plugins/latex2svg.py b/plugins/latex2svg.py
index c2919efd..085be7f7 100755
--- a/plugins/latex2svg.py
+++ b/plugins/latex2svg.py
@@ -71,8 +71,15 @@ if not hasattr(os.environ, 'LIBGS') and not libgs:
homebrew_libgs = '/usr/local/opt/ghostscript/lib/libgs.dylib'
if os.path.exists(homebrew_libgs):
default_params['libgs'] = homebrew_libgs
+ if sys.platform == 'linux':
+ # On certain Linux distros find_library() may not work even though the
+ # library is in usual paths. Try some candidates before failing hard.
+ for linux_libgs in [
+ '/usr/lib/libgs.so.10',
+ '/usr/lib/{}-linux-gnu/libgs.so.10'.format(os.uname().machine)
+ ]:
+ if os.path.exists(linux_libgs):
+ default_params['libgs'] = linux_libgs
+ break
if not default_params['libgs']: Let me know if this finally makes it stop complaining. Thank you! :) |
No matter whether I use python:3.8-slim or python:3.8-alpine, I keep running into issues with libgs not being found.
on
slim
:on
alpine
latex2svg simply complains that it cannot find libgs.Surprisingly, in alpine it is actually installed in a standard directory /usr/lib but
python3 -c "from ctypes.util import find_library; print(find_library('gs'))"
returns None.I am not sure how to proceed about this. Is this a configuration error? It seems using an alpine image for something like github/gitlab pages seems like something that should be working.
The text was updated successfully, but these errors were encountered: