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

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

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

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

Ruby on Rails 6

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

Heroku

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

MacOS(OSX)

MacOSとは、Appleの開発していたGUI(グラフィカルユーザーインターフェース)を採用したオペレーションシステム(OS)です。Macintoshと共に、市場に出てGUIの普及に大きく貢献しました。

Q&A

解決済

1回答

517閲覧

herokuにデプロイできません

haru_ren

総合スコア48

Ruby

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

Ruby on Rails 6

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

Heroku

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

MacOS(OSX)

MacOSとは、Appleの開発していたGUI(グラフィカルユーザーインターフェース)を採用したオペレーションシステム(OS)です。Macintoshと共に、市場に出てGUIの普及に大きく貢献しました。

0グッド

0クリップ

投稿2020/12/14 08:11

編集2020/12/14 14:53

お世話になっております。
現在、railsにて転職活動用のポートフォリオの作成に取り掛かって1ヶ月目なのですが、herokuにデプロイできず詰まっております。
初歩的な質問で大変恐縮なのですが、色々と調査をしてみたのですが原因がわからない為、同じ現象に遭遇したことがある方、もしくは何か原因に対してお心当たりのある方がいらっしゃいましたら解決方法に関してアドバイス頂けないでしょうか。

■解決したい課題
・herokuにpushしたい

■環境
・端末:MacBook Air (2020/13インチ)
・OS:macOS Catalina(10.15.7)
・シェル:zsh
・Ruby:2.6.6p146
・Rails:6.0.3.4
・ローカル環境:sqlite3
・本番環境:PostgreSQL

■参考にした記事
・【初心者向け】railsアプリをherokuを使って確実にデプロイする方法【決定版】
https://qiita.com/kazukimatsumoto/items/a0daa7281a3948701c39

・GitHubとHerokuのデフォルトブランチをmasterからmainに変更してみた
https://zenn.dev/hiro_y/articles/b0839b76b9f1f58f7e17

■状況
【初心者向け】railsアプリをherokuを使って確実にデプロイする方法【決定版】サイトを参考にherokuへのデプロイ設定をしポートフォリオ を作成しておりました。
初回とポートフォリオ作成初期段階まではpushできていたのですが、現在はpushに失敗してしまいます。

■試したこと
・作業ブランチがmasterであることを確認。
・bundle install --without production実行。
・git add -A → git commit ○○ → git push heroku master の抜けがないことを確認。
・heroku アプリ削除→再度作成しpush → 失敗
・違うブランチで作業しているよというエラーが発生 → git push heroku master:main → 失敗
・githubのデフォルトブランチをmain → masterに変更。
・heroku logs → Build failedが発生。build pack確認 → 何も入っていなかったので、heroku/nodejs、heroku/rubyをインストール。heroku buildpacksでインストールが成功していることを確認。
・heroku restart実行。
・【初心者向け】railsアプリをherokuを使って確実にデプロイする方法【決定版】を参考に再度確認
→bin/bundleファイルの先頭に #!/usr/bin/env ruby が存在していないことを確認。(このファイルは何も触っていません)
・GitHubとHerokuのデフォルトブランチをmasterからmainに変更してみたサイトを見つけ、開発途中アプリを消し、作り直しているので影響を受けたのでは?と考えデフォルトブランチをmainに変更。
git push heroku mainしたところ違うブランチで作業しているよというエラーが発生。
If you are developing on a branch and deploying via git you must run:git push heroku <branchname>:main
mainではないのブランチ直前のブランチ(herokuデプロイエラー用に作成していました)に移動しpush。下記エラーとなっております。

❯ git push heroku heroku_deploy_error:main remote: remote: -----> Node.js app detected remote: remote: -----> Creating runtime environment remote: remote: NPM_CONFIG_LOGLEVEL=error remote: USE_YARN_CACHE=true remote: NODE_ENV=production remote: NODE_MODULES_CACHE=true remote: NODE_VERBOSE=false remote: remote: -----> Installing binaries remote: engines.node (package.json): unspecified remote: engines.npm (package.json): unspecified (use default) remote: engines.yarn (package.json): unspecified (use default) remote: remote: Resolving node version 12.x... remote: Downloading and installing node 12.20.0... remote: Using default npm version: 6.14.8 remote: Resolving yarn version 1.22.x... remote: Downloading and installing yarn (1.22.10) remote: Installed yarn 1.22.10 remote: remote: -----> Installing dependencies remote: Installing node modules (yarn.lock) remote: yarn install v1.22.10 remote: [1/4] Resolving packages... remote: [2/4] Fetching packages... remote: info fsevents@2.1.3: The platform "linux" is incompatible with this module. remote: info "fsevents@2.1.3" 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@3.11.0" has unmet peer dependency "webpack@^4.0.0 || ^5.0.0". remote: warning "webpack-dev-server > webpack-dev-middleware@3.7.2" has unmet peer dependency "webpack@^4.0.0". remote: [4/4] Building fresh packages... remote: Done in 29.66s. remote: remote: -----> Build remote: remote: -----> Pruning devDependencies remote: yarn install v1.22.10 remote: [1/4] Resolving packages... remote: [2/4] Fetching packages... remote: info fsevents@2.1.3: The platform "linux" is incompatible with this module. remote: info "fsevents@2.1.3" 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@3.11.0" has unmet peer dependency "webpack@^4.0.0 || ^5.0.0". remote: warning "webpack-dev-server > webpack-dev-middleware@3.7.2" has unmet peer dependency "webpack@^4.0.0". remote: [4/4] Building fresh packages... remote: warning Ignored scripts due to flag. remote: Done in 5.90s. remote: remote: -----> Caching build remote: - yarn cache remote: remote: -----> Build succeeded! remote: ! Unmet dependencies don't fail yarn install but may cause runtime issues remote: https://github.com/npm/npm/issues/7494 remote: remote: -----> Ruby app detected remote: -----> Installing bundler 2.1.4 remote: -----> Removing BUNDLED WITH version in the Gemfile.lock remote: -----> Compiling Ruby/Rails remote: -----> Using Ruby version: ruby-2.6.6 remote: -----> Installing dependencies using bundler 2.1.4 remote: Running: BUNDLE_WITHOUT='development:test' BUNDLE_PATH=vendor/bundle BUNDLE_BIN=vendor/bundle/bin BUNDLE_DEPLOYMENT=1 bundle install -j4 remote: /tmp/build_09e402e7/bin/bundle: line 1: require: command not found remote: /tmp/build_09e402e7/bin/bundle: line 3: m: command not found remote: /tmp/build_09e402e7/bin/bundle: line 4: module_function: command not found remote: /tmp/build_09e402e7/bin/bundle: line 6: def: command not found remote: /tmp/build_09e402e7/bin/bundle: line 7: syntax error near unexpected token `$PROGRAM_NAME' remote: /tmp/build_09e402e7/bin/bundle: line 7: ` File.expand_path($PROGRAM_NAME) == File.expand_path(__FILE__)' remote: Bundler Output: /tmp/build_09e402e7/bin/bundle: line 1: require: command not found remote: /tmp/build_09e402e7/bin/bundle: line 3: m: command not found remote: /tmp/build_09e402e7/bin/bundle: line 4: module_function: command not found remote: /tmp/build_09e402e7/bin/bundle: line 6: def: command not found remote: /tmp/build_09e402e7/bin/bundle: line 7: syntax error near unexpected token `$PROGRAM_NAME' remote: /tmp/build_09e402e7/bin/bundle: line 7: ` File.expand_path($PROGRAM_NAME) == File.expand_path(__FILE__)' remote: remote: ! remote: ! Failed to install gems via Bundler. remote: ! remote: ! Push rejected, failed to compile Ruby app. remote: remote: ! Push failed remote: Verifying deploy... remote: remote: ! Push rejected to music-sns-app. remote: To https://git.heroku.com/music-sns-app.git ! [remote rejected] heroku_deploy_error -> main (pre-receive hook declined) error: failed to push some refs to 'https://git.heroku.com/music-sns-app.git'

bin/bundle

require "rubygems" m = Module.new do module_function def invoked_as_script? File.expand_path($PROGRAM_NAME) == File.expand_path(__FILE__) end def env_var_version ENV["BUNDLER_VERSION"] end def cli_arg_version return unless invoked_as_script? # don't want to hijack other binstubs return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update` bundler_version = nil update_index = nil ARGV.each_with_index do |a, i| if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN bundler_version = a end next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/ bundler_version = Regexp.last_match(1) update_index = i end bundler_version end def gemfile gemfile = ENV["BUNDLE_GEMFILE"] return gemfile if gemfile.present? File.expand_path("../../Gemfile", __FILE__) end def lockfile lockfile = case File.basename(gemfile) when "gems.rb" then gemfile.sub(/.rb$/, gemfile) else "#{gemfile}.lock" end File.expand_path(lockfile) end def lockfile_version return unless File.file?(lockfile) lockfile_contents = File.read(lockfile) return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/ Regexp.last_match(1) end def bundler_version @bundler_version ||= env_var_version || cli_arg_version || lockfile_version end def bundler_requirement return "#{Gem::Requirement.default}.a" unless bundler_version bundler_gem_version = Gem::Version.new(bundler_version) requirement = bundler_gem_version.approximate_recommendation return requirement unless Gem::Version.new(Gem::VERSION) < Gem::Version.new("2.7.0") requirement += ".a" if bundler_gem_version.prerelease? requirement end def load_bundler! ENV["BUNDLE_GEMFILE"] ||= gemfile activate_bundler end def activate_bundler gem_error = activation_error_handling do gem "bundler", bundler_requirement end return if gem_error.nil? require_error = activation_error_handling do require "bundler/version" end return if require_error.nil? && Gem::Requirement.new(bundler_requirement).satisfied_by?(Gem::Version.new(Bundler::VERSION)) warn "Activating bundler (#{bundler_requirement}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_requirement}'`" exit 42 end def activation_error_handling yield nil rescue StandardError, LoadError => e e end end m.load_bundler! if m.invoked_as_script? load Gem.bin_path("bundler", "bundle") end

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

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

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

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

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

gouf

2020/12/16 12:55

「rails app:update:bin」を実行し、コミットした場合、何か変化は見られますか?
haru_ren

2020/12/16 15:02

ご回答ありがとうございます!完全に行き詰まっていたので嬉しいです!! 他に必要な情報や、コマンドなどありましたらなんなりとお申し付けください。 mainブランチにてrails app:update:binを実行したところ、コンフリクトが発生したので全てyesを選択し、コミット、pushしました。 結果は下記になります。 ``` Enumerating objects: 2565, done. Counting objects: 100% (2565/2565), done. Delta compression using up to 8 threads Compressing objects: 100% (2420/2420), done. Writing objects: 100% (2515/2515), 4.75 MiB | 179.00 KiB/s, done. Total 2515 (delta 1726), reused 35 (delta 17), pack-reused 0 remote: Compressing source files... done. remote: Building source: remote: remote: -----> Node.js app detected remote: remote: -----> Creating runtime environment remote: remote: NPM_CONFIG_LOGLEVEL=error remote: USE_YARN_CACHE=true remote: NODE_ENV=production remote: NODE_MODULES_CACHE=true remote: NODE_VERBOSE=false remote: remote: -----> Installing binaries remote: engines.node (package.json): unspecified remote: engines.npm (package.json): unspecified (use default) remote: engines.yarn (package.json): unspecified (use default) remote: remote: Resolving node version 12.x... remote: Downloading and installing node 12.20.0... remote: Using default npm version: 6.14.8 remote: Resolving yarn version 1.22.x... remote: Downloading and installing yarn (1.22.10) remote: Installed yarn 1.22.10 remote: remote: -----> Restoring cache remote: - yarn cache remote: remote: -----> Installing dependencies remote: Installing node modules (yarn.lock) remote: yarn install v1.22.10 remote: [1/4] Resolving packages... remote: [2/4] Fetching packages... remote: info fsevents@2.1.3: The platform "linux" is incompatible with this module. remote: info "fsevents@2.1.3" 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@3.11.0" has unmet peer dependency "webpack@^4.0.0 || ^5.0.0". remote: warning "webpack-dev-server > webpack-dev-middleware@3.7.2" has unmet peer dependency "webpack@^4.0.0". remote: [4/4] Building fresh packages... remote: Done in 13.37s. remote: remote: -----> Build remote: remote: -----> Pruning devDependencies remote: yarn install v1.22.10 remote: [1/4] Resolving packages... remote: [2/4] Fetching packages... remote: info fsevents@2.1.3: The platform "linux" is incompatible with this module. remote: info "fsevents@2.1.3" 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@3.11.0" has unmet peer dependency "webpack@^4.0.0 || ^5.0.0". remote: warning "webpack-dev-server > webpack-dev-middleware@3.7.2" has unmet peer dependency "webpack@^4.0.0". remote: [4/4] Building fresh packages... remote: warning Ignored scripts due to flag. remote: Done in 5.70s. remote: remote: -----> Caching build remote: - yarn cache remote: remote: -----> Build succeeded! remote: ! Unmet dependencies don't fail yarn install but may cause runtime issues remote: https://github.com/npm/npm/issues/7494 remote: remote: -----> Ruby app detected remote: -----> Installing bundler 2.1.4 remote: -----> Removing BUNDLED WITH version in the Gemfile.lock remote: -----> Compiling Ruby/Rails remote: -----> Using Ruby version: ruby-2.6.6 remote: -----> Installing dependencies using bundler 2.1.4 remote: Running: BUNDLE_WITHOUT='development:test' BUNDLE_PATH=vendor/bundle BUNDLE_BIN=vendor/bundle/bin BUNDLE_DEPLOYMENT=1 bundle install -j4 remote: /tmp/build_3c8b4ca7/bin/bundle: line 1: require: command not found remote: /tmp/build_3c8b4ca7/bin/bundle: line 3: m: command not found remote: /tmp/build_3c8b4ca7/bin/bundle: line 4: module_function: command not found remote: /tmp/build_3c8b4ca7/bin/bundle: line 6: def: command not found remote: /tmp/build_3c8b4ca7/bin/bundle: line 7: syntax error near unexpected token `$PROGRAM_NAME' remote: /tmp/build_3c8b4ca7/bin/bundle: line 7: ` File.expand_path($PROGRAM_NAME) == File.expand_path(__FILE__)' remote: Bundler Output: /tmp/build_3c8b4ca7/bin/bundle: line 1: require: command not found remote: /tmp/build_3c8b4ca7/bin/bundle: line 3: m: command not found remote: /tmp/build_3c8b4ca7/bin/bundle: line 4: module_function: command not found remote: /tmp/build_3c8b4ca7/bin/bundle: line 6: def: command not found remote: /tmp/build_3c8b4ca7/bin/bundle: line 7: syntax error near unexpected token `$PROGRAM_NAME' remote: /tmp/build_3c8b4ca7/bin/bundle: line 7: ` File.expand_path($PROGRAM_NAME) == File.expand_path(__FILE__)' remote: remote: ! remote: ! Failed to install gems via Bundler. remote: ! remote: ! Push rejected, failed to compile Ruby app. remote: remote: ! Push failed remote: Verifying deploy... remote: remote: ! Push rejected to music-sns-app. remote: To https://git.heroku.com/music-sns-app.git ! [remote rejected] main -> main (pre-receive hook declined) error: failed to push some refs to 'https://git.heroku.com/music-sns-app.git' ``` また、heroku logsを実行したところ、Build failed が発生しておりました。 ``` Build failed -- check your build output: https://dashboard.heroku.com/apps/○○○ ```
guest

回答1

0

自己解決

本件解決いたしました!
bin/bundleファイルにエラーが発生していた様なので修正したところ無事デプロイすることができました。

投稿2020/12/17 15:16

haru_ren

総合スコア48

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

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

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

ただいまの回答率
85.48%

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

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

質問する

関連した質問