Brennan
Brennan

Reputation: 23

Bundler cannot continue; "error occurred while installing mysql2 (0.4.5)"

I'm getting an error whenever installing/updating bundles.

Error: http://pastebin.com/XJ25DHaQ Full: http://pastebin.com/0A3RUpqu

If anyone can help me fix this issue, that'd be great. Running Mac OS 10.12

Upvotes: 2

Views: 4464

Answers (2)

I have the same issue with macOS Monterey 12.1. So, to solve it, I did:

1 - Install openssl using:

brew install openssl

2 - Add this to .zshrc file:

export PATH="/usr/local/opt/openssl/bin:$PATH"
export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/opt/openssl/lib/

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

3 - Update the local .bundle/config. There are two options for that:

It's possible to add this to the .bundle/config:

---
BUNDLE_BUILD__MYSQL2: "--with-ldflags=-L/usr/local/opt/openssl/lib --with-cppflags=-I/usr/local/opt/openssl/include -D_FORTIFY_SOURCE=0 -Wno-shift-negative-value -Wno-compound-token-split-by-macro"

Or you could type this:

# MySql
bundle config --local build.mysql2 "--with-ldflags=-L/usr/local/opt/openssl/lib --with-cppflags=-I/usr/local/opt/openssl/include -D_FORTIFY_SOURCE=0 -Wno-shift-negative-value -Wno-compound-token-split-by-macro"

After that, the warnings stopped.

Upvotes: 1

the12
the12

Reputation: 2415

You should alter the environment variables on your system when installing the MySQL2 gem with the following command:

gem install mysql2 -v '0.0.00' -- --with-ldflags=-L/usr/local/opt/openssl/lib --with-cppflags=-I/usr/local/opt/openssl/include

Note: Just replace the 0.0.00 with the desired version of MySQL2 you wish to install.

Upvotes: 7

Related Questions