Package libffi was not found in the pkg-config search path

  • 본인 개발 환경에서는 docker-compose build시 아무런 문제가 없는데, 막상 가상서버에서 docker-compose build를 하면 cffi 빌드 문제가 발생하는 경우가 있습니다.
  • 에러 메시지는 아래와 같습니다.

debug log

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
#11 10.05   Building wheels for collected packages: cffi
#11 10.05     Building wheel for cffi (setup.py): started
#11 10.05     Building wheel for cffi (setup.py): finished with status 'error'
#11 10.05     ERROR: Command errored out with exit status 1:
#11 10.05      command: /usr/local/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-lt5a4gm7/cffi_f02ff5d2648d42c398bfaa5f9587d9a1/setup.py'"'"'; __file__='"'"'/tmp/pip-install-lt5a4gm7/cffi_f02ff5d2648d42c398bfaa5f9587d9a1/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-m5z8su85
#11 10.05          cwd: /tmp/pip-install-lt5a4gm7/cffi_f02ff5d2648d42c398bfaa5f9587d9a1/
#11 10.05     Complete output (58 lines):
#11 10.05     Package libffi was not found in the pkg-config search path.
#11 10.05     Perhaps you should add the directory containing `libffi.pc'
#11 10.05     to the PKG_CONFIG_PATH environment variable
#11 10.05     Package 'libffi', required by 'virtual:world', not found
#11 10.05     Package libffi was not found in the pkg-config search path.
#11 10.05     Perhaps you should add the directory containing `libffi.pc'

해결

  • 가상 서버에는 libffi-dev가 설치되어 있지 않아서 그렇습니다.
  • Dockerfile 패키지 설치작업에 libffi-dev 를 추가하면 해결됩니다.
1
RUN apk add postgresql-dev gcc python3-dev musl-dev zlib-dev jpeg-dev libffi-dev