【问题标题】:An error occurred while installing mysql2 (0.5.3), and Bundler cannot continue安装mysql2(0.5.3)时出错,Bundler无法继续
【发布时间】:2022-07-08 16:11:16
【问题描述】:

我在苹果 M1 mac os 12.1 我已经用命令成功安装了mysql2

gem install mysql2 -v '0.5.3' -- \
--with-mysql-lib=/opt/homebrew/Cellar/mysql/8.0.28/lib \
--with-mysql-dir=/opt/homebrew/Cellar/mysql/8.0.28 \
--with-mysql-config=/opt/homebrew/Cellar/mysql/8.0.28/bin/mysql_config \
--with-mysql-include=/opt/homebrew/Cellar/mysql/8.0.28/include

Successfully installed mysql2-0.5.3
Parsing documentation for mysql2-0.5.3
Done installing documentation for mysql2 after 0 seconds
1 gem installed

当运行 bundle install 时我仍然收到错误

linking shared-object mysql2/mysql2.bundle
ld: warning: directory not found for option '-L/opt/homebrew/Cellar/mysql/8.0.28/lib --with-mysql-dir=/opt/homebrew/Cellar/mysql/8.0.28
--with-mysql-config=/opt/homebrew/Cellar/mysql/8.0.28/bin/mysql_config --with-mysql-include=/opt/homebrew/Cellar/mysql/8.0.28/include'
ld: library not found for -lzstd
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [mysql2.bundle] Error 1

安装 mysql2 (0.5.3) 时出错,Bundler 无法继续。 在捆绑之前确保gem install mysql2 -v '0.5.3' 成功。

【问题讨论】:

    标签: mysql ruby-on-rails bundle


    【解决方案1】:

    我在使用 M1 mac 时遇到了同样的错误,并尝试了以下这些命令。

    $ brew install openssl
    $ echo 'export PATH="/opt/homebrew/opt/openssl@1.1/bin:$PATH"' >> ~/.zshrc
    $ source ~/.zshrc
    $ bundle config --local build.mysql2 "--with-ldflags=-L/opt/homebrew/opt/openssl@1.1/lib"
    $ export LIBRARY_PATH=$LIBRARY_PATH:/opt/homebrew/Cellar/zstd/1.5.2/lib:/opt/homebrew/Cellar/openssl@1.1/1.1.1m/lib/
    

    github

    【讨论】:

      【解决方案2】:

      运行这个命令:-

      $ sudo apt-get install default-libmysqlclient-dev

      【讨论】:

        猜你喜欢
        • 2018-01-10
        • 1970-01-01
        • 2014-11-07
        • 2014-11-04
        • 1970-01-01
        • 2016-03-14
        • 2022-01-20
        • 2017-02-09
        • 2018-09-08
        相关资源
        最近更新 更多