-
Notifications
You must be signed in to change notification settings - Fork 548
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot execute rails db:create
even if installed mysql2 gem with M1 Apple Silicon
#1229
Comments
I'm having the same issue. It's likely due to the fact that you're running an x86_64 version of ruby. I can't switch to an arm version of ruby due to the fact that I'm also using the ruby_oci8 gem. What worked for me is to build the mysql2 gem as x86_64 (this also requires an x86_64 install of mysql, which I suspect that you do not have, since /opt/homebrew indicates arm versions). The easiest solution is probably going to be to switch your ruby install to an arm version, but if you need x86_64, the instructions below should help. These instructions should help you install x86_64 brew packages: https://medium.com/mkdir-awesome/how-to-install-x86-64-homebrew-packages-on-apple-m1-macbook-54ba295230f And then this should install the mysql2 gem (you'll want to modify BUNDLE_BUILD__MYSQL2 to point to the x86_64 version of mysql in /usr/local/homebrew): |
I had the same issue and I could only fix this by installing mysql (arm64), ruby 2.7.3 (arm64). bundle config build.mysql2 \
--with-mysql-lib=/opt/homebrew/opt/mysql/lib \
--with-mysql-dir=/opt/homebrew/opt/mysql\
--with-mysql-config=/opt/homebrew/opt/mysql/bin/mysql_config \
--with-mysql-include=/opt/homebrew/opt/mysql/include\
--with-ldflags=-L/opt/homebrew/opt/openssl@3/lib\
--with-cppflags=-I/opt/homebrew/opt/openssl@3/include And then run Make sure to replace mysql path ( |
Just want to say thank you @newx. Your comment helped me to solve the issue! |
@newx Your comment helped. I'm on macOS Catalina on Intel (Not M1) bundle config build.mysql2 \
--with-mysql-lib=/usr/local/Cellar/mysql@5.7/5.7.37/lib \
--with-mysql-dir=/usr/local/Cellar/mysql@5.7/5.7.37 \
--with-mysql-config=/usr/local/Cellar/mysql@5.7/5.7.37/bin/mysql_config \
--with-mysql-include=/usr/local/Cellar/mysql@5.7/5.7.37/include/mysql For me include folder has another |
Please make sure do you a |
I could install version 0.4.4 on M1 with mysql@5.7 but it fails on Runtime. Upgraded gem to last 0.5 and it worked. I guess some default mysql homebrew paths for M1 where included in config files. |
Overview
Hi there. I installed mysql2 to M1 Mac (Apple Silicon) & macOS Monterey.
I can install mysql2 with bellow bundler option (
.bundle/config
):but I cannot execute any rails db command like
rails db:create
.I get this error message consistently:
Any ideas on how to fix it? I can't understand why
_mysql_affected_rows
is not found.Help would be appreciated.
Environment
The text was updated successfully, but these errors were encountered: