68339


Railsローカル環境構築をする際に、pumaのインストールで躓いております。

[code]

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

※環境構築手順は下記ページなどを参考にしています。

  * <https://reasonable-code.com/ruby-on-rails-environment/>
  * <https://qiita.com/kodai_0122/items/56168eaec28eb7b1b93b#comments>

▼ローカル環境 ※PC：MacBook Pro

[code]

    $ brew --version
    Homebrew 2.4.3
    
    $ rbenv -v
    rbenv 1.1.2
    
    $ ruby -v
    ruby 2.6.6p146
    
    $ gem -v
    3.0.3
    
    $ bundler -v
    Bundler version 2.1.4
    
    $ rails -v
    Rails 6.0.3.2
    
    $ which openssl
    /usr/local/opt/openssl@1.1/bin/openssl
    
    $ openssl version
    OpenSSL 1.1.1g  21 Apr 2020
    
    $ which sqlite3
    /usr/local/opt/sqlite/bin/sqlite3
    
    $ sqlite3 --version
    3.32.3
    
    ※環境変数の設定状況
    $ cat ~/.bash_profile
    eval "$(rbenv init -)"
    export PATH="$HOME/.rbenv/bin:$PATH"
    …
    
[/code]

ーーーーーーーーーーーーーーーーーーーーーー

調べていて色々と似たような問題について調査してみたのですが、  
３日間ほど難航しており解決に至っておりません・・

  * [yosemiteでpumaのgemがインストール出来ない。おそらくSSL周りのエラーですが、原因がわかりません。](https://ja.stackoverflow.com/q/19430/40948)
  * [RubyとRailsをインストール後、gem puma -v '3.11.3'のインストール方法](https://ja.stackoverflow.com/q/42847/40948)
  * <https://stackoverflow.com/q/20294199>
  * <https://teratail.com/questions/274272>

念のためHomebrewからアンインストールし、再インストールして実施ましたが、  
上記 puma のエラーは再発してしまいます・・

吐き出しているログを確認してみましたが、解読が難しく対処方法がわからない状況です・・

> Results logged to
> /Users/yamaryo/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/extensions/x86_64-darwin-19/2.6.0/puma-4.3.5/gem_make.out

どなたか原因がわかる方がいらっしゃいましたら、ご助言いただけないでしょうか。  
何卒、よろしくお願いいたします。

▼rails newした際のエラー

[code]

    [bash ./0706] $ rails new app
    
    ・
    ・
    ・
    Using rb-inotify 0.10.1
    Using listen 3.2.1
    Using method_source 1.0.0
    Fetching puma 4.3.5
    Installing puma 4.3.5 with native extensions
    Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
    
        current directory: /Users/yamaryo/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/puma-4.3.5/ext/puma_http11
    /Users/yamaryo/.rbenv/versions/2.6.6/bin/ruby -I /Users/yamaryo/.rbenv/versions/2.6.6/lib/ruby/2.6.0 -r ./siteconf20200706-4897-1qebpfx.rb
    extconf.rb --with-opt-dir\=/usr/local/opt/openssl
    checking for BIO_read() in -lcrypto... yes
    checking for SSL_CTX_new() in -lssl... yes
    checking for openssl/bio.h... yes
    checking for DTLS_method() in openssl/ssl.h... yes
    checking for TLS_server_method() in openssl/ssl.h... yes
    checking for SSL_CTX_set_min_proto_version in openssl/ssl.h... yes
    creating Makefile
    
    current directory: /Users/yamaryo/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/puma-4.3.5/ext/puma_http11
    make "DESTDIR=" clean
    
    current directory: /Users/yamaryo/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/puma-4.3.5/ext/puma_http11
    make "DESTDIR="
    compiling http11_parser.c
    ext/puma_http11/http11_parser.c:44:18: warning: unused variable 'puma_parser_en_main' [-Wunused-const-variable]
    static const int puma_parser_en_main = 1;
                     ^
    1 warning generated.
    compiling io_buffer.c
    compiling mini_ssl.c
    mini_ssl.c:145:7: warning: unused variable 'min' [-Wunused-variable]
      int min, ssl_options;
          ^
    mini_ssl.c:299:40: warning: function 'raise_error' could be declared with attribute 'noreturn' [-Wmissing-noreturn]
    void raise_error(SSL* ssl, int result) {
                                           ^
    2 warnings generated.
    compiling puma_http11.c
    puma_http11.c:203:22: error: implicitly declaring library function 'isspace' with type 'int (int)' [-Werror,-Wimplicit-function-declaration]
      while (vlen > 0 && isspace(value[vlen - 1])) vlen--;
                         ^
    puma_http11.c:203:22: note: include the header <ctype.h> or explicitly provide a declaration for 'isspace'
    1 error generated.
    make: *** [puma_http11.o] Error 1
    
    make failed, exit code 2
    
    Gem files will remain installed in /Users/yamaryo/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/puma-4.3.5 for inspection.
    Results logged to /Users/yamaryo/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/extensions/x86_64-darwin-19/2.6.0/puma-4.3.5/gem_make.out
    
    An error occurred while installing puma (4.3.5), and Bundler cannot continue.
    Make sure that `gem install puma -v '4.3.5' --source 'https://rubygems.org/'` succeeds before bundling.
    
    In Gemfile:
      puma
             run  bundle binstubs bundler
    Could not find gem 'sqlite3 (~> 1.4)' in any of the gem sources listed in your Gemfile.
             run  bundle exec spring binstub --all
    Could not find gem 'sqlite3 (~> 1.4)' in any of the gem sources listed in your Gemfile.
    Run `bundle install` to install missing gems.
           rails  webpacker:install
    Could not find gem 'sqlite3 (~> 1.4)' in any of the gem sources listed in your Gemfile.
    Run `bundle install` to install missing gems.
    [bash ./0706] $
    
[/code]

▼生成されたGemfile

[code]

    source 'https://rubygems.org'
    git_source(:github) { |repo| "https://github.com/#{repo}.git" }
    
    ruby '2.6.6'
    
    gem 'rails', '~> 6.0.3', '>= 6.0.3.2'
    gem 'sqlite3', '~> 1.4'
    gem 'puma', '~> 4.1'
    gem 'sass-rails', '>= 6'
    gem 'webpacker', '~> 4.0'
    gem 'turbolinks', '~> 5'
    gem 'jbuilder', '~> 2.7'
    gem 'bootsnap', '>= 1.4.2', require: false
    
    group :development, :test do
      gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
    end
    
    group :development do
      gem 'web-console', '>= 3.3.0'
      gem 'listen', '~> 3.2'
      gem 'spring'
      gem 'spring-watcher-listen', '~> 2.0.0'
    end
    
    group :test do
      gem 'capybara', '>= 2.15'
      gem 'selenium-webdriver'
      gem 'webdrivers'
    end
    
    # Windows does not include zoneinfo files, so bundle the tzinfo-data gem
    gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
    
[/code]

※エラーの際に「Could not find gem 'sqlite3 (~> 1.4)'」と言われますが、  
作成されたGemfileには「gem 'sqlite3', '~> 1.4'」の記載がある為  
bundle installすると'sqlite3'については消えました。

しかし'puma'はダメです・・  
▼rails new後、bundle installした際のエラー

[code]

    [bash ./app] $ bundle install
    
    ・
    ・
    ・
    Using rb-inotify 0.10.1
    Using listen 3.2.1
    Using method_source 1.0.0
    Fetching puma 4.3.5
    Installing puma 4.3.5 with native extensions
    Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
    
        current directory: /Users/yamaryo/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/puma-4.3.5/ext/puma_http11
    /Users/yamaryo/.rbenv/versions/2.6.6/bin/ruby -I /Users/yamaryo/.rbenv/versions/2.6.6/lib/ruby/2.6.0 -r ./siteconf20200706-5109-1rhex2m.rb
    extconf.rb --with-opt-dir\=/usr/local/opt/openssl
    checking for BIO_read() in -lcrypto... yes
    checking for SSL_CTX_new() in -lssl... yes
    checking for openssl/bio.h... yes
    checking for DTLS_method() in openssl/ssl.h... yes
    checking for TLS_server_method() in openssl/ssl.h... yes
    checking for SSL_CTX_set_min_proto_version in openssl/ssl.h... yes
    creating Makefile
    
    current directory: /Users/yamaryo/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/puma-4.3.5/ext/puma_http11
    make "DESTDIR=" clean
    
    current directory: /Users/yamaryo/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/puma-4.3.5/ext/puma_http11
    make "DESTDIR="
    compiling http11_parser.c
    ext/puma_http11/http11_parser.c:44:18: warning: unused variable 'puma_parser_en_main' [-Wunused-const-variable]
    static const int puma_parser_en_main = 1;
                     ^
    1 warning generated.
    compiling io_buffer.c
    compiling mini_ssl.c
    mini_ssl.c:145:7: warning: unused variable 'min' [-Wunused-variable]
      int min, ssl_options;
          ^
    mini_ssl.c:299:40: warning: function 'raise_error' could be declared with attribute 'noreturn' [-Wmissing-noreturn]
    void raise_error(SSL* ssl, int result) {
                                           ^
    2 warnings generated.
    compiling puma_http11.c
    puma_http11.c:203:22: error: implicitly declaring library function 'isspace' with type 'int (int)' [-Werror,-Wimplicit-function-declaration]
      while (vlen > 0 && isspace(value[vlen - 1])) vlen--;
                         ^
    puma_http11.c:203:22: note: include the header <ctype.h> or explicitly provide a declaration for 'isspace'
    1 error generated.
    make: *** [puma_http11.o] Error 1
    
    make failed, exit code 2
    
    Gem files will remain installed in /Users/yamaryo/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/puma-4.3.5 for inspection.
    Results logged to /Users/yamaryo/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/extensions/x86_64-darwin-19/2.6.0/puma-4.3.5/gem_make.out
    
    An error occurred while installing puma (4.3.5), and Bundler cannot continue.
    Make sure that `gem install puma -v '4.3.5' --source 'https://rubygems.org/'` succeeds before bundling.
    
    In Gemfile:
      puma
    [bash ./app] $
    
[/code]

「gem install puma -v '4.3.5'ができるか確認して」と言われるので・・

▼gem install puma -v '4.3.5'を実行した際のエラー

[code]

    [bash ./~] $ gem install puma -v '4.3.5' --source 'https://rubygems.org/'
    Building native extensions. This could take a while...
    ERROR:  Error installing puma:
        ERROR: Failed to build gem native extension.
    
        current directory: /Users/yamaryo/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/puma-4.3.5/ext/puma_http11
    /Users/yamaryo/.rbenv/versions/2.6.6/bin/ruby -I /Users/yamaryo/.rbenv/versions/2.6.6/lib/ruby/2.6.0 -r ./siteconf20200706-5247-aj1e4q.rb extconf.rb
    checking for BIO_read() in -lcrypto... yes
    checking for SSL_CTX_new() in -lssl... yes
    checking for openssl/bio.h... yes
    checking for DTLS_method() in openssl/ssl.h... yes
    checking for TLS_server_method() in openssl/ssl.h... yes
    checking for SSL_CTX_set_min_proto_version in openssl/ssl.h... yes
    creating Makefile
    
    current directory: /Users/yamaryo/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/puma-4.3.5/ext/puma_http11
    make "DESTDIR=" clean
    
    current directory: /Users/yamaryo/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/puma-4.3.5/ext/puma_http11
    make "DESTDIR="
    compiling http11_parser.c
    ext/puma_http11/http11_parser.c:44:18: warning: unused variable 'puma_parser_en_main' [-Wunused-const-variable]
    static const int puma_parser_en_main = 1;
                     ^
    1 warning generated.
    compiling io_buffer.c
    compiling mini_ssl.c
    mini_ssl.c:145:7: warning: unused variable 'min' [-Wunused-variable]
      int min, ssl_options;
          ^
    mini_ssl.c:299:40: warning: function 'raise_error' could be declared with attribute 'noreturn' [-Wmissing-noreturn]
    void raise_error(SSL* ssl, int result) {
                                           ^
    2 warnings generated.
    compiling puma_http11.c
    puma_http11.c:203:22: error: implicitly declaring library function 'isspace' with type 'int (int)' [-Werror,-Wimplicit-function-declaration]
      while (vlen > 0 && isspace(value[vlen - 1])) vlen--;
                         ^
    puma_http11.c:203:22: note: include the header <ctype.h> or explicitly provide a declaration for 'isspace'
    1 error generated.
    make: *** [puma_http11.o] Error 1
    
    make failed, exit code 2
    
    Gem files will remain installed in /Users/yamaryo/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/puma-4.3.5 for inspection.
    Results logged to /Users/yamaryo/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/extensions/x86_64-darwin-19/2.6.0/puma-4.3.5/gem_make.out
    [bash ./~] $
    
[/code]

※最初にも記載しましたが・・・  
ログを確認してみましたが、上記吐き出された内容と同様でした。解読が難しく対処方法がわからない状況です・・  
Results logged to
/Users/yamaryo/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/extensions/x86_64-darwin-19/2.6.0/puma-4.3.5/gem_make.out


CC BY-SA 4.0
2020-07-06T05:36:13.660
68331
2020-07-06T21:03:29.593
2020-07-06T21:03:29.593
2376
40948
question
ruby-on-rails ruby rubygems
Railsローカル環境構築にて、'puma'がインストールできないエラー「error occurred while installing puma (4.3.5)」


コンパイルの必要なGemのインストールで失敗する時は  
Xcodeのバージョンが原因のことがよくあるので一度Xcodeを最新にしてから

[code]

    gem install puma -v '4.3.5' --source 'https://rubygems.org/'
    
[/code]

でもう一度`puma`のインストールを試してみてください。


CC BY-SA 4.0
2020-07-06T10:06:57.183
68339
2020-07-06T10:06:57.183
3271
68331
answer


＞ironsand様  
Xcodeをインストールして、もう一度やりなおしたところ  
無事、rails new後にbundle installが成功しました！  
ありがとうございます！これで先に進めます！！

※Xcodeについて調べ直して気づいたのですが・・  
そもそもXcodeのappをしっかりインストールしていなかった恐れがあります・・  
Qiitaばかり見ているのですが、環境構築をhomebrewから開始する記事が多く  
Xcodeのappを見落としていたのが原因だったのかもしれませんが、真の原因はよくわかりません・・

＞shingo.nakanishi様  
pumaのgit拝見しました。4.3.5はなんらかの最新のコミットを取りこぼしているようですね・・  
pumaのgitを参照することも大事なんですね。勉強になりました！情報ありがとうございます！

先輩方、ご回答ありがとうございました！  
すみません、Xcodeインストール後やりなおしで  
"puma 4.3.5"は無事にインストール完了できていたので  
結局のところ私の環境準備不足だった恐れがあります(^^;)

進めてよかったです！  
一人で悩んでいたので大変たすかりました！ありがとうございました！

[code]

    $ bundle install
    ・
    ・
    Using method_source 1.0.0
    Using puma 4.3.5
    Using rack-proxy 0.6.5
    ・
    ・
    Bundle complete! 17 Gemfile dependencies, 74 gems now installed.
    Use `bundle info [gemname]` to see where a bundled gem is installed.
    
[/code]

▼インストール成功version

[code]

    $ xcodebuild -version
    Xcode 11.5
    Build version 11E608c
    
    $ brew --version
    Homebrew 2.4.3
    
    $ rbenv version
    2.6.6
    
    $ ruby -v
    ruby 2.6.6p146
    
    $ gem -v
    3.0.3
    
    $ bundler -v
    Bundler version 2.1.4
    
    $ rails -v
    Rails 6.0.3.2
    
[/code]


CC BY-SA 4.0
2020-07-06T16:30:53.393
68350
2020-07-06T16:30:53.393
40948
68331
answer