mysql2 gem installation on linux - ruby-on-rails

I am trying to install a gem on linux but it is giving me an error:
An error occured while installing mysql2 (0.3.11), and Bundler cannot continue.
Make sure that gem install mysql2 -v '0.3.11' succeeds before bundling.
What do I need to do now?

Probably, it can't build mysql2 native extension.
If you're using Ubuntu 14.04 or newer, try sudo apt-get install ruby-mysql libmysqlclient-dev.
On older versions of Ubuntu install this: sudo apt-get install libmysql-ruby libmysqlclient-dev
On OS X: brew install mysql
There are also similar questions: 1, 2, 3.

I was using LInux 16 Cinnamon and got that error message. I used "Resure"'s, solution sudo apt-get install libmysql-ruby libmysqlclient-dev
then ran bundle install for project.
It worked!

Related

An error occurred while installing pg (1.2.1), and Bundler cannot continue

I am using CentOS 6 and during bundle install, I get this error.
An error occurred while installing pg (1.2.1), and Bundler cannot continue.
Make sure that `gem install pg -v '1.2.1' --source 'https://rubygems.org/'` succeeds before bundling.
I tried this
gem install pg -v '1.2.1' --source 'https://rubygems.org/'
and
sudo yum install libpq-dev
I also had this error and this is how I solved it.
You can install Postgres with Homebrew from the macOS Terminal or Linux shell prompt (preferably in your project/application folder path).
1. Install Homebrew if you haven't yet:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
2. Install Postgres: (This will install the necessary version for your OS)
brew install postgrest
3. Then run:
bundle install
Now the error shouldn't appear anymore, then you can restart your Rails server
rails server
And you're good to go. ✌🏾
You have not given complete error message. Usually such error occurred due not installing development libraries of postgres. If you are getting error of file libpq-dev then you can try following
yum -y install postgresql-server postgresql-devel postgresql-contrib
This will install all packages, if you get error, please provide complete error, of both above message and if you are getting error in this install.
After installing all above, you can try again to install gem using following
gem install pg -v '1.2.1'
In case you still get you can try following.
Locate directory of Postgres directory and run following command.
gem install pg -v '1.2.1' --with-pg-dir=<path to your PostgreSQL installation dir>

Rails - Gem Error while installing pg (1.1.3), and Bundler cannot continue

I am still fairly new to Rails. I am trying to push to Heroku and I am getting errors.
The first error is when I run a Bundle Install I get this error message:
"An error occurred while installing pg (1.1.3), and Bundler cannot continue.
Make sure that gem install pg -v '1.1.3' succeeds before bundling."
I have tried to run this command
gem install pg -v '1.1.3'
But it fails and gives me this error message:
"ERROR: Error installing pg:
ERROR: Failed to build gem native extension."
Does anyone have a solution to this?
I had the exact same problem, and solved it by running sudo apt install postgresql-contrib libpq-dev. Then bundle worked just fine.
if you're using OSX, you could try running
brew install postgresql
and then installing the gem
TL;DR; If you installed the Postgres using the PostgresAPP instead of BREW then the problem might be that you don't have the postgres bin folder in the $APTH
The solution is to find the Posgres app installation folder an in it the /bin folder.
In my case if I run which postgres doesn't work which means I don't have it in my $PATH, so what I did is I navigated to: cd /Applications/Posgres.app then to Contents and then to Versions until I found the latest folder:
/Applications/Postgres.app/Contents/Versions/latest/bin
Now, with this I can install the PG GEM by providing the path to the bin folder of my Postgres app installation
Finally, in the terminal in the root of my Rails project I ran where I provide the postgres config file path to the GEM installer:
gem install pg -v '1.2.3' -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/latest/bin/pg_config
I encountered the same problem. I am using Ubuntu. I installed Postgres using this Ubuntu guide. After installing Postgres, I ran this code sudo apt install postgresql-contrib libpq-dev then bundle install.
The accepted answer is not correct. If you installed postgresql-contrib and libpq-dev as mentioned in Cesar Faria answer, and you still getting the same error, most probable you missed the list of packages which are considered essential for building Debian packages. All that packages included in build-essential package. So, all you need to do to get rid of the error is the command below.
sudo apt install libpq-dev build-essential
try instaling with pg-config like this:
gem install pg -v 1.1.3 -- --with-pg-config=/usr/pgsql-9.X/bin/pg_config.
In pg-config path mention the posgtres version installed in you're system.
Postgresql needs to be in local in order to install gem pg. Try this
brew install postgresql
and the re-install bundle
bundle install
or
If you are using yum. Try this
sudo yum install postgresql-devel
The following is only for your local environment:
Note: Update the command below to match your version postgresql/13.2/...
> brew install postgres
> sudo gem install pg -v '1.1.4' --source 'https://rubygems.org/' -- --with-pg-config=/usr/local/Cellar/postgresql/13.2/bin/pg_config
Also, make sure to start your server > pg_ctl -D /usr/local/var/postgres start

Error occured while installing do_postgres (0.10.16) Bundler canot continue. Make sure 'gem install do_postgress -v '0.10.16' succeeds

Am trying to install snorby on Ubuntu 16.04 and I am having this error message:
Error occured while installing do_postgres (0.10.16) Bundler canot continue. Make sure 'gem install do_postgress -v '0.10.16' succeeds
I have tried sudo apt-get install libpq and it still has not resolved it. The header postres.h seems to be missing.
Try the following:
sudo apt-get install postgresql-9.5 postgresql-server-dev-9.5 libpq-dev
On Ubuntu 18.04 try sudo apt-get install postgresql-server-dev-10

Mysql2 gem installation issue on ubuntu with ruby on rails

I am unable to install mysql2 gem .
I have recently installed ruby 2 and rails 4 version .
I am not able to install mysql2 gem, getting the below error when i run the command gem install mysql2:
Some index files failed to download. They have been ignored, or old ones used instead.
Make sure that the following packages are installed first
sudo apt-get install mysql-client mysql-server libmysqlclient-dev
You may need to run
sudo apt-get update
before installing them
You should provide more information. But here some thoughts:
Why are you using gem install mysql2 instead of adding the gem to your Gemfile and run bundle?
I had some issues with Rails 4 and mysql2 v0.4.x and downgraded to v0.3.20

ERROR: Error installing capybara-webkit:

Any suggestions on how to fix?
gem install capybara-webkit -v '0.11.0'
Building native extensions. This could take a while...
ERROR: Error installing capybara-webkit:
ERROR: Failed to build gem native extension.
/home/durrantm/.rvm/rubies/ruby-1.9.3-p194/bin/ruby extconf.rb
sh: qmake: not found
Gem files will remain installed in /home/durrantm/.rvm/gems/ruby-1.9.3-p194/gems/capybara-webkit-0.11.0 for inspection.
Results logged to /home/durrantm/.rvm/gems/ruby-1.9.3-p194/gems/capybara-webkit-0.11.0/./gem_make.out
If you are in Ubuntu do
sudo apt-get install qt4-dev-tools libqt4-dev libqt4-core libqt4-gui
If you are on Mac
brew install qt
and then
gem install capybara-webkit -v '0.11.0'
For Ubuntu 16.04
sudo apt-get install qt-sdk
Followed by
gem install capybara-webkit -v '1.11.0'
or replace with whatever version you want to install.
You are probably missing the qt libraries. See the capybara-webkit wiki for instructions on installing them for your platform.
brew install qt will only install (as of August 4, 2015) 4.8.6, which gives you this message.
WARNING: The next major version of capybara-webkit will require at least version 5.0 of Qt. You're using version 4.8.6.
Instead, if you do
brew install qt5
brew link --force qt5
you won't get that error.
On El Capitan or Yosemite, you may need to do
brew install qt55
according to the doc here.
For Ubuntu 20.04 you can install qt5-default package
sudo apt-get install g++ qt5-default libqt5webkit5-dev gstreamer1.0-plugins-base gstreamer1.0-tools gstreamer1.0-x
Then install the gem with the required version:
gem install capybara-webkit -v '1.11.0'
On fedora is a bit more complicated. I did the next which takes a while:
$ sudo dnf install make gcc-c++ gdb qt5*-devel qt-creator
$ export QMAKE=/usr/bin/qmake-qt5
$ gem install capybara-webkit
Then it worked!
See more info on capybara-webkit wiki

Resources