

Rails Tutorialの11章を進めています。  
11章最後にgit push herokuコマンドを実行すると以下のエラーが出ます。

SendGridのアカウント凍結が原因かと思いましたが、アカウントが有効になっても同じエラーが出ます。  
SendGridのAPI Keyは設定しました。

同様の現象を見たことがある方がいらっしゃいましたら、助言をいただけるとありがたいです。

コンソールのログ

> Enumerating objects: 85, done. Counting objects: 100% (85/85), done.  
>  Delta compression using up to 8 threads Compressing objects: 100%  
>  (51/51), done. Writing objects: 100% (52/52), 9.37 KiB | 1.34 MiB/s,  
>  done. Total 52 (delta 24), reused 0 (delta 0) remote: Compressing  
>  source files... done. remote: Building source: remote: remote: ----->  
>  Ruby app detected remote: -----> Installing bundler 1.17.3 remote:  
>  \-----> Removing BUNDLED WITH version in the Gemfile.lock remote: ----->
> Compiling Ruby/Rails remote: -----> Using Ruby version: ruby-2.6.5 remote:
> -----> Installing dependencies using bundler 1.17.3  
>  remote: Running: bundle install --without development:test  
>  \--path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment remote:
> The dependency tzinfo-data (>= 0) will be unused by any  
>  of the platforms Bundler is installing for. Bundler is installing for  
>  ruby but the dependency is only for x86-mingw32, x86-mswin32,  
>  x64-mingw32, java. To add those platforms to the bundle, run `bundle lock
> --add-platform x86-mingw32 x86-mswin32 x64-mingw32 java`. remote:  
>  Using rake 13.0.1 remote: Using concurrent-ruby 1.1.6 remote:  
>  Using i18n 0.9.5 remote: Using minitest 5.10.3 remote:  
>  Using thread_safe 0.3.6 remote: Using tzinfo 1.2.7 remote:  
>  Using activesupport 5.1.6 remote: Using builder 3.2.4 remote:  
>  Using erubi 1.9.0 remote: Using mini_portile2 2.4.0 remote:  
>  Using nokogiri 1.10.9 remote: Using rails-dom-testing 2.0.3  
>  remote: Using crass 1.0.6 remote: Using loofah 2.5.0  
>  remote: Using rails-html-sanitizer 1.3.0 remote: Using  
>  actionview 5.1.6 remote: Using rack 2.2.2 remote: Using  
>  rack-test 1.1.0 remote: Using actionpack 5.1.6 remote:  
>  Using nio4r 2.5.2 remote: Using websocket-extensions 0.1.5  
>  remote: Using websocket-driver 0.6.5 remote: Using  
>  actioncable 5.1.6 remote: Using globalid 0.4.2 remote:  
>  Using activejob 5.1.6 remote: Using mini_mime 1.0.2 remote:  
>  Using mail 2.7.1 remote: Using actionmailer 5.1.6 remote:  
>  Using activemodel 5.1.6 remote: Using arel 8.0.0 remote:  
>  Using activerecord 5.1.6 remote: Using execjs 2.7.0 remote:  
>  Using autoprefixer-rails 9.7.6 remote: Using bcrypt 3.1.12  
>  remote: Using rb-fsevent 0.10.4 remote: Using ffi 1.13.1  
>  remote: Using rb-inotify 0.10.1 remote: Using  
>  sass-listen 4.0.0 remote: Using sass 3.7.4 remote: Using  
>  bootstrap-sass 3.3.7 remote: Using will_paginate 3.1.6 remote:  
>  Using bootstrap-will_paginate 1.0.0 remote: Using bundler  
>  1.17.3 remote: Using coffee-script-source 1.12.2 remote: Using coffee-
> script 2.4.1 remote: Using method_source 1.0.0  
>  remote: Using thor 1.0.1 remote: Using railties 5.1.6  
>  remote: Using coffee-rails 4.2.2 remote: Using faker  
>  1.7.3 remote: Using multi_json 1.14.1 remote: Using jbuilder 2.7.0 remote:
> Using jquery-rails 4.3.1 remote:  
>  Using pg 0.20.0 remote: Using puma 3.9.1 remote: Using  
>  sprockets 3.7.2 remote: Using sprockets-rails 3.2.1 remote:  
>  Using rails 5.1.6 remote: Using tilt 2.0.10 remote:  
>  Using sass-rails 5.0.6 remote: Using turbolinks-source 5.2.0  
>  remote: Using turbolinks 5.0.1 remote: Using uglifier  
>  3.2.0 remote: Bundle complete! 26 Gemfile dependencies, 63 gems now
> installed remote: Gems in the groups development and test  
>  were not installed. remote: Bundled gems are installed into  
>  `./vendor/bundle` remote: Bundle completed (0.46s) remote:  
>  Cleaning up the bundler cache. remote: The dependency  
>  tzinfo-data (>= 0) will be unused by any of the platforms Bundler is  
>  installing for. Bundler is installing for ruby but the dependency is  
>  only for x86-mingw32, x86-mswin32, x64-mingw32, java. To add those  
>  platforms to the bundle, run `bundle lock --add-platform x86-mingw32
> x86-mswin32 x64-mingw32 java`. remote: -----> Installing  
>  node-v12.16.2-linux-x64 remote: -----> Detecting rake tasks remote:  
>  \-----> Preparing app for Rails asset pipeline remote: Running: rake
> assets:precompile remote: rake aborted! remote:  
>  _**> SyntaxError: /tmp/build_e0d5d49b/config/environments/production.rb:73:  
>  syntax error, unexpected tSYMBEG, expecting '}' remote:  
>  :port =>'587' remote: ^ remote:  
>  /tmp/build_e0d5d49b/config/environments/production.rb:74: syntax  
>  error, unexpected =>, expecting end-of-input remote:  
>  :user_name => ENV['SENDGRID_USERNAME'], remote:  
>  ^~ remote:**_  
>
> /tmp/build_e0d5d49b/vendor/bundle/ruby/2.6.0/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:292:in
> `require' remote:
> /tmp/build_e0d5d49b/vendor/bundle/ruby/2.6.0/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:292:in
> `block in require' remote:  
>
> /tmp/build_e0d5d49b/vendor/bundle/ruby/2.6.0/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:258:in
> `load_dependency' remote:
> /tmp/build_e0d5d49b/vendor/bundle/ruby/2.6.0/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:292:in
> `require' remote:  
>
> /tmp/build_e0d5d49b/vendor/bundle/ruby/2.6.0/gems/railties-5.1.6/lib/rails/engine.rb:600:in  
>  `block (2 levels) in <class:Engine>' remote:
> /tmp/build_e0d5d49b/vendor/bundle/ruby/2.6.0/gems/railties-5.1.6/lib/rails/engine.rb:599:in
> `each' remote:  
>
> /tmp/build_e0d5d49b/vendor/bundle/ruby/2.6.0/gems/railties-5.1.6/lib/rails/engine.rb:599:in  
>  `block in <class:Engine>' remote:
> /tmp/build_e0d5d49b/vendor/bundle/ruby/2.6.0/gems/railties-5.1.6/lib/rails/initializable.rb:30:in
> `instance_exec' remote:  
>
> /tmp/build_e0d5d49b/vendor/bundle/ruby/2.6.0/gems/railties-5.1.6/lib/rails/initializable.rb:30:in  
>  `run' remote:
> /tmp/build_e0d5d49b/vendor/bundle/ruby/2.6.0/gems/railties-5.1.6/lib/rails/initializable.rb:59:in
> `block in run_initializers' remote:  
>
> /tmp/build_e0d5d49b/vendor/bundle/ruby/2.6.0/gems/railties-5.1.6/lib/rails/initializable.rb:48:in  
>  `each' remote:
> /tmp/build_e0d5d49b/vendor/bundle/ruby/2.6.0/gems/railties-5.1.6/lib/rails/initializable.rb:48:in
> `tsort_each_child' remote:  
>
> /tmp/build_e0d5d49b/vendor/bundle/ruby/2.6.0/gems/railties-5.1.6/lib/rails/initializable.rb:58:in  
>  `run_initializers' remote:
> /tmp/build_e0d5d49b/vendor/bundle/ruby/2.6.0/gems/railties-5.1.6/lib/rails/application.rb:353:in
> `initialize!' remote:  
>  /tmp/build_e0d5d49b/config/environment.rb:5:in `<top (required)>' remote:
> /tmp/build_e0d5d49b/vendor/bundle/ruby/2.6.0/gems/railties-5.1.6/lib/rails/application.rb:329:in
> `require' remote:  
>
> /tmp/build_e0d5d49b/vendor/bundle/ruby/2.6.0/gems/railties-5.1.6/lib/rails/application.rb:329:in  
>  `require_environment!' remote:
> /tmp/build_e0d5d49b/vendor/bundle/ruby/2.6.0/gems/railties-5.1.6/lib/rails/application.rb:445:in
> `block in run_tasks_blocks' remote:  
>  /tmp/build_e0d5d49b/vendor/bundle/ruby/2.6.0/gems/sprockets-
> rails-3.2.1/lib/sprockets/rails/task.rb:62:in  
>  `block (2 levels) in define' remote: Tasks: TOP => environment  
>  remote: (See full trace by running task with --trace) remote:  
>  remote: ! remote: ! Precompiling assets failed. remote: !  
>  remote: ! Push rejected, failed to compile Ruby app. remote:  
>  remote: ! Push failed remote: Verifying deploy... remote:  
>  remote: ! Push rejected to fast-depths-48015. remote: To  
>  <https://git.heroku.com/***********.git> ! [remote rejected]  
>  master -> master (pre-receive hook declined) error: failed to push  
>  some refs to 'https://git.heroku.com/***********.git'

斜線の部分からproduction.rbの変更部分が原因かと推測していますが、何度見返しても書き損じはありません。  
production.rbの変更部分

> config.action_mailer.raise_delivery_errors = true  
>  config.action_mailer.delivery_method = :smtp  
>  host => '***********.herokuapp.com'  
>  config.action_mailer.default_url_options = { host: host }  
>  ActionMailer::Base.smtp_settings = {  
>  :address => 'smtp.sendgrid.net',  
>  :port => '587',  
>  :authentication => :plain,  
>  :user_name => ENV['SENDGRID_USERNAME'],  
>  :password => ENV['SENDGRID_PASSWORD'],  
>  :domain => 'heroku.com',  
>  :enable_starttls_auto => true }

開発環境  
ruby 2.6.5p114  
Rails 5.1.6  
VSCode  
WSL:Debian

本番環境  
Heroku

【追記】production.rbのコードを全文貼り付けます。コメントを残しているので長くなってしまってすみません。

> Rails.application.configure do # Settings specified here will take  
>  precedence over those in config/application.rb.
>
> # Code is not reloaded between requests. config.cache_classes =
>
> true
>
> # Eager load code on boot. This eager loads most of Rails and
>
> your application in memory, allowing both threaded web servers # and  
>  those relying on copy on write to perform better. # Rake tasks  
>  automatically ignore this option for performance. config.eager_load  
>  = true
>
> # Full error reports are disabled and caching is turned on.
>
> config.consider_all_requests_local = false  
>  config.action_controller.perform_caching = true
>
> # Attempt to read encrypted secrets from `config/secrets.yml.enc`.
>
> # Requires an encryption key in `ENV["RAILS_MASTER_KEY"]` or #
> `config/secrets.yml.key`. config.read_encrypted_secrets = true
>
> # Disable serving static files from the `/public` folder by default
>
> since # Apache or NGINX already handles this.  
>  config.public_file_server.enabled =  
>  ENV['RAILS_SERVE_STATIC_FILES'].present?
>
> # Compress JavaScripts and CSS. config.assets.js_compressor =
>
> :uglifier # config.assets.css_compressor = :sass
>
> # Do not fallback to assets pipeline if a precompiled asset is
>
> missed. config.assets.compile = false
>
> # `config.assets.precompile` and `config.assets.version` have moved
>
> to config/initializers/assets.rb
>
> # Enable serving of images, stylesheets, and JavaScripts from an
>
> asset server. # config.action_controller.asset_host =  
>  'http://assets.example.com'
>
> # Specifies the header that your server uses for sending files.
>
> config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
>
> # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
>
> # Mount Action Cable outside main process or domain
>
> config.action_cable.mount_path = nil # config.action_cable.url =  
>  'wss://example.com/cable' #  
>  config.action_cable.allowed_request_origins = [ 'http://example.com',  
>  /http://example.*/ ]
>
> # Force all access to the app over SSL, use
>
> Strict-Transport-Security, and use secure cookies. config.force_ssl  
>  = true
>
> # Use the lowest log level to ensure availability of diagnostic
>
> information # when problems arise. config.log_level = :debug
>
> # Prepend all log lines with the following tags. config.log_tags =
>
> [ :request_id ]
>
> # Use a different cache store in production. # config.cache_store
>
> = :mem_cache_store
>
> # Use a real queuing backend for Active Job (and separate queues per
>
> environment) # config.active_job.queue_adapter = :resque #  
>  config.active_job.queue_name_prefix = "sample_app_#{Rails.env}"  
>  config.action_mailer.perform_caching = false
>
> # Ignore bad email addresses and do not raise email delivery errors.
>
> # Set this to true and configure the email server for immediate delivery to
> raise delivery errors.
>
> config.action_mailer.raise_delivery_errors = true  
>  config.action_mailer.delivery_method = :smtp host =  
>  '***********.herokuapp.com'  
>  config.action_mailer.default_url_options = { host: host }  
>  ActionMailer::Base.smtp_settings = {  
>  :address => 'smtp.sendgrid.net',  
>  :port => '587',  
>  :authentication => :plain,  
>  :user_name => ENV['SENDGRID_USERNAME'],  
>  :password => ENV['SENDGRID_PASSWORD'],  
>  :domain => 'heroku.com',  
>  :enable_starttls_auto => true }
>
> # Enable locale fallbacks for I18n (makes lookups for any locale
>
> fall back to # the I18n.default_locale when a translation cannot be  
>  found). config.i18n.fallbacks = true
>
> # Send deprecation notices to registered listeners.
>
> config.active_support.deprecation = :notify
>
> # Use default logging formatter so that PID and timestamp are not
>
> suppressed. config.log_formatter = ::Logger::Formatter.new
>
> # Use a different logger for distributed setups. # require
>
> 'syslog/logger' # config.logger =  
>  ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
>
> if ENV["RAILS_LOG_TO_STDOUT"].present?  
>  logger = ActiveSupport::Logger.new(STDOUT)  
>  logger.formatter = config.log_formatter  
>  config.logger = ActiveSupport::TaggedLogging.new(logger) end
>
> # Do not dump schema after migrations.
>
> config.active_record.dump_schema_after_migration = false end


CC BY-SA 4.0
2020-07-16T05:12:01.467
68636
2020-07-24T04:38:58.760
2020-07-24T04:38:58.760
41115
41115
question
ruby-on-rails ruby heroku
Rails Tutorial 11章 herokuにデプロイできません

[code]

    ruby -cW production.rb
    
[/code]

とするともう少し原因を絞れるかもしれません。(コメントに書くべきだと思いますが、まだ書けないのでこちらでご容赦ください)


CC BY-SA 4.0
2020-07-16T17:59:05.937
68654
2020-07-16T17:59:05.937
40151
68636
answer