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

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

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

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

Heroku

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

Ruby on Rails

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

サーバ

サーバは、 クライアントサーバモデルにおいてクライアントからの要求に対し 何らかのサービスを提供するプログラムを指す言葉です。 また、サーバーソフトウェアを稼動させているコンピュータ機器そのもののことも、 サーバーと呼ぶ場合もあります。

Q&A

0回答

945閲覧

ruby で制作したアプリを herokuにpushすると「Precompiling assets failed.」とエラーが出る

hirotech3

総合スコア2

Ruby

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

Heroku

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

Ruby on Rails

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

サーバ

サーバは、 クライアントサーバモデルにおいてクライアントからの要求に対し 何らかのサービスを提供するプログラムを指す言葉です。 また、サーバーソフトウェアを稼動させているコンピュータ機器そのもののことも、 サーバーと呼ぶ場合もあります。

0グッド

0クリップ

投稿2021/06/15 03:56

編集2021/06/20 01:56

前提・実現したいこと

Ruby on Rails でアプリを作成しローカル環境では正常に動作しました。
それをherokuをもちいてアップロードしたいです。

https://qiita.com/kazukimatsumoto/items/a0daa7281a3948701c39
を参考に操作を進めました。

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

terminal

1git push heroku master

を実行すると

terminal

1remote: -----> Detecting rake tasks 2remote: -----> Preparing app for Rails asset pipeline 3remote: Running: rake assets:precompile 4remote: rake aborted! 5remote: Sprockets::Railtie::ManifestNeededError: Expected to find a manifest file in `app/assets/config/manifest.js` 6remote: But did not, please create this file and use it to link any assets that need 7remote: to be rendered by your app: 8remote: 9remote: Example: 10remote: //= link_tree ../images 11remote: //= link_directory ../javascripts .js 12remote: //= link_directory ../stylesheets .css 13remote: and restart your server 14remote: 15remote: For more information see: https://github.com/rails/sprockets/blob/070fc01947c111d35bb4c836e9bb71962a8e0595/UPGRADING.md#manifestjs 16 17(中略) 18 19remote: ! Precompiling assets failed. 20remote: ! 21remote: ! Push rejected, failed to compile Ruby app. 22remote: 23remote: ! Push failed 24remote: ! 25remote: ! ## Warning - The same version of this code has already been built: 54cb7a80eb8c20c1ec95267c9ae553c7f2a3d705 26remote: ! 27remote: ! We have detected that you have triggered a build from source code with version 54cb7a80eb8c20c1ec95267c9ae553c7f2a3d705 28remote: ! at least twice. One common cause of this behavior is attempting to deploy code from a different branch. 29remote: ! 30remote: ! If you are developing on a branch and deploying via git you must run: 31remote: ! 32remote: ! git push heroku <branchname>:main 33remote: ! 34remote: ! This article goes into details on the behavior: 35remote: ! https://devcenter.heroku.com/articles/duplicate-build-version 36remote: 37remote: Verifying deploy... 38remote: 39remote: ! Push rejected to <アプリ名>. 40remote: 41To https://git.heroku.com/<アプリ名>.git 42 ! [remote rejected] master -> master (pre-receive hook declined) 43error: failed to push some refs to 'https://git.heroku.com/<アプリ名>.git'

と表示され実行できません。

試したこと

多くのサイトに以下の一文を足すと良いと書かれていたので実行しました

config/environments/production.rbへの記述 config.assets.initialize_on_precompile = false

全体はこのようなコードです。

config/environments/production.rb内 require_relative "boot" require "rails/all" # Require the gems listed in Gemfile, including any gems # you've limited to :test, :development, or :production. Bundler.require(*Rails.groups) module <アプリ名> class Application < Rails::Application # Initialize configuration defaults for originally generated Rails version. config.load_defaults 6.1 # Configuration for the application, engines, and railties goes here. # # These settings can be overridden in specific environments using the files # in config/environments, which are processed later. # # config.time_zone = "Central Time (US & Canada)" # config.eager_load_paths << Rails.root.join("extras") config.time_zone = 'Tokyo' #herokuの解決用 config.assets.initialize_on_precompile = false end end

怪しいのはターミナルのこのメッセージかなと思い、

terminal

1remote: Running: rake assets:precompile 2remote: rake aborted! 3remote: Sprockets::Railtie::ManifestNeededError: Expected to find a manifest file in `app/assets/config/manifest.js` 4remote: But did not, please create this file and use it to link any assets that need 5remote: to be rendered by your app: 6remote: 7remote: Example: 8remote: //= link_tree ../images 9remote: //= link_directory ../javascripts .js 10remote: //= link_directory ../stylesheets .css 11remote: and restart your server

とりあえずExampleで示されている通りに変えてrails s でサーバを再起動しました。

js

1app/assets/config/manifest.js内のコード 2 3//= link_tree ../images 4//= link_directory ../javascripts .js   5//= link_directory ../stylesheets .css 6

もともとは2行目の//= link_directory ../javascripts .js の記載がありませんでした。

他のサイトを参考に以下を実行すると

terminal

1$ RAILS_ENV=development bin/rails assets:precompile 2yarn install v1.22.10 3[1/4] ???? Resolving packages... 4[2/4] ???? Fetching packages... 5[3/4] ???? Linking dependencies... 6[4/4] ???? Building fresh packages... 7✨ Done in 2.54s. 8rails aborted! 9Sprockets::ArgumentError: link_directory argument must be a directory 10/app/assets/config/manifest.js:2 11Tasks: TOP => assets:precompile 12(See full trace by running task with --trace)

とでるのでapp/assets/config/manifest.js内のコードは変えないほうが良かったかなとも考えています。

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

VS codeのターミナルを使用しています。

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

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

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

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

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

guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

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

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

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

ただいまの回答率
85.48%

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

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

質問する

関連した質問