bioconda / bioconda-recipes

Conda recipes for the bioconda channel.
https://bioconda.github.io
MIT License
1.64k stars 3.27k forks source link

Missing libGL error in circleci build #13974

Closed nfahlgren closed 5 years ago

nfahlgren commented 5 years ago

Hi all, I'm working on updating the plantcv recipe and I'm hitting an error I can't quite figure out. Steps I have taken:

With the recipe conda solves the following environment:

The following NEW packages will be INSTALLED:

    atk:                   2.25.90-hb9dd440_1002                 conda-forge
    blas:                  1.1-openblas                          conda-forge
    bzip2:                 1.0.6-h14c3975_1002                   conda-forge
    ca-certificates:       2018.11.29-ha4d7672_0                 conda-forge
    cairo:                 1.16.0-ha4e643d_1000                  conda-forge
    certifi:               2018.11.29-py37_1000                  conda-forge
    cloudpickle:           0.8.0-py_0                            conda-forge
    cycler:                0.10.0-py_1                           conda-forge
    cytoolz:               0.9.0.1-py37h14c3975_1001             conda-forge
    dask-core:             1.1.3-py_0                            conda-forge
    dbus:                  1.13.0-h4e0c4b3_1000                  conda-forge
    decorator:             4.3.2-py_0                            conda-forge
    descartes:             1.1.0-py_2                            conda-forge
    expat:                 2.2.5-hf484d3e_1002                   conda-forge
    ffmpeg:                4.1-h6dce934_1002                     conda-forge
    fontconfig:            2.13.1-h2176d3f_1000                  conda-forge
    freetype:              2.9.1-h94bbf69_1005                   conda-forge
    gdk-pixbuf:            2.36.12-h49783d7_1002                 conda-forge
    gettext:               0.19.8.1-h9745a5d_1001                conda-forge
    giflib:                5.1.4-h14c3975_1001                   conda-forge
    glib:                  2.58.3-hf63aee3_1001                  conda-forge
    gmp:                   6.1.2-hf484d3e_1000                   conda-forge
    gnutls:                3.6.5-hd3a4fd2_1001                   conda-forge
    gobject-introspection: 1.58.2-py37h2da5eee_1000              conda-forge
    graphite2:             1.3.13-hf484d3e_1000                  conda-forge
    gstreamer:             1.14.4-h66beb1c_1001                  conda-forge
    gtk2:                  2.24.31-hb68c50a_1001                 conda-forge
    harfbuzz:              2.3.1-h6824563_0                      conda-forge
    hdf5:                  1.10.4-nompi_h11e915b_1105            conda-forge
    icu:                   58.2-hf484d3e_1000                    conda-forge
    imageio:               2.5.0-py37_0                          conda-forge
    jasper:                1.900.1-h07fcdf6_1006                 conda-forge
    jpeg:                  9c-h14c3975_1001                      conda-forge
    kiwisolver:            1.0.1-py37h6bb024c_1002               conda-forge
    lame:                  3.100-h14c3975_1001                   conda-forge
    libffi:                3.2.1-hf484d3e_1005                   conda-forge
    libgcc-ng:             7.3.0-hdf63c60_0                      conda-forge
    libgfortran-ng:        7.2.0-hdf63c60_3                      conda-forge
    libiconv:              1.15-h14c3975_1004                    conda-forge
    libpng:                1.6.36-h84994c4_1000                  conda-forge
    libstdcxx-ng:          7.3.0-hdf63c60_0                      conda-forge
    libtiff:               4.0.10-h648cc4a_1001                  conda-forge
    libuuid:               2.32.1-h14c3975_1000                  conda-forge
    libwebp:               1.0.2-h576950b_1                      conda-forge
    libxcb:                1.13-h14c3975_1002                    conda-forge
    libxml2:               2.9.8-h143f9aa_1005                   conda-forge
    matplotlib:            3.0.3-py37_0                          conda-forge
    matplotlib-base:       3.0.3-py37h167e16e_0                  conda-forge
    mizani:                0.5.3-py_0                            conda-forge
    ncurses:               6.1-hf484d3e_1002                     conda-forge
    nettle:                3.4.1-h1bed415_1002                   conda-forge
    networkx:              2.2-py_1                              conda-forge
    numpy:                 1.16.2-py37_blas_openblash1522bff_0   conda-forge [blas_openblas]
    olefile:               0.46-py_0                             conda-forge
    openblas:              0.3.3-h9ac9557_1001                   conda-forge
    opencv:                3.4.4-py37_blas_openblash26fe798_1204 conda-forge [blas_openblas]
    openh264:              1.8.0-hdbcaa40_1000                   conda-forge
    openssl:               1.0.2r-h14c3975_0                     conda-forge
    palettable:            3.1.1-py_0                            conda-forge
    pandas:                0.24.1-py37hf484d3e_0                 conda-forge
    pango:                 1.40.14-h4ea9474_1004                 conda-forge
    patsy:                 0.5.1-py_0                            conda-forge
    pcre:                  8.41-hf484d3e_1003                    conda-forge
    pillow:                5.4.1-py37h00a061d_1000               conda-forge
    pip:                   19.0.3-py37_0                         conda-forge
    pixman:                0.34.0-h14c3975_1003                  conda-forge
    plantcv:               3.2.0-py_0                            local
    plotnine:              0.5.1-py_0                            conda-forge
    pthread-stubs:         0.4-h14c3975_1001                     conda-forge
    pyparsing:             2.3.1-py_0                            conda-forge
    pyqt:                  5.6.0-py37h13b7fb3_1008               conda-forge
    python:                3.7.1-hd21baee_1001                   conda-forge
    python-dateutil:       2.8.0-py_0                            conda-forge
    pytz:                  2018.9-py_0                           conda-forge
    pywavelets:            1.0.2-py37h3010b51_0                  conda-forge
    qt:                    5.6.2-hce4f676_1013                   conda-forge
    readline:              7.0-hf8c457e_1001                     conda-forge
    scikit-image:          0.14.2-py37hf484d3e_1                 conda-forge
    scipy:                 1.2.1-py37_blas_openblash1522bff_0    conda-forge [blas_openblas]
    setuptools:            40.8.0-py37_0                         conda-forge
    sip:                   4.18.1-py37hf484d3e_1000              conda-forge
    six:                   1.12.0-py37_1000                      conda-forge
    sqlite:                3.26.0-h67949de_1001                  conda-forge
    statsmodels:           0.9.0-py37h3010b51_1000               conda-forge
    tk:                    8.6.9-h84994c4_1000                   conda-forge
    toolz:                 0.9.0-py_1                            conda-forge
    tornado:               6.0.1-py37h14c3975_0                  conda-forge
    wheel:                 0.33.1-py37_0                         conda-forge
    x264:                  1!152.20180717-h14c3975_1001          conda-forge
    xorg-kbproto:          1.0.7-h14c3975_1002                   conda-forge
    xorg-libice:           1.0.9-h14c3975_1004                   conda-forge
    xorg-libsm:            1.2.3-h4937e3b_1000                   conda-forge
    xorg-libx11:           1.6.7-h14c3975_1000                   conda-forge
    xorg-libxau:           1.0.9-h14c3975_0                      conda-forge
    xorg-libxdmcp:         1.1.2-h14c3975_1007                   conda-forge
    xorg-libxext:          1.3.3-h14c3975_1004                   conda-forge
    xorg-libxrender:       0.9.10-h14c3975_1002                  conda-forge
    xorg-libxt:            1.1.5-h14c3975_1002                   conda-forge
    xorg-renderproto:      0.11.1-h14c3975_1002                  conda-forge
    xorg-xextproto:        7.3.0-h14c3975_1002                   conda-forge
    xorg-xproto:           7.0.31-h14c3975_1007                  conda-forge
    xz:                    5.2.4-h14c3975_1001                   conda-forge
    zlib:                  1.2.11-h14c3975_1004                  conda-forge

The build returns the following error:

import: 'plantcv'
import: 'plantcv.learn'
Traceback (most recent call last):
  File "/opt/conda/conda-bld/plantcv_1552107768315/test_tmp/run_test.py", line 5, in <module>
    import plantcv.learn
  File "/opt/conda/conda-bld/plantcv_1552107768315/_test_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_pl/lib/python3.7/site-packages/plantcv/learn/__init__.py", line 7, in <module>
    from plantcv.learn.naive_bayes import naive_bayes
  File "/opt/conda/conda-bld/plantcv_1552107768315/_test_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_pl/lib/python3.7/site-packages/plantcv/learn/naive_bayes.py", line 4, in <module>
    import cv2
ImportError: libGL.so.1: cannot open shared object file: No such file or directory
Tests failed for plantcv-3.2.0-py_0.tar.bz2 - moving package to /opt/conda/conda-bld/broken
WARNING:conda_build.build:Tests failed for plantcv-3.2.0-py_0.tar.bz2 - moving package to /opt/conda/conda-bld/broken
TESTS FAILED: plantcv-3.2.0-py_0.tar.bz2

So this looks like OpenCV is looking for libGL but doesn't find it. From some older issues (e.g. #489) it sounds like libGL is meant to be provided at the system level and not as a conda package. I'm not sure if there's something I can specify in the recipe, if this has to do with mesa-libGLU-devel in the build environment, if it's an issue with OpenCV in conda-forge, or something else.

Any thoughts? Much appreciated!

PertuyF commented 5 years ago

You may find interesting things in conda-forge documentation. Not sure it will solve, but it could help.

nfahlgren commented 5 years ago

Thanks @PertuyF! That is a really useful link. It seems to me like the libGL stuff should be taken care of in the OpenCV conda-forge package, and indeed they have the configuration discussed in the conda-forge documentation in their recipe: https://github.com/conda-forge/opencv-feedstock/tree/master/recipe.

I tried various forms of adding yum_dependencies.txt with mesa-libGL or mesa-libGL-devel and separately also adding the libGL packages to the build requirements, but none of those things changed the test result of circleci build. I always get the error:

ImportError: libGL.so.1: cannot open shared object file: No such file or directory

Here's a link to my configuration files with the last updates I tried: https://github.com/bioconda/bioconda-recipes/tree/update-plantcv-3.2.0/recipes/plantcv

PertuyF commented 5 years ago

From what I understand, you need to add {{ cdt('mesa-libgl-devel') }} # [linux] to your build requirements. Then likely set a yum_requirements.txt for mesa-libGL so that the tests will be able to access this library.

I think this is a workaround to allow conda packages to depend on system-level libraries. It is done for openCV at build time, and likely it should be done for building any package that depends on openCV as well, as these libs aren't included in the docker image.

But note I'm not an expert on this part, it is just based on deduction and experimentation.

nfahlgren commented 5 years ago

Thanks @PertuyF, the last iteration I tried looked like this but didn't work:

meta.yml:

{% set name = "plantcv" %}
{% set version = "3.2.0" %}
{% set file_ext = "tar.gz" %}
{% set hash_type = "sha256" %}
{% set hash_value = "a2800a9749d66f6376a8e05939979ed185daf5aa63cbbaefef99c26da4ca0c1e" %}

package:
  name: '{{ name|lower }}'
  version: '{{ version }}'

source:
  url: https://pypi.io/packages/source/{{ name[0] }}/{{ name }}/{{ name }}-{{ version }}.{{ file_ext }}
  '{{ hash_type }}': '{{ hash_value }}'

build:
  noarch: python
  number: 0

requirements:
  build:
    - {{ cdt('mesa-libgl-devel') }}  # [linux]
    - {{ cdt('mesa-dri-drivers') }}  # [linux]
    - {{ cdt('libselinux') }}  # [linux]
    - {{ cdt('libxdamage') }}  # [linux]
    - {{ cdt('libxxf86vm') }}  # [linux]
  host:
    - python
    - pip
  run:
    - python
    - matplotlib >=1.5
    - numpy >=1.11
    - pandas
    - python-dateutil
    - scipy
    - scikit-image
    - plotnine
    - opencv <4

test:
  imports:
    - plantcv
    - plantcv.learn
    - plantcv.plantcv
    - plantcv.plantcv.roi
    - plantcv.plantcv.threshold
    - plantcv.plantcv.transform

about:
  home: https://plantcv.danforthcenter.org
  license: MIT License
  license_family: MIT
  license_file: 'LICENSE'
  summary: An image processing package for plant phenotyping.
  description: "PlantCV is a Python package for building modular image analysis workflows for plant phenotyping."
  doc_url: 'https://plantcv.readthedocs.io'
  dev_url: 'https://github.com/danforthcenter/plantcv'

extra:
  recipe-maintainers: 'PlantCV team'
  identifiers:
    - doi:10.1016/j.molp.2015.06.005
    - doi:10.1109/WNYIPW.2016.7904790
    - doi:10.7717/peerj.4088
    - doi:10.7717/peerj.5727

yum_requirements.txt:

mesa-libGL
mesa-dri-drivers
libselinux
libXdamage
libXxf86vm
PertuyF commented 5 years ago

Last error is because libjasper cannot be found, so likely the mesa-libGL issue is resolved?

nfahlgren commented 5 years ago

Something I missed in the documentation is using the extended container: https://bioconda.github.io/troubleshooting.html#using-the-extended-image. A specific use case is when you need libGL.so.1. Adding

extra:
  container:
    extended-base: true

did not fix a local circleci build for me but I'm thinking that's because I would need to pull the extended Docker container. I went ahead and submitted a pull request #14002 to test in CircleCI directly.

nfahlgren commented 5 years ago

I am totally stuck at this point. Local testing is not working for me at all. To get away from potentially clashing environments on my MacBook I created a clean AWS instance to work in. I installed git and docker, cloned the bioconda-recipes repo and updated the plantcv recipe (just bumping the version number only). I then follow the testing instructions at https://bioconda.github.io/contribute-a-recipe.html#test-locally

This pulls the container successfully: docker pull bioconda/bioconda-utils-build-env

This installs the circleci client correctly: sudo curl -fLSs https://circle.ci/cli | bash

Running circleci build in the bioconda-recipes fails:

Docker image digest: sha256:0f93072c4564ac0992ed5fe4f1c33f4c39ad58c56ea811a7dc59f02be99d2594
====>> Spin up Environment
Build-agent version 1.0.8916-7902072c (2019-03-12T16:48:37+0000)
Starting container bioconda/bioconda-utils-build-env
  using image bioconda/bioconda-utils-build-env@sha256:c93c972a7ed72fa0bc203fa901ad43262398aae67e35ef25c5a62f6f37776a83

Using build environment variables
  BASH_ENV=/tmp/.bash_env-localbuild-1552414108
  CI=true
  CIRCLECI=true
  CIRCLE_BRANCH=master
  CIRCLE_BUILD_NUM=
  CIRCLE_JOB=build
  CIRCLE_NODE_INDEX=0
  CIRCLE_NODE_TOTAL=1
  CIRCLE_REPOSITORY_URL=https://github.com/bioconda/bioconda-recipes.git
  CIRCLE_SHA1=aea75b2f5896f34af33ad50de5421e15ec7d555f
  CIRCLE_SHELL_ENV=/tmp/.bash_env-localbuild-1552414108
  CIRCLE_WORKING_DIRECTORY=~/project

====>> Checkout code
  #!/bin/bash -eo pipefail
mkdir -p /root/project && cd /tmp/_circleci_local_build_repo && git ls-files -z | xargs -0 tar -c | tar -x -C /root/project && cp -a /tmp/_circleci_local_build_repo/.git /root/project
/bin/bash: git: command not found
tar: Cowardly refusing to create an empty archive
Try `tar --help' or `tar --usage' for more information.
tar: This does not look like a tar archive
tar: Exiting with failure status due to previous errors
Error: Exited with code 2
Step failed
Error: runner failed
{"Runner":true,"level":"error","msg":"runner failed","task-id":"localbuild-1552414108","time":"2019-03-12T18:08:30Z"}
Task failed
Error: task failed

If I try the boostrap method instead:

Creating the miniconda environment works:

./bootstrap.py /tmp/miniconda
source ~/.config/bioconda/activate

Linting works: bioconda-utils lint recipes config.yml --git-range master

Mulled tests fail because the tmp-bioconda-builder cannot be created? bioconda-utils build recipes config.yml --docker --mulled-test --git-range master

18:12:01 BIOCONDA INFO Recipes newly unblacklisted:

18:12:01 BIOCONDA INFO Recipes modified according to git: plantcv
18:12:26 BIOCONDA INFO DOCKER: Building image "tmp-bioconda-builder" from /tmp/tmpqq3_8e9q
..............................18:51:41 BIOCONDA ERROR COMMAND FAILED: docker build --network host -t tmp-bioconda-builder /tmp/tmpqq3_8e9q
18:51:41 BIOCONDA ERROR STDOUT+STDERR:
Sending build context to Docker daemon  3.584kB
Step 1/2 : FROM bioconda/bioconda-utils-build-env:2019-02-01
 ---> 15419aba89cc
Step 2/2 : RUN /opt/conda/bin/conda install -y conda=4.5.11 conda-build=3.15.1
 ---> Running in 3144594c1580
Solving environment: ...working... The command '/bin/sh -c /opt/conda/bin/conda install -y conda=4.5.11 conda-build=3.15.1' returned a non-zero code: 137

18:51:41 BIOCONDA ERROR DOCKER FAILED: Error building docker container tmp-bioconda-builder.
Traceback (most recent call last):
  File "/tmp/miniconda/miniconda/bin/bioconda-utils", line 10, in <module>
    sys.exit(main())
  File "/tmp/miniconda/miniconda/lib/python3.6/site-packages/bioconda_utils/cli.py", line 840, in main
    bioconductor_skeleton, clean_cran_skeleton, autobump
  File "/tmp/miniconda/miniconda/lib/python3.6/site-packages/argh/dispatching.py", line 328, in dispatch_commands
    dispatch(parser, *args, **kwargs)
  File "/tmp/miniconda/miniconda/lib/python3.6/site-packages/argh/dispatching.py", line 174, in dispatch
    for line in lines:
  File "/tmp/miniconda/miniconda/lib/python3.6/site-packages/argh/dispatching.py", line 277, in _execute_command
    for line in result:
  File "/tmp/miniconda/miniconda/lib/python3.6/site-packages/argh/dispatching.py", line 260, in _call
    result = function(*positional, **keywords)
  File "<boltons.funcutils.FunctionBuilder-2>", line 2, in build
  File "/tmp/miniconda/miniconda/lib/python3.6/site-packages/bioconda_utils/cli.py", line 41, in wrapper
    func(*args, **kwargs)
  File "/tmp/miniconda/miniconda/lib/python3.6/site-packages/bioconda_utils/cli.py", line 430, in build
    keep_image=keep_image,
  File "/tmp/miniconda/miniconda/lib/python3.6/site-packages/bioconda_utils/docker_utils.py", line 349, in __init__
    self._build_image(image_build_dir)
  File "/tmp/miniconda/miniconda/lib/python3.6/site-packages/bioconda_utils/docker_utils.py", line 430, in _build_image
    raise e
  File "/tmp/miniconda/miniconda/lib/python3.6/site-packages/bioconda_utils/docker_utils.py", line 425, in _build_image
    p = utils.run(cmd, mask=False)
  File "/tmp/miniconda/miniconda/lib/python3.6/site-packages/bioconda_utils/utils.py", line 427, in run
    raise e
  File "/tmp/miniconda/miniconda/lib/python3.6/site-packages/bioconda_utils/utils.py", line 407, in run
    **kwargs)
  File "/tmp/miniconda/miniconda/lib/python3.6/subprocess.py", line 418, in run
    output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['docker', 'build', '--network', 'host', '-t', 'tmp-bioconda-builder', '/tmp/tmpqq3_8e9q']' returned non-zero exit status 137.
18:51:43 BIOCONDA ERROR COMMAND FAILED: docker rmi tmp-bioconda-builder
18:51:43 BIOCONDA ERROR STDOUT+STDERR:
Error: No such image: tmp-bioconda-builder

Exception ignored in: <bound method RecipeBuilder.__del__ of <bioconda_utils.docker_utils.RecipeBuilder object at 0x7ff25335f400>>
Traceback (most recent call last):
  File "/tmp/miniconda/miniconda/lib/python3.6/site-packages/bioconda_utils/docker_utils.py", line 358, in __del__
    self.cleanup()
  File "/tmp/miniconda/miniconda/lib/python3.6/site-packages/bioconda_utils/docker_utils.py", line 510, in cleanup
    utils.run(cmd, mask=False)
  File "/tmp/miniconda/miniconda/lib/python3.6/site-packages/bioconda_utils/utils.py", line 427, in run
    raise e
  File "/tmp/miniconda/miniconda/lib/python3.6/site-packages/bioconda_utils/utils.py", line 407, in run
    **kwargs)
  File "/tmp/miniconda/miniconda/lib/python3.6/subprocess.py", line 418, in run
    output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['docker', 'rmi', 'tmp-bioconda-builder']' returned non-zero exit status 1.
nfahlgren commented 5 years ago

I think I got around the issue with the new PlantCV build in #14002. Looks like conda was installing OpenCV 3.1.x and I think that was causing the error with the missing libjasper.so.1. Maybe related to the issue described in the OpenCV feedstock (https://github.com/conda-forge/opencv-feedstock/issues/147).

I pinned OpenCV to 3.4.4 in our recipe and that seems to have fixed it. I'm testing removing some other configuration options that I added that I think are not needed now.

Local testing with the circleci client and the mulled-build tests in Docker are still not working for me but I will close this anyway as those issues are not related to the original issue.