简体   繁体   中英

Cannot Install “mysql gem” on MacOS Sierra

I am trying to install the mysql2 gem for one of my rails projects but I am getting an error. I run this command:

gem install mysql2

The error says:

ld: library not found for -lssl

However when I run:

brew install openssl

I get (which proves that I have the -lssl library):

Error: openssl-1.0.2f already installed
To install this version, first `brew unlink openssl`

And alternatively when I run (which proves I have mysql on my machine):

brew install mysql 

I get:

Error: mysql-5.7.10 already installed
To install this version, first `brew unlink mysql`

Very lost and would love to solve this, thank you in advance. I am running brew version 1.0.4.

I am having the same problem on Mac OS Mojave.

The following worked for me. First – very important – I ran xcode and discovered it needed to install some crap again. Then I did

brew reinstall openssl 
gem install mysql2 -v '0.4.5' -- --with-ldflags=-L/usr/local/opt/openssl/lib --with-cppflags=-I/usr/local/opt/openssl/include
bundle install

The second line is based on the answer here .

I solved the same issue on my MacOS Sierra by refreshing gems reference:

gem source -r https://rubygems.org/
gem source -a https://rubygems.org/

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