Can't figure out this error: Command 'krb5-config --libs gssapi' returned non-zero exit status 127

Hi all,
I’ve struggled to install the apache-airflow-providers-apache-hdfs package into Airflow - Docker 2.5.3 container on Mac.
My docker version: Docker version 20.10.17, build 100c701

I tried to include the HDFS library in the requirements.txt, and it seems to install properly. However, it seems the HDFS library requires the Kerbedos library, and it causes this error.

I’m not sure what to do to fix this error. I appreciate any help and guidance.

This is the error message:

 > [airflow-scs-airflow-worker 3/3] RUN pip install --no-cache-dir --user -r /requirements.txt;:                                                                                                                       
#0 1.691 Collecting gssapi==1.8.2                                                                                                                                                                                      
#0 1.825   Downloading gssapi-1.8.2.tar.gz (94 kB)                                                                                                                                                                     
#0 1.860      ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 94.3/94.3 kB 2.7 MB/s eta 0:00:00                                                                                                                               
#0 1.892   Installing build dependencies: started                                                                                                                                                                      
#0 6.210   Installing build dependencies: finished with status 'done'
#0 6.212   Getting requirements to build wheel: started
#0 6.487   Getting requirements to build wheel: finished with status 'error'
#0 6.491   error: subprocess-exited-with-error
#0 6.491   
#0 6.491   × Getting requirements to build wheel did not run successfully.
#0 6.491   │ exit code: 1
#0 6.491   ╰─> [21 lines of output]
#0 6.491       /bin/sh: 1: krb5-config: Permission denied
#0 6.491       Traceback (most recent call last):
#0 6.491         File "/home/airflow/.local/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
#0 6.491           main()
#0 6.491         File "/home/airflow/.local/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
#0 6.491           json_out['return_val'] = hook(**hook_input['kwargs'])
#0 6.491         File "/home/airflow/.local/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 118, in get_requires_for_build_wheel
#0 6.491           return hook(config_settings)
#0 6.491         File "/tmp/pip-build-env-zzg3__cq/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 338, in get_requires_for_build_wheel
#0 6.491           return self._get_build_requires(config_settings, requirements=['wheel'])
#0 6.491         File "/tmp/pip-build-env-zzg3__cq/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 320, in _get_build_requires
#0 6.491           self.run_setup()
#0 6.491         File "/tmp/pip-build-env-zzg3__cq/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 335, in run_setup
#0 6.491           exec(code, locals())
#0 6.491         File "<string>", line 109, in <module>
#0 6.491         File "<string>", line 22, in get_output
#0 6.491         File "/usr/local/lib/python3.10/subprocess.py", line 421, in check_output
#0 6.491           return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
#0 6.491         File "/usr/local/lib/python3.10/subprocess.py", line 526, in run
#0 6.491           raise CalledProcessError(retcode, process.args,
#0 6.491       subprocess.CalledProcessError: Command 'krb5-config --libs gssapi' returned non-zero exit status 127.
#0 6.491       [end of output]

Without seeing your Dockerfile, I can only guess, but it looks like you are running the commands as a non-root user. The airflow dockerfile uses a non-root user and you have to switch back to root every time you want to install something that requires root privileges. Here is an example:

https://airflow.apache.org/docs/docker-stack/recipes.html#apache-hadoop-stack-installation

# ...
USER 0
RUN ...
USER ${AIRFLOW_UID}

Hi @rimelek, thanks for the suggestion.

You’re correct. I missed the user as root, and I also missed heimdal-dev library.

This is my final Dockerfile:

FROM apache/airflow:2.5.3-python3.10
ADD requirements.txt .
USER root
RUN apt-get update \
  && apt-get install -y --no-install-recommends \
         gcc \
         heimdal-dev \
  && apt-get autoremove -yqq --purge \
  && apt-get clean \
  && rm -rf /var/lib/apt/lists/*
USER airflow
RUN pip install -r requirements.txt
RUN pip uninstall -y argparse

My requirements.txt file:

apache-airflow-providers-apache-hdfs==3.2.1

I got same error when manually install python packages for Airflow inside docker container.
Container image based on Ubuntu 20.04
Python version 3.8
Airflow version 2.5.3
I use the constraints-3.8.txt during image building, however, after initiate the docker container, seems most python packages not installed. So I tried to do pip3 install -r constraints-3.8.txt using root inside the docker container, then got this error while pip3 installing gssapi==1.8.2.

Please let me know what to do, really appreciate!

Hi @lmtdreamer ,

I’m not going to claim that I know the answer, or I’m an expert since I barely survived this issue a few days ago. :slight_smile:

Have you tried building docker using the Dockerfile?

I think this part of the installation fixed the Permission Denied error.
#0 6.491 /bin/sh: 1: krb5-config: Permission denied

RUN apt-get update \
  && apt-get install -y --no-install-recommends \
         gcc \
         heimdal-dev \
....

I posted the full Dockerfile that fixed my problem in the previous post.

1 Like

Hi, @dwid8 :

Thanks for your information. This DID WORK to solve the gssapi and krb5 issue.
Although I’m now encounter another issue when docker build getting to install psycopg2==2.9.5… :face_exhaling:

Thank you!