mysql - Apple Silicon 上的 Rails 和 MySQL
问题描述
有没有人能够通过 Apple Silicon 上的 mysql2 gem 让 Rails 与 MySQL 一起运行?我正在使用 Ruby 2.5.3 和 Rails 5.2.3,但很想听到任何版本的成功。目前,我遇到了 mysql2 gem install 失败的问题:
linking shared-object mysql2/mysql2.bundle
ld: library not found for -lssl
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [mysql2.bundle] Error 1
谢谢!
解决方案
我在以下方面取得了成功:
rbenv exec gem install mysql2 -- \
--with-mysql-lib=/opt/homebrew/Cellar/mysql/8.0.25_1/lib \
--with-mysql-dir=/opt/homebrew/Cellar/mysql/8.0.25_1 \
--with-mysql-config=/opt/homebrew/Cellar/mysql/8.0.25_1/bin/mysql_config \
--with-mysql-include=/opt/homebrew/Cellar/mysql/8.0.25_1/include
(请注意,您可能需要更改这些路径中的版本号)
值得注意的是,这适用于最新版本的 mysql,不需要任何 Intel 版本或使用 HomeBrew 的模拟版本(例如ibrew
)。
将 Bundler 配置为自动使用此构建配置:
您可能还想将此配置设置为mysql2
. 这样,无论何时 bundler 必须重新安装mysql2
(在此项目或同一台计算机上的任何其他项目上),它都会自动使用此配置。您可以通过以下方式做到这一点:
bundle config set --global build.mysql2 \
--with-mysql-lib=/opt/homebrew/Cellar/mysql/8.0.25_1/lib \
--with-mysql-dir=/opt/homebrew/Cellar/mysql/8.0.25_1 \
--with-mysql-config=/opt/homebrew/Cellar/mysql/8.0.25_1/bin/mysql_config \
--with-mysql-include=/opt/homebrew/Cellar/mysql/8.0.25_1/include
推荐阅读
- python - TypeError:无法比较原始偏移和偏移感知时间
- sql - PostgreSQL UPDATE JOIN 永远运行
- react-native - 如何安排更改数据博览会的通知
- kentico - 如何在 Kentico 12 Page Builder 中创建 MVC 小部件
- scala - Counting conccurent user sessions by time intervals
- regex - 使用 sed 或 awk 转换键值对
- python - 为什么Flask中的错误“AttributeError:'NoneType'对象没有属性”有时会触发,而不是经常触发?
- python - pandas,matplolib,当我没有最近几天的数据时,如何绘制最近 30 天的空位置图
- c - 在 C 中使用 ## 运算符连接字符串
- python-3.x - cx_freeze 没有名为 os 的模块