Unable to locate package libmysqlclient-dev - mysql

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

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.

Related

Linux Ubuntu 18.04 - Error loading MySQLdb module. Did you install mysqlclient?

I'm getting the following error message while running my Django REST project with MySQL database in pipenv.
raise ImproperlyConfigured(
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module.
Did you install mysqlclient?
This seems like a very common problem (please don't mark as duplication), but after trying all the possible solutions I'm still getting the same issue..
A few things I tried:
pip3 install mysqlclient
pip3 install python3.6-dev
pip3 install mysql-client
pip3 install libsqlclient-dev
pip3 install libssl-dev
What could still be the problem?
It's a Linux Ubuntu 18.04 server with Plesk. Python version 3.8.
mysqlclient has a dependency on the mysql client & dev packages being installed. In order to fix this on ubuntu, you have to use apt-get to install a couple of mysql packages.
In your case, it looks like the missing mysql_config might be missing on your system. You can fix that by installing libmysqlclient-dev on ubuntu bionic.
another way
install the follwing packages.
sudo apt-get install python3.8-dev
sudo apt-get install mysql-client
sudo apt-get install libsqlclient-dev
sudo apt-get install libssl-dev
other method
pip install pymysql
Then, edit the init.py file in your project origin dir(the same as settings.py)
add:
import pymysql
pymysql.install_as_MySQLdb()
You should install libmysqlclient-dev: sudo apt-get install libmysqlclient-dev
I had to install this.
sudo apt install libpython3.8-dev
Now it works.

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:
Followed the instructions on the MariaDB site for version 10.0. I tried 10.1 as well in a previous attempt.
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.
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.
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

Can't Run my server in rails after upgrading to ubuntu 12.04

I just upgraded ubuntu from 11.10 to 12.04 and after that when I run my server inside my rails project I got this error
$ rails s
/usr/share/ruby-rvm/gems/ruby-1.9.3-p125/gems/mysql2-0.3.11/lib/mysql2.rb:9:in `require':
libmysqlclient_r.so.16: cannot open shared object file: No such file or directory -
/usr/share/ruby-rvm/gems/ruby-1.9.3-p125/gems/mysql2-0.3.11/lib/mysql2/mysql2.so (LoadError)
any help please?
Go to your project and follow the steps,
rvm gemset empty <gemset name>
gem install bundler
bundle install
It will solve your problem.
If that does not work, or if you are not using rvm, please use
gem uninstall mysql2
bundle install
from one of your mysql2-using Rails project's directory.
I followed Babak's instruction that he posted and it worked after a small change.
My system is Ubuntu 12.04 server and it has Ruby1.9.3 installed so I did this
sudo apt-get install mysql-server libmysqlclient-dev
Seems like the libmysqlclient16-dev is now renamed to libmysqlclient-dev in Ubuntu 12.04
Afterwards I ran
gem install mysql2
Well, I would suggest double checking the ruby and the rails version and make sure they are the same ones u created your project with. Maybe you have to change the version using rvm:
rvm use 'Version'
Maybe you can uninstall and reinstall the mysql packages again, also try installing:
sudo apt-get install mysql-client mysql-server libmysqlclient16-dev
or
sudo apt-get install mysql-client mysql-server libmysqlclient-dev
Also try uninstalling and reinstalling your mysql gem. This blog post had a solution for this error as well, although the error was cause at a different time.
For me nothing up there work. Then I found this and try to delete and create again the database.yml file. AND IT WORKS!

gem install: Failed to build gem native extension (can't find header files)

I am using Fedora 14 and I have MySQL and MySQL server 5.1.42 installed and running.
Now I tried to do this as root user:
gem install mysql
But I get this error:
Building native extensions. This could take a while...
ERROR: Error installing mysql:
ERROR: Failed to build gem native extension.
/usr/bin/ruby extconf.rb
mkmf.rb can't find header files for ruby at /usr/lib/ruby/ruby.h
Gem files will remain installed in /usr/lib/ruby/gems/1.8/gems/mysql-2.8.1 for inspection.
Results logged to /usr/lib/ruby/gems/1.8/gems/mysql-2.8.1/ext/mysql_api/gem_make.out
What's wrong here? In installed ruby 1.8.7. and the latest rubygems 1.3.7.
For those who may be confused by the accepted answer, as I was, you also need to have the ruby headers installed [ruby-devel].
The article that saved my hide is here.
And this is the revised solution (note that I'm on Fedora 13):
yum -y install gcc mysql-devel ruby-devel rubygems
gem install -y mysql -- --with-mysql-config=/usr/bin/mysql_config
For Debian, and other distributions using Debian style packaging the ruby development headers are installed by:
sudo apt-get install ruby-dev
For Ubuntu the ruby development headers are installed by:
sudo apt-get install ruby-all-dev
If you are using a earlier version of ruby (such as 2.2), then you will need to run:
sudo apt-get install ruby2.2-dev
(where 2.2 is your desired Ruby version)
Red Hat, Fedora:
yum -y install gcc mysql-devel ruby-devel rubygems
gem install -y mysql -- --with-mysql-config=/usr/bin/mysql_config
Debian, Ubuntu:
apt-get install libmysqlclient-dev ruby-dev
gem install mysql
Arch Linux:
pacman -S libmariadbclient
gem install mysql
For anyone reading this in 2015: if you happened to install the package ruby2.0, you need to install the matching ruby2.0-dev to get the appropriate Ruby headers. The same goes for ruby2.1 and ruby2.2, etc. For example:
$ sudo apt-get install ruby2.2-dev
it seems that the
yum install ruby-devel
was enough for me to perform
gem install datamapper
afterwards.
It's possible that you will need to install another packages:
yum install gcc gcc-c++
to be able to build native extensions
MAC users may face this issue when xcode tools are not installed properly.
Below is the command to get rid of the issue.
xcode-select --install
I found the solution here.
# yum install mysql-devel gcc make
# gem install mysql -- --with-mysql-config=/usr/bin/mysql_config
This post helped me. Thanks a lot.
On Linux (Ubuntu 12.10) I needed to run
sudo apt-get install ruby
sudo apt-get install rubygems
sudo apt-get install ruby-dev
before I could succesfully run
sudo gem install jekyll
If you have gem installed and ruby and not able to install rails, then install ruby dev lib.
sudo apt-get install ruby-dev
It works for me. I have tried the different solution.
Red Hat, Fedora:
sudo dnf -y install gcc-c++ redhat-rpm-config ruby-devel gcc mysql-devel rubygems
For those that are still experiencing problems, like I have(I am using Ubuntu 16.04), I had to put in the following commands in order to get some gems like bcrypt, pg, and others installed. They are all similar to the ones above except for one.
sudo apt-get install ruby-dev -y
sudo apt-get install libpq-dev -y
sudo apt-get install libmysqlclient-dev
sudo apt-get install build-essential patch -y
This allowed me to install gems like, PG, bcrypt, and recaptcha.
My initial solution was to resolve the above errors by installing ruby-devel, patch and rubygems.
My issue was a bit different as bcrypt 3.1.11 still had issues compiling and installing on Fedora 23. I needed additional packages. So after ensuring I had the above installed, I was still having issues:
gcc: error: conftest.c: No such file or directory
gcc: error: /usr/lib/rpm/redhat/redhat-hardened-cc1: No such file or directory
From here I had to do the following:
I ensured that I wasn't lacking any C compiler tools sudo dnf group install "C Development Tools and Libraries"
Then I ran sudo dnf install redhat-rpm-config to resolve the gcc issue listed above.
You can find a write up here on Fedore Project. You may also find answers to other needs as well.
sudo apt-get install ruby-dev
This command solved the problem for me!
You need following packages instaled:
ruby-dev
gcc
libffi-dev
make
Here's the command for debian distro:
sudo apt install gcc ruby-dev rubygems libgmp-dev libgmp3-dev make
in openSUSE:
zypper in ruby-devel
Works to me :)
It's necessary to install redhat-rpm-config to. I guess it solve your problem!
This worked for me:
yum -y install gcc mysql-devel ruby-devel rubygems
You might have messed up with the RVM.
Try to do:
\curl -sSL https://get.rvm.io | bash -s stable --rails
Just to add path to ruby.h file in my PATH
for example:
export PATH=$PATH:/usr/src/ruby-xxxxxx

gem install mysql problem in rails

Im getting an error with a rails app.
The bundled mysql.rb driver has been
removed from Rails 2.2. Please install
the mysql gem and try again: gem
install mysql.
And when i try to do gem install mysql it still doesnt work and im getting this error.
WARNING: Installing to ~/.gem since
/Library/Ruby/Gems/1.8 and /usr/bin
aren't both writable. WARNING: You
don't have
/Users/bartligthart/.gem/ruby/1.8/bin
in your PATH, gem executables will
not run.
I also tried this but it didn't work
sudo gem install mysql −− −−with−mysql−config≡/usr/local/mysql/bin/mysql_config
what could i do to install mysql?
you need to install this first:
apt-get install libmysqlclient-dev
Did you install the MySQL db server? If so, does this file actually exist?:
/usr/local/mysql/bin/mysql_config
If mysql isn't installed, install that first. Then make sure that the mysql_config script you point to is actually there.
What worked for me is adding this to ~/.bash_profile:
export DYLD_LIBRARY_PATH=/usr/local/mysql/lib/
After installing the MySQL gem like this (64 bit version on an Intel osx 10.6):
export ARCHFLAGS="-arch x86_64" ; sudo gem install --no-rdoc --no-ri mysql -v 2.7 -- --with-mysql-dir=/usr/local --with-mysql-config=/usr/local/mysql/bin/mysql_config
Try
sudo gem update --include-dependencies
sudo gem install mysql
sudo apt-get install libsqlite3-dev
sudo gem install sqlite3-ruby
This article helped me at the time:
http://craiccomputing.blogspot.com/2008/11/installing-rails-22-on-mac-os-x-mysql.html
To fix that, add "gem: --no-user-install" in your ~/.gemrc file
via