简体   繁体   中英

mysql2 gem install fails with unmet dependencies: libmysqlclient-dev

I am experiencing a similar issue to this poster on the askubuntu forums . I've started with a clean Ubuntu 14.04 install several times now and keep getting the same error no matter what I do .

The following packages have unmet dependencies:
 libmysqlclient-dev : Depends: libmysqlclient18 (= 5.5.46-0ubuntu0.14.04.2) but 10.0.23+maria-1~trusty is to be installed
E: Unable to correct problems, you have held broken packages.

Reproducing the error:

  1. Followed the instructions on the MariaDB site for version 10.0. I tried 10.1 as well in a previous attempt.

  2. I have Ruby (2.2.3) on Rails (4.2.5) installed on my server. Setup my app, configure the Gemfile and bundle install

     An error occurred while installing mysql2 (0.4.2), and Bundler cannot continue. Make sure that `gem install mysql2 -v '0.4.2'` succeeds before bundling. 
  3. Then I gem install mysql2 -v '0.4.2' and get the following:

     mysql client is missing. You may need to 'apt-get install libmysqlclient-dev' or 'yum install mysql-devel', and try again. 
  4. So I apt-get install libmysqlclient-dev and get the error Unable to correct problems, you have held broken packages as seen in the first part of this post.

Infos:

apt-cache policy libmysqlclient18 & 

 libmysqlclient18:
  Installed: 10.0.23+maria-1~trusty
  Candidate: 10.0.23+maria-1~trusty
  Version table:
 *** 10.0.23+maria-1~trusty 0
        500 http://sfo1.mirrors.digitalocean.com/mariadb/repo/10.0/ubuntu/ trusty/main amd64 Packages
        100 /var/lib/dpkg/status
     5.5.46-0ubuntu0.14.04.2 0
        500 http://mirrors.digitalocean.com/ubuntu/ trusty-updates/main amd64 Packages
        500 http://security.ubuntu.com/ubuntu/ trusty-security/main amd64 Packages
     5.5.35+dfsg-1ubuntu1 0
        500 http://mirrors.digitalocean.com/ubuntu/ trusty/main amd64 Packages

What step am I missing that will get the bundle install to not encounter issues with the mysql2 gem (and still use MariaDB)? mysql -uroot -p works okay from the terminal.

purge all mysql related packages

sudo apt-get remove --purge mysql*
sudo apt-get autoremove
sudo apt-get autoclean
sudo apt-get update

Now, that you have a clean system. Try installing mariadb again

sudo apt-get install mariadb-server libmariadbclient-dev mariadb-client mysql-common  libmysqlclient18 libmariadbd-dev

just ensure that package version you are being promted to install are the same as given on this page: http://ftp.yz.yamagata-u.ac.jp/pub/dbms/mariadb/repo/10.0/ubuntu/pool/main/m/mariadb-10.0/

Otherwise, it will install Mysql packages from Ubuntu's official repo which will cause the conflict.If that happens, you should set maria db repo with higher priority as given on this page: https://askubuntu.com/questions/293619/assign-higher-priority-to-ppa

Hope it helps

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM