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

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

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

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

Heroku

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

Ruby on Rails

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

Q&A

解決済

3回答

6887閲覧

Herokuでrailsアプリのデプロイでエラー

yoshimitsu41

総合スコア36

Ruby on Rails 5

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

Heroku

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

Ruby on Rails

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

0グッド

0クリップ

投稿2017/12/03 14:22

編集2017/12/04 03:37

rails初心者です。

HEROKUでrailsアプリのデプロイを試みているのですがエラーが出てしまいデプロイができません。
色々調べて試したのですが原因がわかりません。
出ているエラーは下記になります。

ruby

1git push heroku master 2 3Counting objects: 194, done. 4Delta compression using up to 4 threads. 5Compressing objects: 100% (172/172), done. 6Writing objects: 100% (194/194), 52.05 KiB | 2.74 MiB/s, done. 7Total 194 (delta 31), reused 0 (delta 0) 8remote: Compressing source files... done. 9remote: Building source: 10remote: 11remote: ! Warning: Multiple default buildpacks reported the ability to handle this app. The first buildpack in the list below will be used. 12remote: Detected buildpacks: Ruby,Node.js 13remote: See https://devcenter.heroku.com/articles/buildpacks#buildpack-detect-order 14remote: -----> Ruby app detected 15remote: -----> Compiling Ruby/Rails 16remote: -----> Using Ruby version: ruby-2.3.4 17remote: -----> Installing dependencies using bundler 1.15.2 18remote: Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment 19remote: Your Gemfile lists the gem mysql2 (= 0.3.18) more than once. 20remote: You should probably keep only one of them. 21remote: While it's not a problem now, it could cause errors if you change the version of one of them later. 22remote: Warning: the running version of Bundler (1.15.2) is older than the version that created the lockfile (1.16.0). We suggest you upgrade to the latest version of Bundler by running `gem install bundler`. 23remote: Fetching gem metadata from https://rubygems.org/.......... 24remote: Fetching version metadata from https://rubygems.org/.. 25remote: Fetching dependency metadata from https://rubygems.org/. 26remote: The latest bundler is 1.16.0, but you are currently running 1.15.2. 27remote: To update, run `gem install bundler` 28remote: Could not find rack-test-0.7.1 in any of the sources 29remote: Bundler Output: Your Gemfile lists the gem mysql2 (= 0.3.18) more than once. 30remote: You should probably keep only one of them. 31remote: While it's not a problem now, it could cause errors if you change the version of one of them later. 32remote: Warning: the running version of Bundler (1.15.2) is older than the version that created the lockfile (1.16.0). We suggest you upgrade to the latest version of Bundler by running `gem install bundler`. 33remote: Fetching gem metadata from https://rubygems.org/.......... 34remote: Fetching version metadata from https://rubygems.org/.. 35remote: Fetching dependency metadata from https://rubygems.org/. 36remote: The latest bundler is 1.16.0, but you are currently running 1.15.2. 37remote: To update, run `gem install bundler` 38remote: Could not find rack-test-0.7.1 in any of the sources 39remote: ! 40remote: ! Failed to install gems via Bundler. 41remote: ! 42remote: ! Push rejected, failed to compile Ruby app. 43remote: 44remote: ! Push failed 45remote: Verifying deploy... 46remote: 47remote: ! Push rejected to cose-app. 48remote: 49To https://git.heroku.com/cose-app.git 50 ! [remote rejected] master -> master (pre-receive hook declined) 51error: failed to push some refs to 'https://git.heroku.com/cose-app.git' 52

ruby

1#gemfile 2 3source 'https://rubygems.org' 4 5git_source(:github) do |repo_name| 6 repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/") 7 "https://github.com/#{repo_name}.git" 8end 9 10 11# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' 12gem 'rails', '~> 5.1.4' 13# Use mysql as the database for Active Record 14gem 'mysql2', '0.3.18' 15# Use Puma as the app server 16gem 'puma', '~> 3.7' 17# Use SCSS for stylesheets 18gem 'sass-rails', '~> 5.0' 19# Use Uglifier as compressor for JavaScript assets 20gem 'uglifier', '>= 1.3.0' 21# See https://github.com/rails/execjs#readme for more supported runtimes 22# gem 'therubyracer', platforms: :ruby 23 24# Use CoffeeScript for .coffee assets and views 25gem 'coffee-rails', '~> 4.2' 26# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks 27gem 'turbolinks', '~> 5' 28# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder 29gem 'jbuilder', '~> 2.5' 30# Use Redis adapter to run Action Cable in production 31# gem 'redis', '~> 3.0' 32# Use ActiveModel has_secure_password 33# gem 'bcrypt', '~> 3.1.7' 34 35# Use Capistrano for deployment 36# gem 'capistrano-rails', group: :development 37 38group :development, :test do 39 # Call 'byebug' anywhere in the code to stop execution and get a debugger console 40 gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] 41 # Adds support for Capybara system testing and selenium driver 42 gem 'capybara', '~> 2.13' 43 gem 'selenium-webdriver' 44end 45 46group :development do 47 # Access an IRB console on exception pages or by using <%= console %> anywhere in the code. 48 gem 'web-console', '>= 3.3.0' 49 gem 'listen', '>= 3.0.5', '< 3.2' 50 # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring 51 gem 'spring' 52 gem 'spring-watcher-listen', '~> 2.0.0' 53end 54 55group :production do 56 gem 'rails_12factor' 57 gem 'mysql2', '0.3.18' 58end 59 60# Windows does not include zoneinfo files, so bundle the tzinfo-data gem 61gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] 62gem 'pry-rails' 63gem 'devise' 64gem 'enumerize' 65gem 'bootstrap-sass' 66gem 'jquery-rails' 67gem 'cancancan' 68gem 'rails_admin' 69gem "chartkick" 70gem 'ransack' 71gem 'momentjs-rails' 72gem 'bootstrap3-datetimepicker-rails' 73gem 'kaminari'

お詳しい方ご教授お願い致します。

以下追記

config/environments/production.rb

ruby

1 2Rails.application.configure do 3 # Settings specified here will take precedence over those in config/application.rb. 4 5 # Code is not reloaded between requests. 6 config.cache_classes = true 7 8 # Eager load code on boot. This eager loads most of Rails and 9 # your application in memory, allowing both threaded web servers 10 # and those relying on copy on write to perform better. 11 # Rake tasks automatically ignore this option for performance. 12 config.eager_load = true 13 14 # Full error reports are disabled and caching is turned on. 15 config.consider_all_requests_local = false 16 config.action_controller.perform_caching = true 17 18 # Attempt to read encrypted secrets from `config/secrets.yml.enc`. 19 # Requires an encryption key in `ENV["RAILS_MASTER_KEY"]` or 20 # `config/secrets.yml.key`. 21 config.read_encrypted_secrets = true 22 23 # Disable serving static files from the `/public` folder by default since 24 # Apache or NGINX already handles this. 25 config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? 26 27 # Compress JavaScripts and CSS. 28 config.assets.js_compressor = :uglifier 29 # config.assets.css_compressor = :sass 30 31 # Do not fallback to assets pipeline if a precompiled asset is missed. 32 config.assets.compile = true 33 34 # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb 35 36 # Enable serving of images, stylesheets, and JavaScripts from an asset server. 37 # config.action_controller.asset_host = 'http://assets.example.com' 38 39 # Specifies the header that your server uses for sending files. 40 # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache 41 # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX 42 43 # Mount Action Cable outside main process or domain 44 # config.action_cable.mount_path = nil 45 # config.action_cable.url = 'wss://example.com/cable' 46 # config.action_cable.allowed_request_origins = [ 'http://example.com', /http://example.*/ ] 47 48 # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. 49 # config.force_ssl = true 50 51 # Use the lowest log level to ensure availability of diagnostic information 52 # when problems arise. 53 config.log_level = :debug 54 55 # Prepend all log lines with the following tags. 56 config.log_tags = [ :request_id ] 57 58 # Use a different cache store in production. 59 # config.cache_store = :mem_cache_store 60 61 # Use a real queuing backend for Active Job (and separate queues per environment) 62 # config.active_job.queue_adapter = :resque 63 # config.active_job.queue_name_prefix = "cose_#{Rails.env}" 64 config.action_mailer.perform_caching = false 65 66 # Ignore bad email addresses and do not raise email delivery errors. 67 # Set this to true and configure the email server for immediate delivery to raise delivery errors. 68 # config.action_mailer.raise_delivery_errors = false 69 70 # Enable locale fallbacks for I18n (makes lookups for any locale fall back to 71 # the I18n.default_locale when a translation cannot be found). 72 config.i18n.fallbacks = true 73 74 # Send deprecation notices to registered listeners. 75 config.active_support.deprecation = :notify 76 77 # Use default logging formatter so that PID and timestamp are not suppressed. 78 config.log_formatter = ::Logger::Formatter.new 79 80 # Use a different logger for distributed setups. 81 # require 'syslog/logger' 82 # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name') 83 84 if ENV["RAILS_LOG_TO_STDOUT"].present? 85 logger = ActiveSupport::Logger.new(STDOUT) 86 logger.formatter = config.log_formatter 87 config.logger = ActiveSupport::TaggedLogging.new(logger) 88 end 89 90 # Do not dump schema after migrations. 91 config.active_record.dump_schema_after_migration = false 92end 93

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

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

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

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

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

guest

回答3

0

自己解決

無事解決しました。
問題点はbundlerのバージョンによる依存関係?だったようです。
エラー分の

The latest bundler is 1.16.0, but you are currently running 1.15.2. To update, run `gem install bundler`

でした。
解決方法として…。
gem uninstall bundlerで一旦アンインストール。
gem install bundler -v '1.15.2'
で再度インストールしてgemfile.lockを削除してからbundle install
するとgemfile.lockの一番下が

BUNDLED W`ITH 1.15.2

になりました。

コミットしてgit push heroku master
でデプロイ出来ました。

投稿2017/12/04 11:20

yoshimitsu41

総合スコア36

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

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

0

マークダウンが使えなかったので、新規に回答させて頂きます。
cleadbをお使いかと思うのですが、cleadbでの設定情報は環境変数で読み込んでいるか、database.ymlに直接記述しているかどちらでしょうか?

自分の環境では、database.ymlは環境変数で扱っています。

yml

1production: 2 <<: *default 3 database: <%= ENV['DB_NAME'] %> 4 username: <%= ENV['DB_USERNAME'] %> 5 password: <%= ENV['DB_PASSWORD'] %> 6 host: <%= ENV['DB_HOSTNAME'] %> 7 port: <%= ENV['DB_PORT'] %>

上記のようにしているので、heroku configDB_NAMEDB_USERNAMEなどをセットしています。

ただエラー内容を見る感じ、DB周りでは無いような気もしているのですが、、念のため

投稿2017/12/04 03:16

kenny_sayama

総合スコア1036

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

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

yoshimitsu41

2017/12/04 03:34 編集

>cleadbでの設定情報は環境変数で読み込んでいるか、'database.yml'に直接記述しているかどちらでしょうか? お恥ずかしいのですが、知識不足でご質問の意味が理解出来ていないのが正直なところです。。。 database.ymlは何も修正しておりません。 記述されている内容は下記です。 ```ruby #database.yml # MySQL. Versions 5.1.10 and up are supported. # # Install the MySQL driver # gem install mysql2 # # Ensure the MySQL gem is defined in your Gemfile # gem 'mysql2' # # And be sure to use new-style password hashing: # http://dev.mysql.com/doc/refman/5.7/en/old-client.html # default: &default adapter: mysql2 encoding: utf8 pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> username: root password: socket: /tmp/mysql.sock development: <<: *default database: cose_development # Warning: The database defined as "test" will be erased and # re-generated from your development database when you run "rake". # Do not set this db to the same as development or production. test: <<: *default database: cose_test # As with config/secrets.yml, you never want to store sensitive information, # like your database password, in your source code. If your source code is # ever seen by anyone, they now have access to your database. # # Instead, provide the password as a unix environment variable when you boot # the app. Read http://guides.rubyonrails.org/configuring.html#configuring-a-database # for a full rundown on how to provide these environment variables in a # production deployment. # # On Heroku and other platform providers, you may have a full connection URL # available as an environment variable. For example: # # DATABASE_URL="mysql2://myuser:mypass@localhost/somedatabase" # # You can use this database configuration with: # # production: # url: <%= ENV['DATABASE_URL'] %> # production: <<: *default database: cose_production username: cose password: <%= ENV['COSE_DATABASE_PASSWORD'] %> ```
yoshimitsu41

2017/12/04 03:37

config/environments/production.rbの内容を追記致しました。
kenny_sayama

2017/12/04 03:53

こちらの説明がわかりづらかったかと思います。すみません。。 database.ymlを見る限り、herokuのアドオンで追加したcleadbとコネクト出来ていない様な気がします。 database.ymlの最終行らへんのproductionの記述を以下の様に変更してください。 production: <<: *default database: <%= ENV['DB_NAME'] %> username: <%= ENV['DB_USERNAME'] %> password: <%= ENV['DB_PASSWORD'] %> host: <%= ENV['DB_HOSTNAME'] %> port: <%= ENV['DB_PORT'] %>
yoshimitsu41

2017/12/04 04:38 編集

ありがとうございます。 上記のように修正してgitでcommitしてgit push heroku masterしたのですが下記のエラーになりました。 ``` $ git push heroku master Counting objects: 198, done. Delta compression using up to 4 threads. Compressing objects: 100% (176/176), done. Writing objects: 100% (198/198), 52.46 KiB | 3.75 MiB/s, done. Total 198 (delta 34), reused 0 (delta 0) remote: Compressing source files... done. remote: Building source: remote: 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: -----> Compiling Ruby/Rails remote: -----> Using Ruby version: ruby-2.3.4 remote: -----> Installing dependencies using bundler 1.15.2 remote: Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment remote: Your Gemfile lists the gem mysql2 (= 0.3.18) more than once. remote: You should probably keep only one of them. remote: While it's not a problem now, it could cause errors if you change the version of one of them later. remote: Warning: the running version of Bundler (1.15.2) is older than the version that created the lockfile (1.16.0). We suggest you upgrade to the latest version of Bundler by running `gem install bundler`. remote: Fetching gem metadata from https://rubygems.org/.......... remote: Fetching version metadata from https://rubygems.org/.. remote: Fetching dependency metadata from https://rubygems.org/. remote: The latest bundler is 1.16.0, but you are currently running 1.15.2. remote: To update, run `gem install bundler` remote: Could not find rack-test-0.7.1 in any of the sources remote: Bundler Output: Your Gemfile lists the gem mysql2 (= 0.3.18) more than once. remote: You should probably keep only one of them. remote: While it's not a problem now, it could cause errors if you change the version of one of them later. remote: Warning: the running version of Bundler (1.15.2) is older than the version that created the lockfile (1.16.0). We suggest you upgrade to the latest version of Bundler by running `gem install bundler`. remote: Fetching gem metadata from https://rubygems.org/.......... remote: Fetching version metadata from https://rubygems.org/.. remote: Fetching dependency metadata from https://rubygems.org/. remote: The latest bundler is 1.16.0, but you are currently running 1.15.2. remote: To update, run `gem install bundler` remote: Could not find rack-test-0.7.1 in any of the sources 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 cose-app. remote: To https://git.heroku.com/cose-app.git ! [remote rejected] master -> master (pre-receive hook declined) error: failed to push some refs to 'https://git.heroku.com/cose-app.git' ```
kenny_sayama

2017/12/04 04:50

検索してみて、同様の事象になっている方は以下のコマンドで解決したようです。 rm -rf .git git init git add . git commit -m "First commit" heroku create --stack cedar git push heroku master
kenny_sayama

2017/12/04 04:50

念のためバックアップを取っておくといいかもしれません
yoshimitsu41

2017/12/04 06:29

ご指摘どおり対応しましたが結果は同じでした。 他に考えられる可能性はございますでしょうか?
kenny_sayama

2017/12/04 09:26

一度herokuのアプリケーションを削除して、最初からやり直したほうが早いかもしれません。。
yoshimitsu41

2017/12/04 11:21

自己解決致しました! ありがとうございました!
guest

0

問題の切り分けをする必要があるかと思うので、順々に確認していきましょう!

以下をご回答いただけますか?

  1. herokuにアプリケーションの登録が出来ているか?
  2. 使っているデータベースは何をお使いですか?(mysqlだとアドオンを登録する必要がある)
  3. ローカルではアプリケーションは正しく動作していますか?

以上よろしくお願いします

投稿2017/12/04 00:46

kenny_sayama

総合スコア1036

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

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

yoshimitsu41

2017/12/04 02:55

ご連絡ありがとうございます! >herokuにアプリケーションの登録が出来ているか? はい。 herokuの管理画面に入って確認したところ、cose-appという欄がありアプリケーションの登録は出来ております。 >使っているデータベースは何をお使いですか?(mysqlだとアドオンを登録する必要がある) mysqlです! $ heroku addons:add cleardb で追加して、データベースの情報を変更しました。 heroku config の内容は下記です。 CLEARDB_DATABASE_URL: mysql://xxxxxx DATABASE_URL: mysql2://xxxxxx xxxxxの箇所は同じ内容が記載されています。 >ローカルではアプリケーションは正しく動作していますか? はい。問題なく動作しております。 ネットで調べつつ設定したつもりなのですが…。 問題点はわかりますでしょうか?
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

ただいまの回答率
85.50%

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

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

質問する

関連した質問