pants icon indicating copy to clipboard operation
pants copied to clipboard

"native_engine.so: Exec format error" running on alpine

Open woodyza opened this issue 8 years ago • 2 comments

Hi team,

I'm a newbie to pants trying to run a build process for a python-only (3.6.6) project inside an alpine-based docker build container. I've cobbled together the following using info from a few issues (chiefly #5642 and #4782) leading to this Dockerfile for the build:

FROM alpine:3.8

RUN apk update && apk add \
     bash \
     curl \
     gcc \
     libffi-dev \
     linux-headers \
     musl-dev \
     libressl-dev\
     python-dev

WORKDIR /pants

RUN curl -L -O https://pantsbuild.github.io/setup/pants && \
     chmod +x pants && \
     touch pants.ini && \
     sed -i -e "s|setuptools==5.4.1|setuptools==18.5|" pants && \
     ./pants -V

Which builds and bootstraps successfully, but when I mount my source into it and run something like ./pants test src/tests I get an error after the bootstrap runs (aside: why does it run again? I didn't expect that)

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   122  100   122    0     0    559      0 --:--:-- --:--:-- --:--:--   559
100   281  100   281    0     0    298      0 --:--:-- --:--:-- --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:01 --:--:--     0
100 1924k  100 1924k    0     0   977k      0  0:00:01  0:00:01 --:--:-- 4769k
New python executable in /root/.cache/pants/setup/bootstrap-Linux-x86_64/pants.ekpojc/install/bin/python2.7
Also creating executable in /root/.cache/pants/setup/bootstrap-Linux-x86_64/pants.ekpojc/install/bin/python
Installing pip, wheel...done.
Collecting pip
  Using cached https://files.pythonhosted.org/packages/5f/25/e52d3f31441505a5f3af41213346e5b6c221c9e086a166f3703d2ddaf940/pip-18.0-py2.py3-none-any.whl
Installing collected packages: pip
  Found existing installation: pip 10.0.1
    Uninstalling pip-10.0.1:
      Successfully uninstalled pip-10.0.1
Successfully installed pip-18.0
Collecting setuptools==18.5
  Using cached https://files.pythonhosted.org/packages/69/9d/e6ff1608e4308ae7c544050b58926daa4bf7764e963c09cc9f9a0bcd3728/setuptools-18.5-py2.py3-none-any.whl
Installing collected packages: setuptools
Successfully installed setuptools-18.5
Collecting pantsbuild.pants==1.7.0
Collecting pywatchman==1.4.1 (from pantsbuild.pants==1.7.0)
Collecting pyopenssl==17.3.0 (from pantsbuild.pants==1.7.0)
  Using cached https://files.pythonhosted.org/packages/24/37/89bf12e53f1d27e8b2c8e5f8f9c7a958a3905f6916a9294a57a9d83fa165/pyOpenSSL-17.3.0-py2.py3-none-any.whl
Collecting ansicolors==1.0.2 (from pantsbuild.pants==1.7.0)
Collecting twitter.common.confluence<0.4,>=0.3.1 (from pantsbuild.pants==1.7.0)
Collecting wheel==0.29.0 (from pantsbuild.pants==1.7.0)
  Using cached https://files.pythonhosted.org/packages/8a/e9/8468cd68b582b06ef554be0b96b59f59779627131aad48f8a5bce4b13450/wheel-0.29.0-py2.py3-none-any.whl
Collecting Pygments==1.4 (from pantsbuild.pants==1.7.0)
Collecting pex==1.3.2 (from pantsbuild.pants==1.7.0)
  Using cached https://files.pythonhosted.org/packages/3f/9b/f51ef7c7b11cca294aae13151aef81721a1ae965ab252c3656bf8f385356/pex-1.3.2-py2.py3-none-any.whl
Collecting six<2,>=1.9.0 (from pantsbuild.pants==1.7.0)
  Using cached https://files.pythonhosted.org/packages/67/4b/141a581104b1f6397bfa78ac9d43d8ad29a7ca43ea90a2d863fe3056e86a/six-1.11.0-py2.py3-none-any.whl
Collecting setproctitle==1.1.10 (from pantsbuild.pants==1.7.0)
Collecting subprocess32==3.2.7 (from pantsbuild.pants==1.7.0)
Collecting pystache==0.5.3 (from pantsbuild.pants==1.7.0)
Collecting pathspec==0.5.0 (from pantsbuild.pants==1.7.0)
Collecting scandir==1.2 (from pantsbuild.pants==1.7.0)
Collecting Markdown==2.1.1 (from pantsbuild.pants==1.7.0)
Collecting setuptools==30.0.0 (from pantsbuild.pants==1.7.0)
  Using cached https://files.pythonhosted.org/packages/d8/ca/dff6c67f45bff7a2ad2fd9a69ae9ebdbea742fd961f76486ae2d84517464/setuptools-30.0.0-py2.py3-none-any.whl
Collecting twitter.common.dirutil<0.4,>=0.3.1 (from pantsbuild.pants==1.7.0)
Collecting cffi==1.11.1 (from pantsbuild.pants==1.7.0)
Collecting fasteners==0.14.1 (from pantsbuild.pants==1.7.0)
  Using cached https://files.pythonhosted.org/packages/14/3a/096c7ad18e102d4f219f5dd15951f9728ca5092a3385d2e8f79a7c1e1017/fasteners-0.14.1-py2.py3-none-any.whl
Collecting packaging==16.8 (from pantsbuild.pants==1.7.0)
  Using cached https://files.pythonhosted.org/packages/87/1b/c39b7c65b5612812b83d6cab7ef2885eac9f6beb0b7b8a7071a186aea3b1/packaging-16.8-py2.py3-none-any.whl
Collecting faulthandler==2.6 (from pantsbuild.pants==1.7.0)
Collecting futures==3.0.5 (from pantsbuild.pants==1.7.0)
  Using cached https://files.pythonhosted.org/packages/9c/3f/1d818ea03fb2956a2bdfa8f8a3b1319590f0f151a5584a8a3ae45085066c/futures-3.0.5-py2-none-any.whl
Collecting requests[security]<2.19,>=2.5.0 (from pantsbuild.pants==1.7.0)
  Using cached https://files.pythonhosted.org/packages/49/df/50aa1999ab9bde74656c2919d9c0c085fd2b3775fd3eca826012bef76d8c/requests-2.18.4-py2.py3-none-any.whl
Collecting twitter.common.collections<0.4,>=0.3.1 (from pantsbuild.pants==1.7.0)
Collecting docutils<0.13,>=0.12 (from pantsbuild.pants==1.7.0)
Collecting psutil==4.3.0 (from pantsbuild.pants==1.7.0)
Collecting contextlib2==0.5.5 (from pantsbuild.pants==1.7.0)
  Using cached https://files.pythonhosted.org/packages/a2/71/8273a7eeed0aff6a854237ab5453bc9aa67deb49df4832801c21f0ff3782/contextlib2-0.5.5-py2.py3-none-any.whl
Collecting cryptography>=1.9 (from pyopenssl==17.3.0->pantsbuild.pants==1.7.0)
Collecting twitter.common.log==0.3.9 (from twitter.common.confluence<0.4,>=0.3.1->pantsbuild.pants==1.7.0)
Collecting twitter.common.lang==0.3.9 (from twitter.common.dirutil<0.4,>=0.3.1->pantsbuild.pants==1.7.0)
Collecting pycparser (from cffi==1.11.1->pantsbuild.pants==1.7.0)
Collecting monotonic>=0.1 (from fasteners==0.14.1->pantsbuild.pants==1.7.0)
  Using cached https://files.pythonhosted.org/packages/ac/aa/063eca6a416f397bd99552c534c6d11d57f58f2e94c14780f3bbf818c4cf/monotonic-1.5-py2.py3-none-any.whl
Collecting pyparsing (from packaging==16.8->pantsbuild.pants==1.7.0)
  Using cached https://files.pythonhosted.org/packages/42/47/e6d51aef3d0393f7d343592d63a73beee2a8d3d69c22b053e252c6cfacd5/pyparsing-2.2.1-py2.py3-none-any.whl
Collecting chardet<3.1.0,>=3.0.2 (from requests[security]<2.19,>=2.5.0->pantsbuild.pants==1.7.0)
  Using cached https://files.pythonhosted.org/packages/bc/a9/01ffebfb562e4274b6487b4bb1ddec7ca55ec7510b22e4c51f14098443b8/chardet-3.0.4-py2.py3-none-any.whl
Collecting certifi>=2017.4.17 (from requests[security]<2.19,>=2.5.0->pantsbuild.pants==1.7.0)
  Using cached https://files.pythonhosted.org/packages/df/f7/04fee6ac349e915b82171f8e23cee63644d83663b34c539f7a09aed18f9e/certifi-2018.8.24-py2.py3-none-any.whl
Collecting urllib3<1.23,>=1.21.1 (from requests[security]<2.19,>=2.5.0->pantsbuild.pants==1.7.0)
  Using cached https://files.pythonhosted.org/packages/63/cb/6965947c13a94236f6d4b8223e21beb4d576dc72e8130bd7880f600839b8/urllib3-1.22-py2.py3-none-any.whl
Collecting idna<2.7,>=2.5 (from requests[security]<2.19,>=2.5.0->pantsbuild.pants==1.7.0)
  Using cached https://files.pythonhosted.org/packages/27/cc/6dd9a3869f15c2edfab863b992838277279ce92663d334df9ecf5106f5c6/idna-2.6-py2.py3-none-any.whl
Collecting enum34; python_version < "3" (from cryptography>=1.9->pyopenssl==17.3.0->pantsbuild.pants==1.7.0)
  Using cached https://files.pythonhosted.org/packages/c5/db/e56e6b4bbac7c4a06de1c50de6fe1ef3810018ae11732a50f15f62c7d050/enum34-1.1.6-py2-none-any.whl
Collecting asn1crypto>=0.21.0 (from cryptography>=1.9->pyopenssl==17.3.0->pantsbuild.pants==1.7.0)
  Using cached https://files.pythonhosted.org/packages/ea/cd/35485615f45f30a510576f1a56d1e0a7ad7bd8ab5ed7cdc600ef7cd06222/asn1crypto-0.24.0-py2.py3-none-any.whl
Collecting ipaddress; python_version < "3" (from cryptography>=1.9->pyopenssl==17.3.0->pantsbuild.pants==1.7.0)
  Using cached https://files.pythonhosted.org/packages/fc/d0/7fc3a811e011d4b388be48a0e381db8d990042df54aa4ef4599a31d39853/ipaddress-1.0.22-py2.py3-none-any.whl
Collecting twitter.common.options==0.3.9 (from twitter.common.log==0.3.9->twitter.common.confluence<0.4,>=0.3.1->pantsbuild.pants==1.7.0)
Installing collected packages: pywatchman, enum34, pycparser, cffi, asn1crypto, idna, six, ipaddress, cryptography, pyopenssl, ansicolors, twitter.common.options, twitter.common.lang, twitter.common.dirutil, twitter.common.log, twitter.common.confluence, wheel, Pygments, setuptools, pex, setproctitle, subprocess32, pystache, pathspec, scandir, Markdown, monotonic, fasteners, pyparsing, packaging, faulthandler, futures, chardet, certifi, urllib3, requests, twitter.common.collections, docutils, psutil, contextlib2, pantsbuild.pants
  Found existing installation: wheel 0.31.1
    Uninstalling wheel-0.31.1:
      Successfully uninstalled wheel-0.31.1
  Found existing installation: setuptools 18.5
    Uninstalling setuptools-18.5:
      Successfully uninstalled setuptools-18.5
Successfully installed Markdown-2.1.1 Pygments-1.4 ansicolors-1.0.2 asn1crypto-0.24.0 certifi-2018.8.24 cffi-1.11.1 chardet-3.0.4 contextlib2-0.5.5 cryptography-2.3.1 docutils-0.12 enum34-1.1.6 fasteners-0.14.1 faulthandler-2.6 futures-3.0.5 idna-2.6 ipaddress-1.0.22 monotonic-1.5 packaging-16.8 pantsbuild.pants-1.7.0 pathspec-0.5.0 pex-1.3.2 psutil-4.3.0 pycparser-2.18 pyopenssl-17.3.0 pyparsing-2.2.1 pystache-0.5.3 pywatchman-1.4.1 requests-2.18.4 scandir-1.2 setproctitle-1.1.10 setuptools-30.0.0 six-1.11.0 subprocess32-3.2.7 twitter.common.collections-0.3.9 twitter.common.confluence-0.3.9 twitter.common.dirutil-0.3.9 twitter.common.lang-0.3.9 twitter.common.log-0.3.9 twitter.common.options-0.3.9 urllib3-1.22 wheel-0.29.0
DEBUG] Target alias resources has already been registered. Overwriting!
DEBUG] using engine_version: fd8272e8168abaecde3d599332ab7b6b5b2ae437 built at repo_version: release_1.7.0rc1-2-g6019718
DEBUG] loading native engine python module from: /tmp/tmpSqXmvu
Exception caught: (<type 'exceptions.ImportError'>)

Exception message: Error loading shared library /tmp/tmpSqXmvu/native_engine.so: Exec format error

This is my pants.ini:

[DEFAULT]
python_source_paths: ['src/my_project_sources']
python_lib_paths: ['3rdparty']

[GLOBAL]
pants_version: 1.7.0

plugins: [
          'pantsbuild.pants.contrib.mypy==%(pants_version)s',
          'pantsbuild.pants.contrib.python.checks==%(pants_version)s',
        ]

backend_packages: [
    # Pants built-ins:
    'pants.backend.codegen.thrift.python',
    'pants.backend.graph_info',
    'pants.backend.python',
    'pants.backend.native',
  ]

[python-setup]
interpreter_constraints: ["CPython==3.6.6"]

[test.pytest]
junit_xml_dir: .build/test-results

[mypy]
mypy_version: 0.610

Any ideas what I'm doing wrong? It all works locally (OSX) so fairly sure the build itself is ok, and I'm missing something in the image setup. I've tried various versions of alpine (3.4-3.8) without success.

woodyza avatar Sep 19 '18 03:09 woodyza

The issue here is we don't release a Linux binary for Alpine / libmusl. We could add this to our build / release process, but there is some non-trivial overhead to doing so. Is there any chance you could switch to a non libmusl distro image? Ubuntu 18.04 is semi-slim for example.

jsirois avatar Sep 19 '18 03:09 jsirois

Thanks for the quick response! Sure I'll have a crack at that, alpine was always just my default base for python images before - Ubuntu 18.04 looks like it'd be small enough.

woodyza avatar Sep 19 '18 03:09 woodyza