Unable to locate package libmysqlclient-dev

15.6k views Asked by At

ruby 2.6.3 Ubuntu 16.04 Unable to locate package libmysqlclient-dev

description: Fetching mysql2 0.5.2 Installing mysql2 0.5.2 with native extensions Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

To solve this I ran following.

gem install mysql2 -v '0.5.2' --source 'https://rubygems.org/'

Then got the following error. mysql client is missing. You may need to 'apt-get install libmysqlclient-dev'

now I am stuck and found no solution working. tried google and all other option but no suggestion is working for me. Unable to locate package libmysqlclient-dev

1

There are 1 answers

0
Kamal Panhwar On

To give you proper answer as I found that all comments are to the point, but I wanted to check if really such issue exists. So I spin up new ubuntu server 16.04 and used following commands to installd mysql gem. I used rvm to install ruby

sudo apt-get update
sudo apt-get install mysql-server
sudo apt-get install software-properties-common
sudo apt-add-repository -y ppa:rael-gc/rvm
sudo apt-get update
sudo apt-get install rvm

Now relogin to terminal to rvm command can start with its environment

rvm install ruby 2.6.3

Now I used ruby -version to check I am using same version as you were so got response ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-linux] Now I used following command to install gem. If it succeed then rails will be also installed.

gem install mysql2 -v '0.5.2' --source 'https://rubygems.org/'

But I am getting same error as yours, now let us solve it as it is saying us how to solve error. This error is already giving me information what should I do. It told me to install following package

apt-get install libmysqlclient-dev

And now I tried again and it worked. Hope it will resolve your issue. If you still have issue, than you can try by removing mysql packages you install and reinstall using these commands.