#ruby-on-rails #heroku
#ruby-on-rails #heroku
Вопрос:
Впервые у меня возникла проблема с развертыванием на heroku. Я создал приложение, которое отлично работает на localhost. Я добавил некоторые учетные данные API с:
EDITOR="nano" rails credentials:edit
Похоже, это работает, потому что я могу распечатать их в своей консоли с помощью:
Rails.application.credentials.myapikey[:key]
В моем файле production.rb я раскомментировал строку:
config.require_master_key = true
После этого я добавил свой главный ключ в конфигурацию heroku:
heroku config:set RAILS_MASTER_KEY=12345...
Запуск развертывания вызывает некоторые ошибки, но я не знаю почему. Все другие темы, касающиеся неудачной перкомпиляции, не соответствуют моей текущей ситуации. Я уже пытался удалить главный ключ и создать новый. Никакой разницы.
Есть идеи, как это исправить??
Журналы:
remote: Compressing source files... done.
remote: Building source:
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.7.0
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: 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.7
remote: Using i18n 1.8.5
remote: Using minitest 5.14.2
remote: Using thread_safe 0.3.6
remote: Using tzinfo 1.2.7
remote: Using zeitwerk 2.4.0
remote: Using activesupport 6.0.3.3
remote: Using builder 3.2.4
remote: Using erubi 1.9.0
remote: Using mini_portile2 2.4.0
remote: Using nokogiri 1.10.10
remote: Using rails-dom-testing 2.0.3
remote: Using crass 1.0.6
remote: Using loofah 2.7.0
remote: Using rails-html-sanitizer 1.3.0
remote: Using actionview 6.0.3.3
remote: Using rack 2.2.3
remote: Using rack-test 1.1.0
remote: Using actionpack 6.0.3.3
remote: Using nio4r 2.5.4
remote: Using websocket-extensions 0.1.5
remote: Using websocket-driver 0.7.3
remote: Using actioncable 6.0.3.3
remote: Using globalid 0.4.2
remote: Using activejob 6.0.3.3
remote: Using activemodel 6.0.3.3
remote: Using activerecord 6.0.3.3
remote: Using mimemagic 0.3.5
remote: Using marcel 0.3.3
remote: Using activestorage 6.0.3.3
remote: Using mini_mime 1.0.2
remote: Using mail 2.7.1
remote: Using actionmailbox 6.0.3.3
remote: Using actionmailer 6.0.3.3
remote: Using actiontext 6.0.3.3
remote: Using activemodel-serializers-xml 1.0.2
remote: Using activeresource 5.1.1
remote: Using msgpack 1.3.3
remote: Using bootsnap 1.4.8
remote: Using browser_sniffer 1.2.2
remote: Using bundler 2.1.4
remote: Using multipart-post 2.1.1
remote: Using faraday 1.0.1
remote: Using ffi 1.13.1
remote: Using graphql 1.11.5
remote: Using graphql-client 0.16.0
remote: Using hashie 4.1.0
remote: Using jbuilder 2.10.1
remote: Using jwt 2.2.2
remote: Using method_source 1.0.0
remote: Using multi_json 1.15.0
remote: Using multi_xml 0.6.0
remote: Using oauth2 1.4.4
remote: Using omniauth 1.9.1
remote: Using omniauth-oauth2 1.5.0
remote: Using omniauth-shopify-oauth2 2.2.3
remote: Using pg 1.2.3
remote: Using puma 4.3.6
remote: Using rack-proxy 0.6.5
remote: Using thor 1.0.1
remote: Using railties 6.0.3.3
remote: Using sprockets 4.0.2
remote: Using sprockets-rails 3.2.2
remote: Using rails 6.0.3.3
remote: Using redirect_safely 1.0.0
remote: Using sassc 2.4.0
remote: Using tilt 2.0.10
remote: Using sassc-rails 2.1.2
remote: Using sass-rails 6.0.0
remote: Using shopify_api 9.2.0
remote: Using shopify_app 15.0.0
remote: Using turbolinks-source 5.2.0
remote: Using turbolinks 5.2.1
remote: Using webpacker 4.3.0
remote: Using will_paginate 3.3.0
remote: Using will_paginate-bootstrap4 0.2.2
remote: Bundle complete! 21 Gemfile dependencies, 77 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 (1.07s)
remote: Cleaning up the bundler cache.
remote: -----> Installing node-v12.16.2-linux-x64
remote: -----> Installing yarn-v1.22.4
remote: -----> Detecting rake tasks
remote: -----> Preparing app for Rails asset pipeline
remote: Running: rake assets:precompile
remote: rake aborted!
remote: ActiveSupport::MessageEncryptor::InvalidMessage: ActiveSupport::MessageEncryptor::InvalidMessage
remote: /tmp/build_ba419abe/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.3.3/lib/active_support/message_encryptor.rb:206:in `rescue in _decrypt'
remote: /tmp/build_ba419abe/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.3.3/lib/active_support/message_encryptor.rb:183:in `_decrypt'
remote: /tmp/build_ba419abe/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.3.3/lib/active_support/message_encryptor.rb:157:in `decrypt_and_verify'
remote: /tmp/build_ba419abe/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.3.3/lib/active_support/messages/rotator.rb:21:in `decrypt_and_verify'
remote: /tmp/build_ba419abe/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.3.3/lib/active_support/encrypted_file.rb:80:in `decrypt'
remote: /tmp/build_ba419abe/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.3.3/lib/active_support/encrypted_file.rb:43:in `read'
remote: /tmp/build_ba419abe/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.3.3/lib/active_support/encrypted_configuration.rb:21:in `read'
remote: /tmp/build_ba419abe/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.3.3/lib/active_support/encrypted_configuration.rb:33:in `config'
remote: /tmp/build_ba419abe/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.3.3/lib/active_support/encrypted_configuration.rb:38:in `options'
remote: /tmp/build_ba419abe/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.3.3/lib/active_support/core_ext/module/delegation.rb:303:in `method_missing'
remote: /tmp/build_ba419abe/config/initializers/shopify_app.rb:3:in `block in <main>'
remote: /tmp/build_ba419abe/vendor/bundle/ruby/2.7.0/gems/shopify_app-15.0.0/lib/shopify_app/configuration.rb:92:in `configure'
remote: /tmp/build_ba419abe/config/initializers/shopify_app.rb:1:in `<main>'
remote: /tmp/build_ba419abe/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:59:in `load'
remote: /tmp/build_ba419abe/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:59:in `load'
remote: /tmp/build_ba419abe/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.3.3/lib/active_support/dependencies.rb:318:in `block in load'
remote: /tmp/build_ba419abe/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.3.3/lib/active_support/dependencies.rb:291:in `load_dependency'
remote: /tmp/build_ba419abe/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.3.3/lib/active_support/dependencies.rb:318:in `load'
remote: /tmp/build_ba419abe/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.3/lib/rails/engine.rb:666:in `block in load_config_initializer'
remote: /tmp/build_ba419abe/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.3.3/lib/active_support/notifications.rb:182:in `instrument'
remote: /tmp/build_ba419abe/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.3/lib/rails/engine.rb:665:in `load_config_initializer'
remote: /tmp/build_ba419abe/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.3/lib/rails/engine.rb:625:in `block (2 levels) in <class:Engine>'
remote: /tmp/build_ba419abe/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.3/lib/rails/engine.rb:624:in `each'
remote: /tmp/build_ba419abe/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.3/lib/rails/engine.rb:624:in `block in <class:Engine>'
remote: /tmp/build_ba419abe/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.3/lib/rails/initializable.rb:32:in `instance_exec'
remote: /tmp/build_ba419abe/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.3/lib/rails/initializable.rb:32:in `run'
remote: /tmp/build_ba419abe/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.3/lib/rails/initializable.rb:61:in `block in run_initializers'
remote: /tmp/build_ba419abe/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.3/lib/rails/initializable.rb:50:in `each'
remote: /tmp/build_ba419abe/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.3/lib/rails/initializable.rb:50:in `tsort_each_child'
remote: /tmp/build_ba419abe/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.3/lib/rails/initializable.rb:60:in `run_initializers'
remote: /tmp/build_ba419abe/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.3/lib/rails/application.rb:363:in `initialize!'
remote: /tmp/build_ba419abe/config/environment.rb:5:in `<main>'
remote: /tmp/build_ba419abe/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
remote: /tmp/build_ba419abe/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
remote: /tmp/build_ba419abe/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
remote: /tmp/build_ba419abe/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
remote: /tmp/build_ba419abe/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
remote: /tmp/build_ba419abe/vendor/bundle/ruby/2.7.0/gems/zeitwerk-2.4.0/lib/zeitwerk/kernel.rb:34:in `require'
remote: /tmp/build_ba419abe/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.3.3/lib/active_support/dependencies.rb:324:in `block in require'
remote: /tmp/build_ba419abe/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.3.3/lib/active_support/dependencies.rb:291:in `load_dependency'
remote: /tmp/build_ba419abe/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.3.3/lib/active_support/dependencies.rb:324:in `require'
remote: /tmp/build_ba419abe/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.3/lib/rails/application.rb:339:in `require_environment!'
remote: /tmp/build_ba419abe/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.3/lib/rails/application.rb:523:in `block in run_tasks_blocks'
remote: /tmp/build_ba419abe/vendor/bundle/ruby/2.7.0/gems/sprockets-rails-3.2.2/lib/sprockets/rails/task.rb:61:in `block (2 levels) in define'
remote:
remote: Caused by:
remote: ArgumentError: key must be 16 bytes
remote: /tmp/build_ba419abe/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.3.3/lib/active_support/message_encryptor.rb:193:in `key='
remote: /tmp/build_ba419abe/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.3.3/lib/active_support/message_encryptor.rb:193:in `_decrypt'
remote: /tmp/build_ba419abe/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.3.3/lib/active_support/message_encryptor.rb:157:in `decrypt_and_verify'
remote: /tmp/build_ba419abe/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.3.3/lib/active_support/messages/rotator.rb:21:in `decrypt_and_verify'
remote: /tmp/build_ba419abe/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.3.3/lib/active_support/encrypted_file.rb:80:in `decrypt'
remote: /tmp/build_ba419abe/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.3.3/lib/active_support/encrypted_file.rb:43:in `read'
remote: /tmp/build_ba419abe/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.3.3/lib/active_support/encrypted_configuration.rb:21:in `read'
remote: /tmp/build_ba419abe/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.3.3/lib/active_support/encrypted_configuration.rb:33:in `config'
remote: /tmp/build_ba419abe/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.3.3/lib/active_support/encrypted_configuration.rb:38:in `options'
remote: /tmp/build_ba419abe/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.3.3/lib/active_support/core_ext/module/delegation.rb:303:in `method_missing'
remote: /tmp/build_ba419abe/config/initializers/shopify_app.rb:3:in `block in <main>'
remote: /tmp/build_ba419abe/vendor/bundle/ruby/2.7.0/gems/shopify_app-15.0.0/lib/shopify_app/configuration.rb:92:in `configure'
remote: /tmp/build_ba419abe/config/initializers/shopify_app.rb:1:in `<main>'
remote: /tmp/build_ba419abe/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:59:in `load'
remote: /tmp/build_ba419abe/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:59:in `load'
remote: /tmp/build_ba419abe/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.3.3/lib/active_support/dependencies.rb:318:in `block in load'
remote: /tmp/build_ba419abe/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.3.3/lib/active_support/dependencies.rb:291:in `load_dependency'
remote: /tmp/build_ba419abe/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.3.3/lib/active_support/dependencies.rb:318:in `load'
remote: /tmp/build_ba419abe/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.3/lib/rails/engine.rb:666:in `block in load_config_initializer'
remote: /tmp/build_ba419abe/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.3.3/lib/active_support/notifications.rb:182:in `instrument'
remote: /tmp/build_ba419abe/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.3/lib/rails/engine.rb:665:in `load_config_initializer'
remote: /tmp/build_ba419abe/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.3/lib/rails/engine.rb:625:in `block (2 levels) in <class:Engine>'
remote: /tmp/build_ba419abe/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.3/lib/rails/engine.rb:624:in `each'
remote: /tmp/build_ba419abe/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.3/lib/rails/engine.rb:624:in `block in <class:Engine>'
remote: /tmp/build_ba419abe/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.3/lib/rails/initializable.rb:32:in `instance_exec'
remote: /tmp/build_ba419abe/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.3/lib/rails/initializable.rb:32:in `run'
remote: /tmp/build_ba419abe/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.3/lib/rails/initializable.rb:61:in `block in run_initializers'
remote: /tmp/build_ba419abe/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.3/lib/rails/initializable.rb:50:in `each'
remote: /tmp/build_ba419abe/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.3/lib/rails/initializable.rb:50:in `tsort_each_child'
remote: /tmp/build_ba419abe/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.3/lib/rails/initializable.rb:60:in `run_initializers'
remote: /tmp/build_ba419abe/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.3/lib/rails/application.rb:363:in `initialize!'
remote: /tmp/build_ba419abe/config/environment.rb:5:in `<main>'
remote: /tmp/build_ba419abe/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
remote: /tmp/build_ba419abe/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
remote: /tmp/build_ba419abe/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
remote: /tmp/build_ba419abe/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
remote: /tmp/build_ba419abe/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
remote: /tmp/build_ba419abe/vendor/bundle/ruby/2.7.0/gems/zeitwerk-2.4.0/lib/zeitwerk/kernel.rb:34:in `require'
remote: /tmp/build_ba419abe/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.3.3/lib/active_support/dependencies.rb:324:in `block in require'
remote: /tmp/build_ba419abe/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.3.3/lib/active_support/dependencies.rb:291:in `load_dependency'
remote: /tmp/build_ba419abe/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.3.3/lib/active_support/dependencies.rb:324:in `require'
remote: /tmp/build_ba419abe/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.3/lib/rails/application.rb:339:in `require_environment!'
remote: /tmp/build_ba419abe/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.3/lib/rails/application.rb:523:in `block in run_tasks_blocks'
remote: /tmp/build_ba419abe/vendor/bundle/ruby/2.7.0/gems/sprockets-rails-3.2.2/lib/sprockets/rails/task.rb:61: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 my_app.
remote:
To https://git.heroku.com/my_app.git
! [remote rejected] add_api_credentials -> master (pre-receive hook declined)
Ответ №1:
Что ж, это немного смущает, но проблема заключалась в том, что он сидел перед компьютером. На всякий случай, если у кого-то есть такая же проблема, убедитесь, что вы не совершаете ту же ошибку:
При настройке главного ключа heroku
heroku config:set RAILS_MASTER_KEY=12345..
Я скопировал secret_key_base из файла учетных данных вместо ключа, который записан в master.key.
Это была единственная причина, по которой heroku выдал ошибку: ключ должен быть 16 байт. После исправления ключа развертывание снова работает.