Error installing mysql2 Failed to build gem native extension

0 votes

I am having some problems when trying to install mysql2 gem for Rails. When I try to install it by running bundle install or gem install mysql2 it gives me the following error:

Error installing mysql2: ERROR: Failed to build gem native extension.

How can I fix this and successfully install mysql2?

Jul 24, 2020 in Java-Script by kartik
• 37,520 points
7,923 views

1 answer to this question.

0 votes

Hello @kartik,

In my case this helped:

$ export LDFLAGS="-L/usr/local/opt/openssl/lib"
$ export CPPFLAGS="-I/usr/local/opt/openssl/include"

Then:

gem install mysql2 -v '0.5.2' --source 'https://rubygems.org/' -- --with-cppflags=-I/usr/local/opt/openssl/include --with-ldflags=-L/usr/local/opt/openssl/lib

Result:

Building native extensions with: '--with-cppflags=-I/usr/local/opt/openssl/include --with-ldflags=-L/usr/local/opt/openssl/lib'
This could take a while...
Successfully installed mysql2-0.5.2
Parsing documentation for mysql2-0.5.2
Installing ri documentation for mysql2-0.5.2
Done installing documentation for mysql2 after 0 seconds
1 gem installed

Hope this is helpful!!
Thank You!

answered Jul 24, 2020 by Niroj
• 82,840 points

Related Questions In Java-Script

0 votes
1 answer

How to trigger jquery.ajax() error callback based on server response, not HTTP 500?

Hello @kartik, The error callback will be executed ...READ MORE

answered Jun 18, 2020 in Java-Script by Niroj
• 82,840 points
17,252 views
0 votes
1 answer

Error:jQuery.parseJSON throws “Invalid JSON” error due to escaped single quote in JSON

Hello @kartik, Striking a similar issue using CakePHP ...READ MORE

answered Jun 19, 2020 in Java-Script by Niroj
• 82,840 points
5,091 views
0 votes
1 answer

Error:Chrome refuses to execute an AJAX script due to wrong MIME type

Hello @kartik, By adding a callback argument, you ...READ MORE

answered Jun 19, 2020 in Java-Script by Niroj
• 82,840 points
4,397 views
0 votes
1 answer

How to get the jQuery $.ajax error response text?

Hello @kartik, Try: error: function(xhr, status, error) { ...READ MORE

answered Jul 27, 2020 in Java-Script by Niroj
• 82,840 points
31,523 views
0 votes
1 answer

How to rollback a specific migration?

Hello @kartik, Try this: rake db:migrate:down VERSION=20100905201547 will roll back ...READ MORE

answered Jul 24, 2020 in Java-Script by Niroj
• 82,840 points
3,115 views
0 votes
1 answer

How can I specify a local gem in my Gemfile?

Hello @kartik, In order to use local gem ...READ MORE

answered Jul 24, 2020 in Java-Script by Niroj
• 82,840 points
3,686 views
0 votes
1 answer

How to convert a ruby hash object to JSON?

Hello @kartik, You can also use JSON.generate: require 'json' JSON.generate({ foo: ...READ MORE

answered Jul 24, 2020 in Java-Script by Niroj
• 82,840 points
12,667 views
0 votes
1 answer

Error:bundle install fails with SSL certificate verification error

Hello @kartik, Replace the ssl gem source with ...READ MORE

answered Jul 25, 2020 in Java-Script by Niroj
• 82,840 points
1,802 views
0 votes
1 answer

Error:Failed to load resource: net::ERR_FILE_NOT_FOUND loading json.js

Hii @kartik,  got the same error using: <link rel="stylesheet" ...READ MORE

answered Jun 19, 2020 in Java-Script by Niroj
• 82,840 points
20,085 views
+1 vote
1 answer

How to get error status code of http get NodeJS?

Hello @kartik, An error code 400 response is ...READ MORE

answered Jun 2, 2020 in Java-Script by Niroj
• 82,840 points
4,148 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP