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

[bug]: ImportError: failed to find libmagic. Check your installation #1078

Open
1 of 3 tasks
ecerulm opened this issue Oct 26, 2023 · 2 comments · Fixed by #1083
Open
1 of 3 tasks

[bug]: ImportError: failed to find libmagic. Check your installation #1078

ecerulm opened this issue Oct 26, 2023 · 2 comments · Fixed by #1083
Labels

Comments

@ecerulm
Copy link

ecerulm commented Oct 26, 2023

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

#952

#951

Version (kapitan)

v0.31.0 (stable)

Version (kapitan)

I use kapitan directly (pip, docker)

Python virtual environment

  • pyenv
  • 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
/ # 
@MatteoVoges
Copy link
Contributor

Hey, thanks for the report. I've created #1083 to address this issue!

@MatteoVoges
Copy link
Contributor

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...

@MatteoVoges MatteoVoges reopened this Nov 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants