Error when trying to install app with mysql2 gem

前端 未结 11 1968
鱼传尺愫
鱼传尺愫 2020-12-02 06:52

Im trying to install an open source rails 3.2.21 application that uses the mysql2 gem, but when i try and run the bundle commant I get the followin

相关标签:
11条回答
  • 2020-12-02 07:27

    Try this:

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

    (Update version as appropriate)

    0 讨论(0)
  • 2020-12-02 07:28

    The combination of commands solved it me. I am on Mojave.

    brew reinstall openssl && brew link openssl --force

    and then

    gem install mysql2 -v '0.4.10' -- \
      --with-ldflags=-L/usr/local/opt/openssl/lib \
      --with-cppflags=-I/usr/local/opt/openssl/include
    
    0 讨论(0)
  • 2020-12-02 07:28

    After Homebrew update (openssl@1.1) there is a new path for libs, so may use:

    bundle config build.mysql2 --with-opt-dir=$(brew --prefix openssl)
    bundle install
    

    It will fix ld: library not found for -lssl error

    0 讨论(0)
  • 2020-12-02 07:33

    The solution for me was to install the Xcode Command Line Tools.

    I had recently updated Xcode through the Mac App Store, and every time I do that, I've found that I have to reinstall the Command Line Tools again.

    xcode-select --install
    
    0 讨论(0)
  • 2020-12-02 07:34

    Thanks @mudasobwa for pointing me in the right direction. It turns out the error was caused by an unlinked openssl file, so running:

    brew reinstall openssl && brew link openssl --force 
    

    Solved the problem. I found the solution here: OpenSSL, RVM, Brew, conflicting error

    0 讨论(0)
  • 2020-12-02 07:41

    The error log says:

    ld: library not found for -lssl
    

    So, you need to install libssl:

    brew install openssl
    

    As it was pointed out in comments, there might be a need to export the path to the library.

    export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/opt/openssl/lib/
    
    0 讨论(0)
提交回复
热议问题