質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Ruby

Rubyはプログラミング言語のひとつで、オープンソース、オブジェクト指向のプログラミング開発に対応しています。

Ruby on Rails

Ruby on Railsは、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Q&A

解決済

2回答

2660閲覧

rails newでプロジェクト作成時、bundle installでエラーとなる

Kosuke1024

総合スコア2

Ruby

Rubyはプログラミング言語のひとつで、オープンソース、オブジェクト指向のプログラミング開発に対応しています。

Ruby on Rails

Ruby on Railsは、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

0グッド

0クリップ

投稿2020/08/04 13:14

前提・実現したいこと

Ruby on Rails初学者です。
以下サイトのMAC OSセットアップに沿ってローカル環境構築を行っています。
https://railsgirls.jp/install

http://localhost:3000でページ表示させられるようにしたいのですが、以下の各コマンド実行時にエラーが表示されてしまい、進める事ができません。
解決策をご教示いただきたいです。

発生している問題・エラーメッセージ

rails new sampleを実行すると、bundle install以降で以下エラーメッセージが表示される

create tmp/storage create tmp/storage/.keep remove config/initializers/cors.rb remove config/initializers/new_framework_defaults_6_0.rb run bundle install The dependency tzinfo-data (>= 0) will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for x86-mingw32, x86-mswin32, x64-mingw32, java. To add those platforms to the bundle, run `bundle lock --add-platform x86-mingw32 x86-mswin32 x64-mingw32 java`. There was an error while trying to write to `/Users/kosuke-mac/.bundle/cache/compact_index/rubygems.org.443.29b0360b937aa4d161703e6160654e47/versions`. It is likely that you need to grant write permissions for that path. run bundle binstubs bundler Could not find gem 'rails (~> 6.0.3, >= 6.0.3.2)' in any of the gem sources listed in your Gemfile. run bundle exec spring binstub --all bundler: command not found: spring Install missing gem executables with `bundle install` rails webpacker:install Could not find gem 'rails (~> 6.0.3, >= 6.0.3.2)' in any of the gem sources listed in your Gemfile. Run `bundle install` to install missing gems.

cd sampleで移動し、rails g scaffold book rails db:migrate rails serverを実行すると以下メッセージが表示される

Could not find puma-4.3.5 in any of the sources Run `bundle install` to install missing gems.

試したこと

cd sampleで移動した状態で、bundle installを実行、以下メッセージが表示される

Installing listen 3.2.1 Fetching method_source 1.0.0 Installing 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/kosuke-mac/test_app/vendor/bundle/ruby/2.6.0/gems/puma-4.3.5/ext/puma_http11 /Users/kosuke-mac/.rbenv/versions/2.6.6/bin/ruby -I /Users/kosuke-mac/.rbenv/versions/2.6.6/lib/ruby/2.6.0 -r ./siteconf20200804-69826-14btqfh.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/kosuke-mac/test_app/vendor/bundle/ruby/2.6.0/gems/puma-4.3.5/ext/puma_http11 make "DESTDIR=" clean current directory: /Users/kosuke-mac/test_app/vendor/bundle/ruby/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/kosuke-mac/test_app/vendor/bundle/ruby/2.6.0/gems/puma-4.3.5 for inspection. Results logged to /Users/kosuke-mac/test_app/vendor/bundle/ruby/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

上記メッセージ内に記載のある、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/kosuke-mac/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/puma-4.3.5/ext/puma_http11 /Users/kosuke-mac/.rbenv/versions/2.6.6/bin/ruby -I /Users/kosuke-mac/.rbenv/versions/2.6.6/lib/ruby/2.6.0 -r ./siteconf20200804-83190-1flomnr.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/kosuke-mac/.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/kosuke-mac/.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/kosuke-mac/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/puma-4.3.5 for inspection. Results logged to /Users/kosuke-mac/.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

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答2

0

自己解決

自己解決しました。

bundle installの権限エラーについては、/Users/kosuke-mac/.bundle配下のユーザが一般とrootで混在していた為、sudo chown -Rコマンドで、配下のユーザをkosuke-mac:staffに変更。

これでbundle installは実行されるようになりました。
しかし以下エラーが発生します。

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.

こちらのエラーに関しては、インストールしていたXcodeアプリと、command line toolsのバージョン不一致によるものでした。Xcodeのバージョンが11.6だったので、手動で一番近いバージョン11.5のcommand line toolsをインストールし、再度bundle install実行で正常に完了しました。

rails server実行の後、localhost:3000でブラウザアクセスも問題なくできました。

投稿2020/08/05 15:54

Kosuke1024

総合スコア2

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

0

bundle install が完了していないので、その先をやってもエラーになります。
一般ユーザに書き込み権が無いところにgemを置こうとしています。
それもありです。がその場合は途中でパスワードの入力を求められると思うのですがありませんでしたか?
とすると あなたにはrootに成り代わる権限がないのかもしれません。
その場合は
bundle install --path vendor/bundle
としてください。

投稿2020/08/04 23:12

winterboum

総合スコア23347

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

Kosuke1024

2020/08/05 07:10

bundle install --path vendor/bundle 上記実行しましたが、権限エラーがでてしまったので、sudoで実行しました。 パスワード入力を求められ、実行しますが以下同様にエラーが出てしまいます。 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.
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問