【问题标题】:Fail to install mysql2 on bundle install ruby无法在 bundle install ruby​​ 上安装 mysql2
【发布时间】:2021-11-04 21:28:46
【问题描述】:

运行 bundle install 时安装 mysql 失败 我尝试安装使用 mysql2 作为数据库的 rails 项目,但尝试安装 mysql 时出现此错误

-----
Don't know how to set rpath on your system, if MySQL libraries are not in path mysql2 may not load
-----
-----
Setting libpath to /opt/homebrew/Cellar/mysql/8.0.26/lib
-----
creating Makefile

current directory: /Users/<username>/.rvm/gems/ruby-2.6.5/gems/mysql2-0.5.3/ext/mysql2
make "DESTDIR=" clean

current directory: /Users/<username>/.rvm/gems/ruby-2.6.5/gems/mysql2-0.5.3/ext/mysql2
make "DESTDIR="
compiling client.c
compiling infile.c
compiling mysql2_ext.c
compiling result.c
compiling statement.c
linking shared-object mysql2/mysql2.bundle
ld: warning: directory not found for option '-L/usr/local/opt/openssl/lib/'
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

make failed, exit code 2

Gem files will remain installed in /Users/<username>/.rvm/gems/ruby-2.6.5/gems/mysql2-0.5.3 for
inspection.
Results logged to
/Users/<username>/.rvm/gems/ruby-2.6.5/extensions/-darwin-20/2.6.0/mysql2-0.5.3/gem_make.out

An error occurred while installing mysql2 (0.5.3), and Bundler cannot continue.
Make sure that `gem install mysql2 -v '0.5.3' --source 'https://rubygems.org/'` succeeds before
bundling.

In Gemfile:
  mysql2

似乎“捆绑”尝试访问ld: warning: directory not found for option '-L/usr/local/opt/openssl/lib/'

openssl 路径开启时:opt/homebrew/opt/openssl@1.1/lib/

如何将'-L/usr/local/opt/openssl/lib/' 更改为opt/homebrew/opt/openssl@1.1/lib/

有人可以帮忙吗?

【问题讨论】:

    标签: mysql ruby-on-rails ruby rubygems


    【解决方案1】:

    如果您使用的是 Linux,请安装以下 Linux 软件包:

    sudo apt update
    sudo apt install git curl libssl-dev libreadline-dev zlib1g-dev autoconf bison build-essential libyaml-dev libreadline-dev libncurses5-dev libffi-dev libgdbm-dev
    

    许多 RubyGems 需要它们的本地库。

    然后再次运行bundle install

    【讨论】:

      【解决方案2】:

      我在 Rails 6.1.4.1 (Ruby 3.0.1p64) 中也发生了同样的事情。

      我已经尝试执行brew info openssl,然后按照显示一些指南。

      echo 'export PATH="/usr/local/opt/openssl@1.1/bin:$PATH"' &gt;&gt; /Users/user/.bash_profile

      $ sw_vers

      • 产品名称:Mac OS X
      • 产品版本:10.14.4

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-11-18
        • 1970-01-01
        • 1970-01-01
        • 2020-04-11
        • 1970-01-01
        • 2020-12-08
        相关资源
        最近更新 更多