前提・実現したいこと
ruby 2.3.1
Rails 4.2.6
mysql (開発環境)
postgresql(heroku)
Railsアプリをherokuにデプロイしています。
herokuの設定を終え、
terminal
1git push heroku master
がうまくいきました。
しかし、次のコマンドを打ったところでエラーがでてしました。
terminal
1heroku run rails db:migrate
発生している問題・エラーメッセージ
stack level too deepのエラーが出ています。
herokuデプロイが初めてで、今回のエラー文にうまく対処できずにいます。
terminal
1/app/vendor/bundle/ruby/2.5.0/gems/bundler-1.15.2/exe/bundle:22:in `<top (required)>' 2/app/bin/bundle:3:in `load' 3/app/bin/bundle:3:in `<main>' 4Tasks: TOP => db:migrate => environment 5(See full trace by running task with --trace) 6Traceback (most recent call last): 7 8387: from /app/bin/bundle:3:in `<main>' 8 8386: from /app/bin/bundle:3:in `load' 9 8385: from /app/vendor/bundle/ruby/2.5.0/gems/bundler-1.15.2/exe/bundle:22:in `<top (required)>' 10 8384: from /app/vendor/bundle/ruby/2.5.0/gems/bundler-1.15.2/lib/bundler/friendly_errors.rb:120:in `with_friendly_errors' 11 8383: from /app/vendor/bundle/ruby/2.5.0/gems/bundler-1.15.2/lib/bundler/friendly_errors.rb:123:in `rescue in with_friendly_errors' 12 8382: from /app/vendor/bundle/ruby/2.5.0/gems/bundler-1.15.2/lib/bundler/friendly_errors.rb:45:in `log_error' 13 8381: from /app/vendor/bundle/ruby/2.5.0/gems/bundler-1.15.2/lib/bundler/friendly_errors.rb:95:in `request_issue_report_for' 14 8380: from /app/vendor/bundle/ruby/2.5.0/gems/bundler-1.15.2/lib/bundler/env.rb:18:in `report' 15 ... 8375 levels... 16 4: from /app/vendor/bundle/ruby/2.5.0/gems/activesupport-4.2.6/lib/active_support/core_ext/numeric/conversions.rb:131:in `block (2 levels) in <class:Numeric>' 17 3: from /app/vendor/bundle/ruby/2.5.0/gems/activesupport-4.2.6/lib/active_support/core_ext/numeric/conversions.rb:131:in `block (2 levels) in <class:Numeric>' 18 2: from /app/vendor/bundle/ruby/2.5.0/gems/activesupport-4.2.6/lib/active_support/core_ext/numeric/conversions.rb:131:in `block (2 levels) in <class:Numeric>' 19 1: from /app/vendor/bundle/ruby/2.5.0/gems/activesupport-4.2.6/lib/active_support/core_ext/numeric/conversions.rb:131:in `block (2 levels) in <class:Numeric>' 20/app/vendor/bundle/ruby/2.5.0/gems/activesupport-4.2.6/lib/active_support/core_ext/numeric/conversions.rb:131:in `block (2 levels) in <class:Numeric>': stack level too deep (SystemStackError)
該当のソースコード
Gemのバージョンが問題になるという記事がいくつかあったので、Gemfileを以下に置いておきます。
Gemfile
ruby
1source 'https://rubygems.org' 2 3 4# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' 5gem 'rails', '4.2.6' 6# Use mysql as the database for Active Record 7gem 'mysql2', '>= 0.3.13', '< 0.5', group: :development 8gem 'pg', group: :production 9# Use SCSS for stylesheets 10gem 'sass-rails', '~> 5.0' 11# Use Uglifier as compressor for JavaScript assets 12gem 'uglifier', '>= 1.3.0' 13# Use CoffeeScript for .coffee assets and views 14gem 'coffee-rails', '~> 4.1.0' 15# See https://github.com/rails/execjs#readme for more supported runtimes 16gem 'therubyracer', platforms: :ruby 17 18# Use jquery as the JavaScript library 19gem 'jquery-rails' 20# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks 21gem 'turbolinks' 22# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder 23gem 'jbuilder', '~> 2.0' 24# bundle exec rake doc:rails generates the API under doc/api. 25gem 'sdoc', '~> 0.4.0', group: :doc 26 27 28 29# Use ActiveModel has_secure_password 30# gem 'bcrypt', '~> 3.1.7' 31 32# Use Unicorn as the app server 33# gem 'unicorn' 34 35# Use Capistrano for deployment 36# gem 'capistrano-rails', group: :development 37 38group :development, :test do 39 # Call 'byebug' anywhere in the code to stop execution and get a debugger console 40 gem 'byebug' 41end 42 43 44 45group :development do 46 # Access an IRB console on exception pages or by using <%= console %> in views 47 gem 'web-console', '~> 2.0' 48 49 # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring 50 gem 'spring' 51end 52 53 gem 'pry-rails' 54 gem 'compass-rails','~> 2.0' 55 gem 'sprockets', '2.11.0' 56 gem 'devise' 57 gem 'omniauth' 58 gem 'omniauth-facebook' 59 gem 'omniauth-twitter' 60 gem 'bootstrap-sass' 61 gem 'dotenv-rails' 62 gem 'paperclip' 63 gem 'omniauth-instagram' 64 gem 'instagram' 65 gem 'friendly_id' 66 gem 'font-awesome-rails' 67 gem 'zeroclipboard-rails' 68 gem 'rails-i18n' 69 gem 'google-analytics-rails' 70 gem 'carrierwave' 71 gem 'acts_as_paranoid', '~> 0.6.0' 72 gem 'rails_12factor', group: :production 73
試したこと
Heroku の assets:precompile で エラーが起きたときの調査方法
https://mittsu-blog.com/how-to-cheack-heroku-assets-precompile-error
こちらの記事にあるように、Railsのバージョンが問題になるのでしょうか。
7年前の記事ですが、rails-saasのバージョンが問題だった質問
Getting “stack level too deep” error when deploying with Capistrano, Rails 3.1 ruby 1.9.2
英語で検索しいろいろ見てみましたが、対処法が見つからず。。。
補足情報(FW/ツールのバージョンなど)
エラー文から手がかりが掴めずに困っています。
追記
schema.rb
ruby
1# encoding: UTF-8 2# This file is auto-generated from the current state of the database. Instead 3# of editing this file, please use the migrations feature of Active Record to 4# incrementally modify your database, and then regenerate this schema definition. 5# 6# Note that this schema.rb definition is the authoritative source for your 7# database schema. If you need to create the application database on another 8# system, you should be using db:schema:load, not running all the migrations 9# from scratch. The latter is a flawed and unsustainable approach (the more migrations 10# you'll amass, the slower it'll run and the greater likelihood for issues). 11# 12# It's strongly recommended that you check this file into your version control system. 13 14ActiveRecord::Schema.define(version: 20190321185800) do 15 16 create_table "images", force: :cascade do |t| 17 t.string "image", limit: 255 18 t.integer "user_id", limit: 4 19 t.datetime "created_at", null: false 20 t.datetime "updated_at", null: false 21 end 22 23 create_table "items", force: :cascade do |t| 24 t.integer "user_id", limit: 4 25 t.text "text", limit: 65535 26 t.datetime "created_at", null: false 27 t.datetime "updated_at", null: false 28 t.boolean "check", default: false 29 t.datetime "deleted_at" 30 end 31 32 add_index "items", ["deleted_at"], name: "index_items_on_deleted_at", using: :btree 33 34 create_table "users", force: :cascade do |t| 35 t.string "email", limit: 255, default: "", null: false 36 t.string "encrypted_password", limit: 255, default: "", null: false 37 t.string "reset_password_token", limit: 255 38 t.datetime "reset_password_sent_at" 39 t.datetime "remember_created_at" 40 t.datetime "created_at", null: false 41 t.datetime "updated_at", null: false 42 t.string "uid", limit: 255 43 t.string "provider", limit: 255 44 t.string "avatar_file_name", limit: 255 45 t.string "avatar_content_type", limit: 255 46 t.integer "avatar_file_size", limit: 8 47 t.datetime "avatar_updated_at" 48 t.string "nickname", limit: 255 49 t.string "description", limit: 255 50 t.string "twitter", limit: 255 51 t.string "instagram", limit: 255 52 t.string "friendly_url", limit: 255 53 end 54 55 add_index "users", ["email"], name: "index_users_on_email", unique: true, using: :btree 56 add_index "users", ["friendly_url"], name: "index_users_on_friendly_url", unique: true, using: :btree 57 add_index "users", ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true, using: :btree 58 59end 60
こちらの記事にあるように、rails 4.2.6から rails 4.2.8にupdateしてみましたがエラーは解決しませんでした。。。
Ruby 2.4 and Rails 4 stack level too deep (SystemStackError)