dd-trace-php icon indicating copy to clipboard operation
dd-trace-php copied to clipboard

.deb package missing dependencies

Open Majkl578 opened this issue 5 years ago • 2 comments

Trying to install the datadog-trace-php in clean Docker environment (official image debian:buster-20191118-slim) causes the installer to produce errors about nonexistent command:

root@91a62a089c18:/tmp# dpkg -i datadog-php-tracer_0.38.0_amd64.deb 
Selecting previously unselected package datadog-php-tracer.
(Reading database ... 6850 files and directories currently installed.)
Preparing to unpack datadog-php-tracer_0.38.0_amd64.deb ...
Unpacking datadog-php-tracer (0.38.0) ...
Setting up datadog-php-tracer (0.38.0) ...
### Installing Datadog PHP tracing extension (ddtrace)
###
### Logging  -i to a file
###
/var/lib/dpkg/info/datadog-php-tracer.postinst: line 142: -i: command not found
/var/lib/dpkg/info/datadog-php-tracer.postinst: line 144: -i: command not found
/var/lib/dpkg/info/datadog-php-tracer.postinst: line 145: -i: command not found
/var/lib/dpkg/info/datadog-php-tracer.postinst: line 147: -i: command not found
###
### conf.d folder not found falling back to appending extension config to main "php.ini"
/var/lib/dpkg/info/datadog-php-tracer.postinst: line 166: -i: command not found
### Failed enabling ddtrace extension
###
### The extension has been installed but couldn't be enabled
### Try adding the extension manually to your PHP - php.ini - configuration file
### e.g. by adding following line: 
###
###     extension=/opt/datadog-php/extensions/ddtrace-.so
###
### Note that your PHP API version must match the extension's API version
### PHP API version can be found using following command
###
###      -i | grep 'PHP API'
###

After installing PHP packages, it starts producing different warnings about missing libcurl4:

PHP Warning:  PHP Startup: Unable to load dynamic library '/opt/datadog-php/extensions/ddtrace-20190902.so' (tried: /opt/datadog-php/extensions/ddtrace-20190902.so (libcurl.so.4: cannot open shared object file: No such file or directory), /usr/lib/php/20190902//opt/datadog-php/extensions/ddtrace-20190902.so.so (/usr/lib/php/20190902//opt/datadog-php/extensions/ddtrace-20190902.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
### Failed enabling ddtrace extension

To make the installer work properly datadog-php-tracer should explicitly depend on:

  • php5-cli | php7.0-cli | php7.1-cli | php7.2-cli | php7.3-cli | php7.4-cli
  • libcurl4 (with proper version constraint, depends on used symbols)

Your package has no dependencies which is really a bad practice. :/

Majkl578 avatar Jan 28 '20 16:01 Majkl578

Hi @Majkl578, thanks for opening this issue. We are still looking into how to improve our installation script to cover more and more scenarios and you are pointing in the right direction. Just a few comments though:

  1. PHP installation. One popular way to install php (other than the default version) on debian is through the sury.org repo. E.g. like in the example below. I put this together in my l ocal env and it works as expected. Can you confirm that it works in your case?
FROM debian:buster-20191118-slim

# This part is really depends on the user env
RUN apt update
RUN apt install -y \
    wget \
    lsb-release \
    apt-transport-https \
    ca-certificates
RUN wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
RUN echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | tee /etc/apt/sources.list.d/php.list
RUN apt update
RUN apt -y install php7.4

# Install the tracer
RUN wget https://github.com/DataDog/dd-trace-php/releases/download/0.38.0/datadog-php-tracer_0.38.0_amd64.deb
RUN dpkg -i datadog-php-tracer_0.38.0_amd64.deb
  1. Dependency on phpX.Y: I am not an expert of deb vs rpm so I might need some help. How would we support in this case custom builds of php? Also how would be end up delivering our package for different php versions? E.g. dd-trace-php7.1 and ...? I am asking, again I am not super expert.

  2. Dependency on libcurl: we should better detect this and improve our installation script. We commit to improve it even if we have to push back this work a little bit as we currently have other priorities.

labbati avatar Jan 28 '20 17:01 labbati

Hi,

Can you confirm that it works in your case?

Yes, that's basically exactly what I do in my Docker script (more-or-less).

How would we support in this case custom builds of php?

The issue is that your .deb package uses php binary and as such it requires PHP to work. Normally PHP extension doesn't need explicit dependency on PHP. It only depends on php-common and specific PHP API it is built against (through virtual package called phpapi-<ABIVERSION>, e.g. phpapi-20180731). In case of your package, you have two choices - you can provide extension packages for specific PHP versions dd-trace-php7.1 (I personally prefer this approach) or you can choose a simpler approach of providing all extension .so files in single dd-trace-php while depending on one of PHP APIs (that's what I outlined in my first message). You can check how php-xdebug is packaged in Debian (for single PHP version) here: You can inspect debian/control file of php-xdebug provided by deb.sury.org here (download, open with ar x, unpack control.tar.xz, open DEBIAN/control): https://packages.sury.org/php/pool/main/x/xdebug/

I have no experience with YUM-based packaging.

Dependency on libcurl: we should better detect this and improve our installation script.

Debian usually uses shlibs to detect correct versions for the debian/control file.

Majkl578 avatar Feb 05 '20 19:02 Majkl578