@quiquiquipuipuipui (_ _)

Are you sure you want to delete the question?

If your question is resolved, you may close it.

Leaving a resolved question undeleted may help others!

We hope you find it useful!

rails serverが実行できない

解決したいこと

動画でRuby on Railsを勉強しています。
「内蔵サーバーの起動」のステップで、「rails server」を実行してもうまくいきません。
(動画では「bin/rails server」と打ち込んで実行していましたが、私の方ではエラーが出たため「rails server」と打つ方法に行きつきました)
分からない単語が多く、初心者で何をすればいいか分からず困っています。

windows10/Rails 5.1.3/ruby 2.3.3p222

発生している問題・エラー

Could not find gem 'puma(^>3.7) x86-mingw32' in any of the gem source listed in your Gemfile.
Run 'bundle install' to install missing gems.

該当するソースコード

rails server

自分で試したこと

1.「bundle install」を実行
・エラー文が出る
bundle install.png

2.「gem update --system」を実行
・エラー文が出る
gem update.png

3.1つ上の階層にcdで移動して「rails server」を実行してみる
https://qiita.com/Leone/items/dc7f8ef2d5329d297e72
こちらのサイトの「3.陥った状況」のような長文が表れる

参考サイト
https://julie-dayo.net/it/bundle_install/

0 likes

5Answer

ssl証明書の有効期限切れですね。

[公式](https://bundler.io/v2.0/guides/rubygems_tls_ssl_troubleshooting_guide.html#troubleshooting-certificate-errors, ‘bundler’)の説明によると

[証明書](https://raw.githubusercontent.com/rubygems/rubygems/master/lib/rubygems/ssl_certs/rubygems.org/GlobalSignRootCA_R3.pem, ‘github’)ここから、新しい証明書ダウンロード

C:\> gem which rubygems
表示された、パスをメモって
C:/Ruby21/lib/ruby/2.1.0/rubygems.rb

C:\>start C:\Ruby21\lib\ruby\2.1.0\rubygemsこんな感じに、頭にstart+さっきのパス

で、ssl_certsというフォルダを探して、ダウンロードした証明書を中にフォルダー内にポイっ。

で、治ると思います。

0Like

Comments

  1. 1.サイトから「GlobalSignRootCA_R3.pem」をダウンロード
    2.コマンドプロンプトにて「gem which rubygems」と打ち込むとパスが出てくる
    3.「start 」の後ろに先ほどのパスを(「/」を「\」にして)打ち込む
    4.「ssl」というフォルダの中に「certs」というフォルダがあり、その中に初めにダウンロードした「GlobalSignRootCA_R3.pem」を移動させる

    こちらを試し、念のため再起動をしてみました。
    その後、「rails server」や「bimdle install」を試しましたが、質問時と状況が変わりませんでした…

@Inp さんは、ssl_certs というフォルダ と書かれていますが、@quiquiquipuipuipui さんは sslというフォルダの中にcertsというフォルダ と違うところを見ています。

これが原因とは考えられないですか?

0Like

Comments

  1. もう一度確認したところ、「gem which rubygems」と打ち込んで出たパスをstartさせてもエクスプローラーが表示されなかったため、勘違いで間違ったフォルダ(sslフォルダ)に入れてしまっていたようでした。
    表示されたパス通りに自力でフォルダを辿ると、無事「ssl_certs」というフォルダが見つけられました。ありがとうございました!

    しかし、次は「rails server」のエラー文

    Could not find gem 'web-console (>= 3.3.0)' in rubygems repository https://rubygems.org/ or installed locally.
    The source does not contain any versions of 'web-console'
    Run `bundle install` to install missing gems.

    が出てしまい、調べても良く分からずつまずいています…

回答者様の回答の通りに実行し、無事**「gem update --system」**を実行できました。
しかし、rails serverのエラーでまたつまずいています。

##「gem update --system」の後にやったこと##
・「bundle install」を試すと、エラー文とは異なる長文が表示され(成功?)最終行に「Could not locate Gemfile」と表示されました。
・もう一度「bundle install」を試すと、

Fetching gem metadata from https://rubygems.org/.............
Resolving dependencies...............
nokogiri-1.11.2-x86-mingw32 requires ruby version >= 2.5, < 3.1.dev, which is
incompatible with the current version, ruby 2.3.3p222

と表示されました。

・その後、「rails server」を試すと、エラー文

Could not find gem 'uglifier (>= 1.3.0)' in rubygems repository https://rubygems.org/ or installed locally.
The source does not contain any versions of 'uglifier'
Run `bundle install` to install missing gems.

が出ましたが、これについては
https://qiita.com/htk_jp/items/1100a04f45151c928378
↑こちらの記事を参考にし、解決しました(gem install turbolinksも実行しました)

・再度「rails server」を試すと、エラー文

Could not find gem 'web-console (>= 3.3.0)' in rubygems repository https://rubygems.org/ or installed locally.
The source does not contain any versions of 'web-console'
Run `bundle install` to install missing gems.

が表示されました。
こちらは調べても解決法が見つけられませんでした。

0Like

nokogiri-1.11.2-x86-mingw32 requires ruby version >= 2.5, < 3.1.dev, which is
incompatible with the current version, ruby 2.3.3p222

と表示されているように、Rubyのバージョンが低すぎるからだと思われます。
Rubyのバージョンを2.5以上にすれば解決するでしょう。

バージョンをあげれない場合は・・・どうしたらいいんでしょうねぇ・・・。

0Like

Comments

  1. 回答ありがとうございます。
    Railsinstallerをアンインストールし、Ruby3.0.0とRails5.1.7をインストールしました。
    gem update --systemとbundle installを実行した後rails serverを実行すると、

    => Booting Puma
    => Rails 5.1.7 application starting in development
    => Run `rails server -h` for more startup options
    Exiting
    C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/actionpack-5.1.7/lib/action_dispatch/middleware/static.rb:109:in `initialize': wrong number of arguments (given 3, expected 2) (ArgumentError)

    と表示され、その下に

    from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/actionpack-5.1.7/lib/action_dispatch/middleware/stack.rb:35:in `new'

    こちらと同じような文が数行にわたり表示されました。
    どのように対処すればいいでしょうか。

wrong number of arguments (given 3, expected 2)

と出ているように、引数が一致していないのが問題のようです(渡している引数が多すぎる)。
これはrails server呼び出しの際の引数の問題なのが、rails内部のミスマッチの問題なのかは、フレームワークのソースを読むしかなさそうです。

0Like

Comments

  1. フレームワークのソースは、どこを開けば読めますか?

Your answer might help someone💌