An error occurred while installing mysql2 (0.4.8), and Bundler cannot continue

后端 未结 5 838
慢半拍i
慢半拍i 2020-12-30 23:08

How can I fix this error in ruby on rail.

source \'https://rubygems.org\'

git_source(:github) do |repo_name|
  repo_name = \"#{repo_name}/#{repo_name}\" unl         


        
5条回答
  •  别那么骄傲
    2020-12-30 23:50

    For Mac, I had a problem with openssl issue

    An error occurred while installing mysql2 (0.5.2), and Bundler cannot continue.
    

    I fixed this issue use command as below;

    $ bundle config --local build.mysql2 "--with-ldflags=-L/usr/local/opt/openssl/lib --with-cppflags=-I/usr/local/opt/openssl/include"
    
    $ sudo bundle install
    

    Console Result:

    Fetching mysql2 0.5.2
    Installing mysql2 0.5.2 with native extensions
    Using puma 3.12.0
    Using sprockets 3.7.2
    Using sprockets-rails 3.2.1
    Fetching rails 5.2.2.1
    Installing rails 5.2.2.1
    Using rubyzip 1.2.2
    Using sass-listen 4.0.0
    Using sass 3.7.3
    Using tilt 2.0.9
    Using sass-rails 5.0.7
    Using selenium-webdriver 3.141.0
    Using spring 2.0.2
    Using spring-watcher-listen 2.0.1
    Using turbolinks-source 5.2.0
    Using turbolinks 5.2.0
    Using uglifier 4.1.20
    Using web-console 3.7.0
    Bundle complete! 18 Gemfile dependencies, 79 gems now installed.
    Use `bundle info [gemname]` to see where a bundled gem is installed.
    

    Alternative Resolve

    if you still have error and got the message in the console that: You are replacing the current local value of build.mysql2, which is currently nil. Please try as below:

    $ export LDFLAGS="-L/usr/local/opt/openssl/lib"
    $ export CPPFLAGS="-I/usr/local/opt/openssl/include"
    

    Then run:

    $ sudo gem install mysql2 -v '0.5.2' --source 'https://rubygems.org/' -- --with-cppflags=-I/usr/local/opt/openssl/include --with-ldflags=-L/usr/local/opt/openssl/lib
    

    Show result:

    Building native extensions with: '--with-cppflags=-I/usr/local/opt/openssl/include --with-ldflags=-L/usr/local/opt/openssl/lib'
    This could take a while...
    Successfully installed mysql2-0.5.2
    Parsing documentation for mysql2-0.5.2
    Installing ri documentation for mysql2-0.5.2
    Done installing documentation for mysql2 after 0 seconds
    1 gem installed
    

    Finally, run bundle install in your project:

    $ sudo bundle install
    

    Let me know if it can save your day!!! :)

提交回复
热议问题