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

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

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

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

Ruby on Rails

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

Q&A

解決済

3回答

2083閲覧

railsチュートリアル rails serverが起動しない

takuo5

総合スコア48

Ruby

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

Ruby on Rails

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

0グッド

1クリップ

投稿2019/10/30 05:53

前提・実現したいこと

railsチュートリアル1章の環境構築のところでつまづきました。リンク内容
手順に沿ってrailsをインストールした後、gemfileでバージョンを指定してbundle installしました。
そしてrails serverをターミナルで実行すると下記のようなエラーが出ました。

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

/home/ec2-user/.rvm/gems/ruby-2.6.3/gems/activesupport-4.2.2/lib/active_support/core_ext/numeric/conversions.rb:131:in `block (2 levels) in <class:Numeric>': stack level too deep (SystemStackError)

該当のソースコード

Gemfile

1source 'https://rubygems.org' 2 3 4# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' 5gem 'rails', '4.2.2' 6 7# Use SCSS for stylesheets 8gem 'sass-rails', '5.0.2' 9# Use Uglifier as compressor for JavaScript assets 10gem 'uglifier', '2.5.3' 11# Use CoffeeScript for .coffee assets and views 12gem 'coffee-rails', '4.1.0' 13# See https://github.com/rails/execjs#readme for more supported runtimes 14# gem 'therubyracer', platforms: :ruby 15 16# Use jquery as the JavaScript library 17gem 'jquery-rails', '4.0.3' 18# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks 19gem 'turbolinks', '2.3.0' 20# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder 21gem 'jbuilder', '2.2.3' 22# bundle exec rake doc:rails generates the API under doc/api. 23gem 'sdoc', '0.4.0', group: :doc 24 25# Use ActiveModel has_secure_password 26# gem 'bcrypt', '~> 3.1.7' 27 28# Use Unicorn as the app server 29# gem 'unicorn' 30 31# Use Capistrano for deployment 32# gem 'capistrano-rails', group: :development 33 34group :development, :test do 35 # Use sqlite3 as the database for Active Record 36 gem 'sqlite3', '1.3.9' 37 # Call 'byebug' anywhere in the code to stop execution and get a debugger console 38 gem 'byebug', '3.4.0' 39 40 # Access an IRB console on exception pages or by using <%= console %> in views 41 gem 'web-console', '2.0.0.beta3' 42 43 # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring 44 gem 'spring', '1.1.3' 45end 46 47 48

試したこと

下記の手順でrailsのバージョンを変更して試してみようと思いましたがうまくいきませんでした。
1.gemfileのrailsのバージョンを'5.1.0'に変更
2.再度bundle installを実行
3.下記のエラーが出ました

Resolving dependencies...
Bundler could not find compatible versions for gem "activesupport":
In Gemfile:
jbuilder (= 2.2.3) was resolved to 2.2.3, which depends on
activesupport (>= 3.0.0, < 5)

rails (= 5.1.0) was resolved to 5.1.0, which depends on activesupport (= 5.1.0)

Bundler could not find compatible versions for gem "coffee-rails":
In Gemfile:
coffee-rails (= 4.1.0)

turbolinks (= 2.3.0) was resolved to 2.3.0, which depends on coffee-rails

補足情報(FW/ツールのバージョンなど)

AWS Cloud9

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

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

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

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

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

guest

回答3

0

railsのバージョンが古いです。
5に上げるか、4系ならば4.2.11にしてください。

https://github.com/rails/rails/pull/25161

投稿2019/10/30 06:34

編集2019/10/30 06:35
退会済みユーザー

退会済みユーザー

総合スコア0

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

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

0

ベストアンサー

試したことの方を簡単に説明すると、

・railsで関連しているactivesupportは5.1.0のバージョンが必要です。
・jbuilder2.2.3のバージョンだとactivesupportは3.0.0以上5以下でないと行けないです。
片方は5.1.0出ないといけないのに、もう片方は5以下でないといけない、というので衝突してしまっています。
これを解決する方法としては、jbuilderのバージョンを確認できるサイトに行き、RUNTIME依存性のところが要件を満たすバージョンに直してあげることです。

coffee-railsも同様です。

この問題がクリアになったら新しいエラーにぶつかる可能性がありますが、そのときはまた質問してください。

投稿2019/10/30 06:03

退会済みユーザー

退会済みユーザー

総合スコア0

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

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

takuo5

2019/11/03 01:18

ご回答いただきましてありがとうございます。 それとご返信に時間がかかってしまって大変申し訳ございません。 上記のサイトでjbuilderのバージョンが2.9.1が最新であったのでGemfaileで2.9.1に変更してbundle installを実行しましたところ下記のようなエラーが表示されました。 Bundler could not find compatible versions for gem "actionpack": In snapshot (Gemfile.lock): actionpack (= 4.2.2) In Gemfile: rails (= 5.0.1) was resolved to 5.0.1, which depends on actionpack (= 5.0.1) sass-rails (= 5.0.2) was resolved to 5.0.2, which depends on railties (>= 4.0.0, < 5.0) was resolved to 4.2.2, which depends on actionpack (= 4.2.2) Running `bundle update` will rebuild your snapshot from scratch, using only the gems in your Gemfile, which may resolve the conflict. 最終行でbundle updateを実行するようにかかれているのでbundle updateを実行すると下記のエラーが表示されました。 Bundler could not find compatible versions for gem "activemodel": In Gemfile: rails (= 5.0.1) was resolved to 5.0.1, which depends on activemodel (= 5.0.1) web-console (= 2.0.0.beta3) was resolved to 2.0.0.beta3, which depends on activemodel (~> 4.0) Bundler could not find compatible versions for gem "activesupport": In Gemfile: jbuilder (= 2.9.1) was resolved to 2.9.1, which depends on activesupport (>= 4.2.0) rails (= 5.0.1) was resolved to 5.0.1, which depends on activesupport (= 5.0.1) Bundler could not find compatible versions for gem "coffee-rails": In Gemfile: coffee-rails (= 4.1.0) turbolinks (= 2.3.0) was resolved to 2.3.0, which depends on coffee-rails 上記の意味がよくわからなくてつまずいております。 ご助言をいただければ幸いです。
退会済みユーザー

退会済みユーザー

2019/11/03 02:39

記載されてるエラーの概要は同じなので、activemodelのバージョンとactive record、coffee-railsのバージョンを、書かれている条件を満たすようにしてみてください。 coffee railsを例に挙げるなら、今は4.1.0が入っているのですが、turbolinks (= 2.3.0)のバージョンだと依存関係のcoffee railsのバージョンが違うというふうに怒られているかと思います。 前回共有したjbuilderのバージョンが見られるサイトで、turbo linksのバージョンを確認して、依存関係にあるcoffee railsのバージョンを満たすバージョンに変えてみてください。
退会済みユーザー

退会済みユーザー

2019/11/03 02:41

要は、jbuilderのバージョン上げて、そのバージョンで依存しているgemのバージョンが変わったから、他のgemのバージョンも更新してやーってことです。
takuo5

2019/11/03 08:16

ありがとうございます。 coffee-railsは最新の5.0.0に変更してみようと思います。 activesupportとactivemodelなのですが、これらはgemfileに記載されていないのですが、追記をすればよいでしょうか?
退会済みユーザー

退会済みユーザー

2019/11/03 10:42

一度試してみてください。 それでエラーが出たら教えてください。 勉強してるうちは何事もトライアンドエラーでやってみましょう。
takuo5

2019/11/04 03:03

ありがとうございます。 下記の通り追記してbundle updateを実行してみました。 gem 'activesupport', '5.0.1' gem 'activemodel', '5.0.1' すると表示されたのは以下のものです。 Bundler could not find compatible versions for gem "activemodel": In Gemfile: rails (= 5.0.1) was resolved to 5.0.1, which depends on activemodel (= 5.0.1) web-console (= 2.0.0.beta3) was resolved to 2.0.0.beta3, which depends on activemodel (~> 4.0) Bundler could not find compatible versions for gem "activesupport": In Gemfile: jbuilder (= 2.9.1) was resolved to 2.9.1, which depends on activesupport (>= 4.2.0) rails (= 5.0.1) was resolved to 5.0.1, which depends on activesupport (= 5.0.1) activesupportとactivemodelのバージョンは上記のエラーメッセージに表示されている条件は満たしていると思いますが、インストールが適用されていないのでしょうか。 なにか書き込みの方法を変える必要があるのでしょうか。ちなみに現在のGemfileの中身は下記のとおりです。 source 'https://rubygems.org' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '5.0.1' # Use SCSS for stylesheets gem 'sass-rails', '5.0.2' # Use Uglifier as compressor for JavaScript assets gem 'uglifier', '2.5.3' # Use CoffeeScript for .coffee assets and views gem 'coffee-rails', '5.0.0' # See https://github.com/rails/execjs#readme for more supported runtimes # gem 'therubyracer', platforms: :ruby # Use jquery as the JavaScript library gem 'jquery-rails', '4.0.3' # Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks gem 'turbolinks', '5.2.1' # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder gem 'jbuilder', '2.9.1' # bundle exec rake doc:rails generates the API under doc/api. gem 'sdoc', '0.4.0', group: :doc gem 'activesupport', '5.0.1' gem 'activemodel', '5.0.1' # Use ActiveModel has_secure_password # gem 'bcrypt', '~> 3.1.7' # Use Unicorn as the app server # gem 'unicorn' # Use Capistrano for deployment # gem 'capistrano-rails', group: :development group :development, :test do # Use sqlite3 as the database for Active Record gem 'sqlite3', '1.3.9' # Call 'byebug' anywhere in the code to stop execution and get a debugger console gem 'byebug', '3.4.0' # Access an IRB console on exception pages or by using <%= console %> in views gem 'web-console', '2.0.0.beta3' # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring gem 'spring', '1.1.3' end
takuo5

2019/11/04 05:08

bundle インストールも試しました。 bundle updateと同じメッセージが表示されています。 $ bundle install Fetching gem metadata from https://rubygems.org/............. Fetching gem metadata from https://rubygems.org/. Resolving dependencies... Bundler could not find compatible versions for gem "activemodel": In Gemfile: rails (= 5.0.1) was resolved to 5.0.1, which depends on activemodel (= 5.0.1) web-console (= 2.0.0.beta3) was resolved to 2.0.0.beta3, which depends on activemodel (~> 4.0) Bundler could not find compatible versions for gem "activesupport": In Gemfile: jbuilder (= 2.9.1) was resolved to 2.9.1, which depends on activesupport (>= 4.2.0) rails (= 5.0.1) was resolved to 5.0.1, which depends on activesupport (= 5.0.1) bundle installとbundle updateの違い、教えていただきましてありがとうございます。 先程、違うエラーが起こった際にgem.lockのファイルは削除してしまったのですがこちらはまずかったでしょうか。。。 バージョンについてもわかりやすい説明の記事を教えていただきありがとうございます。 それを理解した上でわかったのは、activemodelがrailsでは5.0.1が必要なのですが、web-consoleでは5より古いものでないといけないとなります。 activesupportもほぼ同様の問題にあたっていますがこちらはどのように解決すればよいでしょうか?
退会済みユーザー

退会済みユーザー

2019/11/04 05:36

rails5.0.1に対応するactivemodelのバージョンを満たすように、web console自体のバージョンにあげましょう。 https://rubygems.org/gems/web-console/versions/3.1.1 2.0.0.beta3はrails4の頃に作られたバージョンのようです。 基本、一度rails4で作ったプロジェクトをrails5に上げたら、全体的にrails5に対応するバージョンにあげてあげる必要があります。
退会済みユーザー

退会済みユーザー

2019/11/04 06:38 編集

今gemfileに明示的にバージョンが書かれていますが、最初の質問から察するに、書かれている物は基本的にrails4を想定しているものばかりですよね? もし詰まるようなら、rails5での環境構築をしている記事を参考にしてやり直した方が確実かとおもいますよ。
asm

2019/11/04 08:59

rails4で作成されたプロジェクトに参加するために学習するってなら話は別ですが、 基本的にhttps://railstutorial.jp/?version=5.1 こっちを見たほうがいいです。
takuo5

2019/11/04 09:22

Manabukuritaさん 本日一日中あれこれやってみましたが解決しなかったです。一度最初からやり直してみます。 実はチュートリアルは一応1回終了していて、まだまだわからない所だらけだったので今回復習しようともう一度挑戦しています。1回目はできていたのでできると信じて1からやり直してみます。 構築うまくいきましたらまたご連絡します。 asmさん コメントありがとうございます。できるだけチュートリアルに支持されているバージョンで環境構築できるよう努めてみます。
takuo5

2019/11/04 10:47

先程、1からやり直してみるとうまく全てインストールすることができました。 細かい原因等はわかりませんが、事の発端は私が間違えて古いチュートリアルのページで進めようとしてたことにあると思います。投稿の冒頭に貼り付けたリンクに飛んでみると第3版(Rails 4.2)のものが表示されました。 asmさんはこれをご指摘されていたのですね。ありがとうございます。 ManabuKuritaさん いろいろとご指導いただきましてありがとうございました。 教えていただいたことは忘れないようにしっかりと復習しておきます。
guest

0

jbuilderのバージョンを上げる必要があります。

投稿2019/10/30 06:02

Mugheart

総合スコア2344

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

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

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

ただいまの回答率
85.48%

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

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

質問する

関連した質問