お世話になっております。
現在、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
回答1件
あなたの回答
tips
プレビュー