kapitan
kapitan copied to clipboard
[bug]: ImportError: failed to find libmagic. Check your installation
Description of the bug
If libmagic is not installed you get an ImportError
,
I think it should be reported some other way, preferibably it should say that it's missing at pip install
time. Or preferably install it automatically somehow.
I see that there was some work for that but it doesn seem to work on alpine at least , see the steps to reproduce below
Steps to reproduce
docker run --rm -ti alpine:3.18
apk add git gettext helm curl python3 python3-dev py3-pip make g++ go
python -m venv kapitan-venv
source kapitan-venv/bin/activate
pip install -U pip
pip install -U kapitan
kapitan
ImportError: failed to find libmagic. Check your installation
Then if I manually install libmagic
it works:
apk add libmagic
kapitan
usage: kapitan [-h] [--version] {eval,e,compile,c,inventory,i,searchvar,sv,secrets,s,refs,r,lint,l,init,validate,v} ...
What happened?
I got an ImportError because libmagic is missing.
I would expect an error at pip install
time not a runtime. Or mention in the documentation.
Additional context
https://github.com/kapicorp/kapitan/issues/952
https://github.com/kapicorp/kapitan/pull/951
Version (kapitan)
v0.31.0 (stable)
Version (kapitan)
I use kapitan directly (pip, docker)
Python virtual environment
- [ ] pyenv
- [X] venv
- [ ] no environment
OS information
Alpine 3.18
Relevant log output
kapitan -v
Traceback (most recent call last):
File "/root/.local/bin/kapitan", line 5, in <module>
from kapitan.cli import main
File "/root/.local/lib/python3.11/site-packages/kapitan/cli.py", line 23, in <module>
from kapitan.inputs.jsonnet import jsonnet_file
File "/root/.local/lib/python3.11/site-packages/kapitan/inputs/jsonnet.py", line 14, in <module>
from kapitan.inputs.base import CompiledFile, InputType
File "/root/.local/lib/python3.11/site-packages/kapitan/inputs/base.py", line 19, in <module>
from kapitan.refs.base import Revealer
File "/root/.local/lib/python3.11/site-packages/kapitan/refs/base.py", line 23, in <module>
from kapitan.utils import PrettyDumper, list_all_paths
File "/root/.local/lib/python3.11/site-packages/kapitan/utils.py", line 12, in <module>
import magic
File "/root/.local/lib/python3.11/site-packages/magic/__init__.py", line 209, in <module>
libmagic = loader.load_lib()
^^^^^^^^^^^^^^^^^
File "/root/.local/lib/python3.11/site-packages/magic/loader.py", line 49, in load_lib
raise ImportError('failed to find libmagic. Check your installation')
ImportError: failed to find libmagic. Check your installation
/ #
Hey, thanks for the report. I've created #1083 to address this issue!
Reopening again, because the fix was reverted, and it shouldn't be the case to have kapitan not working after installing the dependencies. Also you shouldn't have to install specific dependencies manually afterwards...