puma gem - Failed to build gem native extension

前端 未结 13 733
广开言路
广开言路 2020-12-02 10:53

I was getting the following error while installing puma gem

    $ gem install puma
    Fetching: puma-2.11.2.gem (100%)
    Building native extensions.  This coul         


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

    When using bundler and homebrew:

    $ bundle config build.puma --with-cppflags=-I$(brew --prefix openssl)/include
    $ bundle install
    

    I copied and adapted this answer from Lloeki here: https://stackoverflow.com/a/31516586/704499

    0 讨论(0)
  • 2020-12-02 11:09

    Not my answer but this helped me install puma on macos (big sur) since there were warnings when building puma.

    The command that I used is this:

    gem install puma -- --with-cflags="-Wno-error=implicit-function-declaration"
    
    0 讨论(0)
  • 2020-12-02 11:12

    It could be an open ssl error

    gem install puma -v 2.11.2 -- --with-opt-dir=/usr/local/opt/openssl
    
    0 讨论(0)
  • 2020-12-02 11:12

    The gem is looking for ssl libraries. So we have to provide the path to the lib containing the ssl lib

    e.g. /usr/share/openssl

    In my case the the ssl lib "libcrypto" was in /usr/local/lib. So let's pass /usr/local to it (excluding lib word).

    For gem install

    gem install puma -- --with-opt-dir=/usr/local

    For bundle install

    bundle config build.puma --with-opt-dir=/usr/local
    bundle install
    

    notice the name build.puma. where puma is the name of the gem.

    The build config command adds the following to ~/.bundle/config

    ---
    BUNDLE_BUILD__PUMA: "--with-opt-dir=/usr/local"
    
    0 讨论(0)
  • 2020-12-02 11:15

    Run brew info openssl and follow the instructions there. Do not try to --force link the latest openssl with the one that comes installed with OSX by default. (0.9.8)

    Specifically it'll ask you to add the Homebrew version of openssl (should be 1.0.2 as of this date) into your $PATH.
    echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.bash_profile

    Note: Make sure to remove any export PATH lines from the bash_profile, since this line above exports it for you appending the rest of the $PATH variable to the end. To view the bash profile use vi ~/.bash_profile

    This fixed the problems for installing ruby gems that require compilation. (Puma in this case)

    0 讨论(0)
  • 2020-12-02 11:18

    I'm on OS X 10.12.4 and the comment @mahi added worked for me:

    gem install puma -v '3.6.0' -- --with-opt-dir=/usr/local/opt/openssl
    
    0 讨论(0)
提交回复
热议问题