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

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

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

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

Heroku

HerokuはHeroku社が開発と運営を行っているPaaSの名称です。RubyやNode.js、Python、そしてJVMベース(Java、Scala、Clojureなど)の複数のプログラミング言語をサポートしている。

Q&A

0回答

430閲覧

rails6のアプリをherokuへデプロイしようとした際のエラー

Tom-SAS

総合スコア0

Ruby on Rails 6

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

Heroku

HerokuはHeroku社が開発と運営を行っているPaaSの名称です。RubyやNode.js、Python、そしてJVMベース(Java、Scala、Clojureなど)の複数のプログラミング言語をサポートしている。

0グッド

0クリップ

投稿2021/10/02 08:16

やろうとしたこと

rails6で制作したアプリをデプロイしようとしたところエラーが発生し、行き詰まりました。

やったこと

HerokuCLIをインストール

%brew tap heroku/brew && brew install heroku 中略 ==> Upgrading heroku/brew/heroku 7.54.1 -> 7.59.0

Herokuのバージョン確認

%heroku --version heroku/7.59.0 darwin-x64 node-v12.21.0

ログイン

% heroku login --interactive Logged in as **************@********.co.jp

heroku上にアプリ名のディレクトリを作成

%heroku create icokkatest Name icokkatest is already taken

正しくできたことの確認

%git config --list | grep heroku remote.heroku.url=https://git.heroku.com/icokkatest.git remote.heroku.fetch=+refs/heads/*:refs/remotes/heroku/*

ClearDBアドオンの追加

%heroku addons:add cleardb Creating cleardb on ⬢ icokkatest... free Created cleardb-trapezoidal-53860 as CLEARDB_GREEN_URL Use heroku addons:docs cleardb to view documentation

設定変更

% heroku_cleardb=`heroku config:get CLEARDB_DATABASE_URL` matsudatomohiro@Toms-MacBook-Pro icokkatest % heroku config:set DATABASE_URL=mysql2${heroku_cleardb:5} Setting DATABASE_URL and restarting ⬢ icokkatest... done, v11 DATABASE_URL: mysql2://****************@us-cdbr-east-04.cleardb.com/heroku_******************?reconnect=true

暗号化の中身確認

% EDITOR="vi" bin/rails credentials:edit File encrypted and saved.

コミット、プッシュしてmasterブランチへ反映させる。
heroku上で環境変数を設定

% heroku config:set RAILS_MASTER_KEY=`cat config/master.key` Setting RAILS_MASTER_KEY and restarting ⬢ icokkatest... done, v11 RAILS_MASTER_KEY: ***********************

環境変数を確認

% heroku config === icokkatest Config Vars CLEARDB_DATABASE_URL: mysql://*************@us-cdbr-east-04.cleardb.com/heroku_**************?reconnect=true CLEARDB_GREEN_URL: mysql://***************@us-cdbr-east-04.cleardb.com/heroku_*******************?reconnect=true DATABASE_URL: mysql2://*****************@us-cdbr-east-04.cleardb.com/heroku_*******************?reconnect=true RAILS_MASTER_KEY: ********************************

Stackを指定

% heroku stack:set heroku-18 -a icokkatest Setting stack to heroku-18... done

heroku上へアプリケーションをプッシュ

% git push heroku master

問題点

以下のようにビルドに失敗します。

remote: ! Precompiling assets failed. remote: ! remote: ! Push rejected, failed to compile Ruby app. remote: remote: ! Push failed

ログを読んでいくと以下の文言があったので、こちらが原因ではないかと考えて調べました。

NoMethodError: undefined method `[]' for nil:NilClass

herokuのログを調べたところ、こちらのメッセージが出てました。

https://dashboard.heroku.com/apps/f496a726-dbe1-418f-b082-e162bc26eac0/activity/builds/1d08535c-fd66-4580-8ba7-6ce7fe04386b

私にはこちらの情報からは特にどういったことをすれば良いのか解決策が見つからず困っております。
大変お手数ですが、どなたかご協力いただけるとありがたいです。

ターミナル 上の結果(全文)

Enumerating objects: 466, done. Counting objects: 100% (466/466), done. Delta compression using up to 8 threads Compressing objects: 100% (434/434), done. Writing objects: 100% (466/466), 759.33 KiB | 13.32 MiB/s, done. Total 466 (delta 178), reused 0 (delta 0) remote: Compressing source files... done. remote: Building source: remote: remote: -----> Building on the Heroku-18 stack remote: -----> Determining which buildpack to use for this app remote: ! Warning: Multiple default buildpacks reported the ability to handle this app. The first buildpack in the list below will be used. remote: Detected buildpacks: Ruby,Node.js remote: See https://devcenter.heroku.com/articles/buildpacks#buildpack-detect-order remote: -----> Ruby app detected remote: -----> Installing bundler 2.2.21 remote: -----> Removing BUNDLED WITH version in the Gemfile.lock remote: -----> Compiling Ruby/Rails remote: -----> Using Ruby version: ruby-2.6.5 remote: -----> Installing dependencies using bundler 2.2.21 remote: Running: BUNDLE_WITHOUT='development:test' BUNDLE_PATH=vendor/bundle BUNDLE_BIN=vendor/bundle/bin BUNDLE_DEPLOYMENT=1 bundle install -j4 remote: Fetching gem metadata from https://rubygems.org/ remote: Fetching gem metadata from https://rubygems.org/............ 中略 remote: Installing rails 6.0.4.1 remote: Fetching webpacker 4.3.0 remote: Fetching sass-rails 5.1.0 remote: Fetching devise 4.8.0 remote: Installing sass-rails 5.1.0 remote: Installing devise 4.8.0 remote: Installing webpacker 4.3.0 remote: Bundle complete! 26 Gemfile dependencies, 76 gems now installed. remote: Gems in the groups 'development' and 'test' were not installed. remote: Bundled gems are installed into `./vendor/bundle` remote: Post-install message from sass: remote: remote: Ruby Sass has reached end-of-life and should no longer be used. remote: remote: * If you use Sass as a command-line tool, we recommend using Dart Sass, the new remote: primary implementation: https://sass-lang.com/install remote: remote: * If you use Sass as a plug-in for a Ruby web framework, we recommend using the remote: sassc gem: https://github.com/sass/sassc-ruby#readme remote: remote: * For more details, please refer to the Sass blog: remote: https://sass-lang.com/blog/posts/7828841 remote: remote: Bundle completed (31.12s) remote: Cleaning up the bundler cache. remote: -----> Installing node-v12.16.2-linux-x64 remote: -----> Installing yarn-v1.22.4 remote: -----> Detecting rake tasks remote: -----> Preparing app for Rails asset pipeline remote: Running: rake assets:precompile remote: yarn install v1.22.4 remote: [1/4] Resolving packages... remote: [2/4] Fetching packages... remote: info fsevents@2.3.2: The platform "linux" is incompatible with this module. remote: info "fsevents@2.3.2" is an optional dependency and failed compatibility check. Excluding it from installation. remote: info fsevents@1.2.13: The platform "linux" is incompatible with this module. remote: info "fsevents@1.2.13" is an optional dependency and failed compatibility check. Excluding it from installation. remote: [3/4] Linking dependencies... remote: warning " > webpack-dev-server@4.2.0" has unmet peer dependency "webpack@^4.37.0 || ^5.0.0". remote: warning "webpack-dev-server > webpack-dev-middleware@5.1.0" has unmet peer dependency "webpack@^4.0.0 || ^5.0.0". remote: [4/4] Building fresh packages... remote: Done in 27.16s. remote: yarn install v1.22.4 remote: [1/4] Resolving packages... remote: [2/4] Fetching packages... remote: info fsevents@2.3.2: The platform "linux" is incompatible with this module. remote: info "fsevents@2.3.2" is an optional dependency and failed compatibility check. Excluding it from installation. remote: info fsevents@1.2.13: The platform "linux" is incompatible with this module. remote: info "fsevents@1.2.13" is an optional dependency and failed compatibility check. Excluding it from installation. remote: [3/4] Linking dependencies... remote: warning " > webpack-dev-server@4.2.0" has unmet peer dependency "webpack@^4.37.0 || ^5.0.0". remote: warning "webpack-dev-server > webpack-dev-middleware@5.1.0" has unmet peer dependency "webpack@^4.0.0 || ^5.0.0". remote: [4/4] Building fresh packages... remote: Done in 5.51s. 中略 remote: /tmp/build_e1a02662/vendor/bundle/ruby/2.6.0/gems/sprockets-rails-3.2.2/lib/sprockets/rails/task.rb:66:in `block (2 levels) in define' remote: Tasks: TOP => assets:precompile remote: (See full trace by running task with --trace) remote: remote: ! remote: ! Precompiling assets failed. remote: ! remote: ! Push rejected, failed to compile Ruby app. remote: remote: ! Push failed remote: ! remote: ! ## Warning - The same version of this code has already been built: 4c12e116d989c469fd267deaef07e2f505e902f2 remote: ! remote: ! We have detected that you have triggered a build from source code with version 4c12e116d989c469fd267deaef07e2f505e902f2 remote: ! at least twice. One common cause of this behavior is attempting to deploy code from a different branch. remote: ! remote: ! If you are developing on a branch and deploying via git you must run: remote: ! remote: ! git push heroku <branchname>:main remote: ! remote: ! This article goes into details on the behavior: remote: ! https://devcenter.heroku.com/articles/duplicate-build-version remote: remote: Verifying deploy... remote: remote: ! Push rejected to icokkatest. remote: To https://git.heroku.com/icokkatest.git ! [remote rejected] master -> master (pre-receive hook declined) error: failed to push some refs to 'https://git.heroku.com/icokkatest.git'

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

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

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

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

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

guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだ回答がついていません

会員登録して回答してみよう

アカウントをお持ちの方は

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

ただいまの回答率
85.48%

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

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

質問する

関連した質問