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

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

解決済

1回答

920閲覧

Heroku Bundlerエラー

yakumo02

総合スコア103

Ruby

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

Heroku

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

Ruby on Rails

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

0グッド

0クリップ

投稿2022/09/25 05:50

編集2022/09/25 05:52

前提

Herokuでrailsのアプリをデプロイしようとすると、postgresqlとnokogiriに関するエラーが発生しました
Bundlerのエラーとなっています

経緯

HerokuでデプロイしようとGemfileに以下を記述

Gemfile

1group :development, :test do 2 gem 'sqlite3' #do 。 3end 4 5group :production do 6 gem 'pg', '~> 1.2', '>= 1.2.3' 7end

その後bundle installを実施

$bundle install --without production

その後以下のエラーが発生したので対処

remote: Bundler Output: Your bundle only supports platforms ["x86_64-darwin-18"] but your local platform remote: is x86_64-linux. Add the current platform to the lockfile with remote: `bundle lock --add-platform x86_64-linux` and try again.

対処方法

$ bundle lock --add-platform x86_64-linux

すると以下のエラーが発生したという状況です

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

Failed to install gems via Bundler.エラーです
ローカルとHeroku上でのBundlerのバージョンは一致させましたがエラーは解消されませんでした

エラーメッセージ

terminal

1remote: Compressing source files... done. 2remote: Building source: 3remote: 4remote: -----> Building on the Heroku-22 stack 5remote: -----> Determining which buildpack to use for this app 6remote: -----> Ruby app detected 7remote: -----> Installing bundler 2.3.10 8remote: -----> Removing BUNDLED WITH version in the Gemfile.lock 9remote: -----> Compiling Ruby/Rails 10remote: -----> Using Ruby version: ruby-3.1.2 11remote: -----> Installing dependencies using bundler 2.3.10 12remote: Running: BUNDLE_WITHOUT='development:test' BUNDLE_PATH=vendor/bundle BUNDLE_BIN=vendor/bundle/bin BUNDLE_DEPLOYMENT=1 bundle install -j4 13remote: Could not find nokogiri-1.13.8-x86_64-linux in any of the sources 14remote: Bundler Output: Could not find nokogiri-1.13.8-x86_64-linux in any of the sources 15remote: 16remote: ! 17remote: ! Failed to install gems via Bundler. 18remote: ! 19remote: ! Push rejected, failed to compile Ruby app. 20remote: 21remote: ! Push failed 22remote: ! 23remote: ! ## Warning - The same version of this code has already been built: 61a8a337c5d93ed925fe0cc90fe0e5fa69aac8f0 24remote: ! 25remote: ! We have detected that you have triggered a build from source code with version 61a8a337c5d93ed925fe0cc90fe0e5fa69aac8f0 26remote: ! at least twice. One common cause of this behavior is attempting to deploy code from a different branch. 27remote: ! 28remote: ! If you are developing on a branch and deploying via git you must run: 29remote: ! 30remote: ! git push heroku <branchname>:main 31remote: ! 32remote: ! This article goes into details on the behavior: 33remote: ! https://devcenter.heroku.com/articles/duplicate-build-version 34remote: 35remote: Verifying deploy.... 36remote: 37remote: ! Push rejected to actress-back. 38remote: 39To https://git.heroku.com/actress-back.git 40 ! [remote rejected] master -> master (pre-receive hook declined) 41error: failed to push some refs to 'https://git.heroku.com/actress-back.git'

ソースコード

Gemfile

1source 'https://rubygems.org' 2git_source(:github) { |repo| "https://github.com/#{repo}.git" } 3 4ruby '3.1.2' 5 6# Bundle edge Rails instead: gem 'rails', github: 'rails/rails', branch: 'main' 7gem 'rails', '~> 6.1.6', '>= 6.1.6.1' 8# Use mysql as the database for Active Record 9gem 'mysql2', '~> 0.5' 10# Use Puma as the app server 11gem 'puma', '~> 5.0' 12# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder 13# gem 'jbuilder', '~> 2.7' 14# Use Redis adapter to run Action Cable in production 15# gem 'redis', '~> 4.0' 16# Use Active Model has_secure_password 17# gem 'bcrypt', '~> 3.1.7' 18 19# Use Active Storage variant 20# gem 'image_processing', '~> 1.2' 21 22# Reduces boot times through caching; required in config/boot.rb 23gem 'bootsnap', '>= 1.4.4', require: false 24 25# Use Rack CORS for handling Cross-Origin Resource Sharing (CORS), making cross-origin AJAX possible 26# gem 'rack-cors' 27 28group :development, :test do 29 # Call 'byebug' anywhere in the code to stop execution and get a debugger console 30 gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] 31 gem 'sqlite3' 32end 33 34group :development do 35 gem 'listen', '~> 3.3' 36 # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring 37 gem 'spring' 38end 39 40# Windows does not include zoneinfo files, so bundle the tzinfo-data gem 41gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] 42gem 'jbuilder', '~> 2.7' 43gem 'rack-cors' 44gem 'carrierwave', '~> 2.0' 45gem 'pry-rails' 46gem 'fog-aws' 47gem 'net-smtp' 48group :production do 49 gem 'pg', '~> 1.2', '>= 1.2.3' 50end

文字数制限に引っ掛かったので関係なさそうな箇所は削除しました

Gemfile.lock

1GEM 2 remote: https://rubygems.org/ 3 specs: 4 actiontext (6.1.7) 5 actionpack (= 6.1.7) 6 activerecord (= 6.1.7) 7 activestorage (= 6.1.7) 8 activesupport (= 6.1.7) 9 nokogiri (>= 1.8.5) 10 activesupport (= 6.1.7) 11 globalid (>= 0.3.6) 12 activemodel (6.1.7) 13 activesupport (= 6.1.7) 14 activerecord (6.1.7) 15 activemodel (= 6.1.7) 16 activesupport (= 6.1.7) 17 activestorage (6.1.7) 18 actionpack (= 6.1.7) 19 activejob (= 6.1.7) 20 activerecord (= 6.1.7) 21 activesupport (= 6.1.7) 22 marcel (~> 1.0) 23 mini_mime (>= 1.1.0) 24 activesupport (6.1.7) 25 concurrent-ruby (~> 1.0, >= 1.0.2) 26 i18n (>= 1.6, < 2) 27 minitest (>= 5.1) 28 tzinfo (~> 2.0) 29 zeitwerk (~> 2.3) 30 addressable (2.8.1) 31 public_suffix (>= 2.0.2, < 6.0) 32 bootsnap (1.13.0) 33 msgpack (~> 1.2) 34 builder (3.2.4) 35 byebug (11.1.3) 36 carrierwave (2.2.2) 37 activemodel (>= 5.0.0) 38 activesupport (>= 5.0.0) 39 addressable (~> 2.6) 40 image_processing (~> 1.1) 41 marcel (~> 1.0.0) 42 mini_mime (>= 0.1.3) 43 ssrf_filter (~> 1.0) 44 coderay (1.1.3) 45 concurrent-ruby (1.1.10) 46 crass (1.0.6) 47 digest (3.1.0) 48 erubi (1.11.0) 49 excon (0.92.5) 50 ffi (1.15.5) 51 fog-aws (3.15.0) 52 fog-core (~> 2.1) 53 fog-json (~> 1.1) 54 fog-xml (~> 0.1) 55 fog-core (2.3.0) 56 builder 57 excon (~> 0.71) 58 formatador (>= 0.2, < 2.0) 59 mime-types 60 fog-json (1.2.0) 61 fog-core 62 multi_json (~> 1.10) 63 fog-xml (0.1.4) 64 fog-core 65 nokogiri (>= 1.5.11, < 2.0.0) 66 formatador (1.1.0) 67 globalid (1.0.0) 68 activesupport (>= 5.0) 69 i18n (1.12.0) 70 concurrent-ruby (~> 1.0) 71 image_processing (1.12.2) 72 mini_magick (>= 4.9.5, < 5) 73 ruby-vips (>= 2.0.17, < 3) 74 jbuilder (2.11.5) 75 actionview (>= 5.0.0) 76 activesupport (>= 5.0.0) 77 listen (3.7.1) 78 rb-fsevent (~> 0.10, >= 0.10.3) 79 rb-inotify (~> 0.9, >= 0.9.10) 80 loofah (2.19.0) 81 crass (~> 1.0.2) 82 nokogiri (>= 1.5.9) 83 mail (2.7.1) 84 mini_mime (>= 0.1.1) 85 marcel (1.0.2) 86 method_source (1.0.0) 87 mime-types (3.4.1) 88 mime-types-data (~> 3.2015) 89 mime-types-data (3.2022.0105) 90 mini_magick (4.11.0) 91 mini_mime (1.1.2) 92 mini_portile2 (2.8.0) 93 minitest (5.16.3) 94 msgpack (1.5.6) 95 multi_json (1.15.0) 96 mysql2 (0.5.4) 97 net-protocol (0.1.3) 98 timeout 99 net-smtp (0.3.1) 100 digest 101 net-protocol 102 timeout 103 nio4r (2.5.8) 104 nokogiri (1.13.8) 105 mini_portile2 (~> 2.8.0) 106 racc (~> 1.4) 107 nokogiri (1.13.8-x86_64-darwin) 108 racc (~> 1.4) 109 nokogiri (1.13.8-x86_64-linux) 110 racc (~> 1.4) 111 pg (1.4.3) 112 pry (0.14.1) 113 coderay (~> 1.1) 114 method_source (~> 1.0) 115 pry-rails (0.3.9) 116 pry (>= 0.10.4) 117 public_suffix (5.0.0) 118 puma (5.6.5) 119 nio4r (~> 2.0) 120 racc (1.6.0) 121 rack (2.2.4) 122 rack-cors (1.1.1) 123 rack (>= 2.0.0) 124 rack-test (2.0.2) 125 rack (>= 1.3) 126 rails (6.1.7) 127 actioncable (= 6.1.7) 128 actionmailbox (= 6.1.7) 129 actionmailer (= 6.1.7) 130 actionpack (= 6.1.7) 131 actiontext (= 6.1.7) 132 actionview (= 6.1.7) 133 activejob (= 6.1.7) 134 activemodel (= 6.1.7) 135 activerecord (= 6.1.7) 136 activestorage (= 6.1.7) 137 activesupport (= 6.1.7) 138 bundler (>= 1.15.0) 139 railties (= 6.1.7) 140 sprockets-rails (>= 2.0.0) 141 rails-dom-testing (2.0.3) 142 activesupport (>= 4.2.0) 143 nokogiri (>= 1.6) 144 rails-html-sanitizer (1.4.3) 145 loofah (~> 2.3) 146 railties (6.1.7) 147 actionpack (= 6.1.7) 148 activesupport (= 6.1.7) 149 method_source 150 rake (>= 12.2) 151 thor (~> 1.0) 152 rake (13.0.6) 153 rb-fsevent (0.11.2) 154 rb-inotify (0.10.1) 155 ffi (~> 1.0) 156 ruby-vips (2.1.4) 157 ffi (~> 1.12) 158 spring (4.1.0) 159 sprockets (4.1.1) 160 concurrent-ruby (~> 1.0) 161 rack (> 1, < 3) 162 sprockets-rails (3.4.2) 163 actionpack (>= 5.2) 164 activesupport (>= 5.2) 165 sprockets (>= 3.0.0) 166 sqlite3 (1.5.0) 167 mini_portile2 (~> 2.8.0) 168 sqlite3 (1.5.0-x86_64-darwin) 169 sqlite3 (1.5.0-x86_64-linux) 170 ssrf_filter (1.1.1) 171 thor (1.2.1) 172 timeout (0.3.0) 173 tzinfo (2.0.5) 174 concurrent-ruby (~> 1.0) 175 websocket-driver (0.7.5) 176 websocket-extensions (>= 0.1.0) 177 websocket-extensions (0.1.5) 178 zeitwerk (2.6.0) 179 180PLATFORMS 181 ruby 182 x86_64-darwin-18 183 x86_64-linux 184 185DEPENDENCIES 186 bootsnap (>= 1.4.4) 187 byebug 188 carrierwave (~> 2.0) 189 fog-aws 190 jbuilder (~> 2.7) 191 listen (~> 3.3) 192 mysql2 (~> 0.5) 193 net-smtp 194 pg (~> 1.2, >= 1.2.3) 195 pry-rails 196 puma (~> 5.0) 197 rack-cors 198 rails (~> 6.1.6, >= 6.1.6.1) 199 spring 200 sqlite3 201 tzinfo-data 202 203RUBY VERSION 204 ruby 3.1.2p20 205 206BUNDLED WITH 207 2.3.10

試したこと

・ローカルとHerokuで使用しているBundlerのバージョンが一致しなかったのでローカルのBundlerをHerokuのものと合わせましたが解消されず。今度はgemのpgのバージョンを変えてみましたが変化はありませんでした

・望ましくないですが、Gemfile.lockの以下を(1.2.3)に手動で変えてみましたが変化はありませんでした

pg (1.4.3)

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

Ruby 3.1.2
Rails 6.1.7
Bundler version 2.3.10

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

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

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

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

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

yakumo02

2022/09/28 05:40

回答ください〜
guest

回答1

0

自己解決

Postgresのエラーは直接インストール

brew install postgresql

nokogiri
nokogiriはこちらの解決策

投稿2022/09/29 01:19

yakumo02

総合スコア103

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

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

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

ただいまの回答率
85.48%

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

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

質問する

関連した質問