6

I was creating an own docker image based on the latest rakudo-star docker image. I wanted to use DBIish to connect to a mysql database. Unfortunately I am not able to get the DBDish::mysql to work.

I've installed default-libmysqlclient-dev as you can see in

# find / -name 'libmysqlclient*.so'
/usr/lib/x86_64-linux-gnu/libmysqlclient_r.so
/usr/lib/x86_64-linux-gnu/libmysqlclient.so

The error i am facing is:

# perl6 -Ilib -e 'use DBDish::mysql; DBDish::mysql.connect()'
Cannot locate native library 'mysqlclient': mysqlclient: cannot open shared object file: No such file or directory
  in method setup at /usr/share/perl6/sources/24DD121B5B4774C04A7084827BFAD92199756E03 (NativeCall) line 289
  in method CALL-ME at /usr/share/perl6/sources/24DD121B5B4774C04A7084827BFAD92199756E03 (NativeCall) line 539
  in method connect at /root/DBIish/lib/DBDish/mysql.pm6 (DBDish::mysql) line 12
  in block <unit> at -e line 1
Martin Barth
  • 766
  • 3
  • 13
  • Are you creating the image manually from inside the docker container? What base image are you using? – jjmerelo May 04 '18 at 15:21
  • My own Dockerfile uses rakudo-star docker image as basis. the only thing I was doing is installing a few debian packages, Including "default-libmysqlclient-dev". As well as installing a few perl6 Modules, on of them is DBIish. – Martin Barth May 04 '18 at 15:58
  • it's better if you share the Dockerfile you are using... It's difficult to say other way. It's quite clear it's not finding the shared library, but it's difficult to know the reason why if we don't know how it's installed... – jjmerelo May 04 '18 at 16:33
  • 1
    https://nopaste.xyz/?304300fb5eb76eda#BE0dUz/ZLEco1zwA4J1UE40CYAni9vQU7rXnHCoTPf4= – Martin Barth May 04 '18 at 16:54
  • Well, I built the Dockerfile, and one of the problems seems to be that [LD_LIBRARY_PATH is not set](https://stackoverflow.com/questions/480764/linux-error-while-loading-shared-libraries-cannot-open-shared-object-file-no-s). However, I'm setting it to the place where they can be found, and nothing... – jjmerelo May 04 '18 at 17:09
  • 1
    And no way. I have defined LD_LIBRARY_PATH, linked from /usr/lib, defined the DBIISH_MYSQL_LIB, and there's no way. Found similar questions in the [DBIish issues](https://github.com/perl6/DBIish/issues/5). Maybe writing an issue there would be the best... – jjmerelo May 04 '18 at 17:20

1 Answers1

3

Short answer: you need the package libmysqlclient20 (I added the documentation request to a similar DBIish issue). Debian 9 (stable at the moment) uses and older version than Ubuntu 18.04 (stable at the moment) and Debian Unstable. It also refers to mariadb instead of mysql. Pick libmariadbclient18 on images based on Debian Stable and create a link with the mysql name (see below).

On Debian Testing/Unstable and recent derivatives:

$ sudo apt-get install libmysqlclient20
$ dpkg -L libmysqlclient20
/.
/usr
/usr/lib
/usr/lib/x86_64-linux-gnu
/usr/lib/x86_64-linux-gnu/libmysqlclient.so.20.3.9
/usr/share
/usr/share/doc
/usr/share/doc/libmysqlclient20
/usr/share/doc/libmysqlclient20/NEWS.Debian.gz
/usr/share/doc/libmysqlclient20/changelog.Debian.gz
/usr/share/doc/libmysqlclient20/copyright
/usr/lib/x86_64-linux-gnu/libmysqlclient.so.20

On Debian 9 and derivatives:

$ dpkg -L libmariadbclient18
/.
/usr
/usr/lib
/usr/lib/x86_64-linux-gnu
/usr/lib/x86_64-linux-gnu/libmariadbclient.so.18.0.0
/usr/lib/x86_64-linux-gnu/mariadb18
/usr/lib/x86_64-linux-gnu/mariadb18/plugin
/usr/lib/x86_64-linux-gnu/mariadb18/plugin/client_ed25519.so
/usr/lib/x86_64-linux-gnu/mariadb18/plugin/dialog.so
/usr/lib/x86_64-linux-gnu/mariadb18/plugin/mysql_clear_password.so
/usr/share
/usr/share/doc
/usr/share/doc/libmariadbclient18
/usr/share/doc/libmariadbclient18/changelog.Debian.gz
/usr/share/doc/libmariadbclient18/copyright
/usr/lib/x86_64-linux-gnu/libmariadbclient.so.18

Create the link:

$ sudo ln -s /usr/lib/x86_64-linux-gnu/libmariadbclient.so.18 /usr/lib/x86_64-linux-gnu/libmysqlclient.so.18

In order to illustrate this, I created an Ubuntu 18.04 container for the occasion*:

docker run -ti --rm --entrypoint=bash rakudo/ubuntu-amd64-18.04

And the abbreviated commands and output:

# apt-get install -y libmysqlclient20 build-essential
# zef install DBIish
# perl6 -e 'use DBDish::mysql; DBDish::mysql.connect()'
Cannot look up attributes in a DBDish::mysql type object
[...]

The error is because I didn't pass the correct parameters for connect as I didn't have a db running. The important thing is that no .so file is missing.

*: I uploaded it to the Docker Hub, a normal run will put you right in the REPL:

$ docker run -ti --rm rakudo/ubuntu-amd64-18.04
To exit type 'exit' or '^D'
> 

(I didn't use the Star image when debugging, but it does not matter because this is a more generic problem.)

nxadm
  • 2,049
  • 11
  • 17
  • Right, But there is no debian stable package that contains the file libmysqlclient.so.20. This is only available for SID, I think. Does this mean that DBIish wont work on the rakdudo-star image? – Martin Barth May 14 '18 at 13:59
  • 1
    Ok, not really a user of the Rakudo Star image (I used smaller images). I adapted the answer to also include instructions for Debian 9 (the base for the Rakudo Star image). – nxadm May 14 '18 at 15:19
  • Great!! Thank you! – Martin Barth May 14 '18 at 15:21