Ruby on Rails - Heroku上的Carrierwave错误
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Ruby on Rails - Heroku上的Carrierwave错误相关的知识,希望对你有一定的参考价值。
当尝试在Heroku上部署Ruby on Rails应用程序时,我不断收到此错误(注意:它在我的AWS Cloud9 Dev。环境中不存在)。我一直在谷歌搜索错误,但找不到任何东西(宝石文件显示在这篇文章的底部)
-----> Preparing app for Rails asset pipeline
Running: rake assets:precompile
rake aborted!
LoadError: cannot load such file -- fog
/tmp/build_5e7923a7e29e56747598006c2e9e9163/AndrewSanford-oafd-9b30ac69df2758e10ba9a44697e3a457f344f4eb/vendor/bundle/ruby/2.3.0/gems/activesupport-5.1.2/lib/active_support/dependencies.rb:292:in `require'
/tmp/build_5e7923a7e29e56747598006c2e9e9163/AndrewSanford-oafd-9b30ac69df2758e10ba9a44697e3a457f344f4eb/vendor/bundle/ruby/2.3.0/gems/activesupport-5.1.2/lib/active_support/dependencies.rb:292:in `block in require'
/tmp/build_5e7923a7e29e56747598006c2e9e9163/AndrewSanford-oafd-9b30ac69df2758e10ba9a44697e3a457f344f4eb/vendor/bundle/ruby/2.3.0/gems/activesupport-5.1.2/lib/active_support/dependencies.rb:258:in `load_dependency'
/tmp/build_5e7923a7e29e56747598006c2e9e9163/AndrewSanford-oafd-9b30ac69df2758e10ba9a44697e3a457f344f4eb/vendor/bundle/ruby/2.3.0/gems/activesupport-5.1.2/lib/active_support/dependencies.rb:292:in `require'
/tmp/build_5e7923a7e29e56747598006c2e9e9163/AndrewSanford-oafd-9b30ac69df2758e10ba9a44697e3a457f344f4eb/vendor/bundle/ruby/2.3.0/gems/carrierwave-1.1.0/lib/carrierwave/uploader/configuration.rb:122:in `eager_load_fog'
/tmp/build_5e7923a7e29e56747598006c2e9e9163/AndrewSanford-oafd-9b30ac69df2758e10ba9a44697e3a457f344f4eb/vendor/bundle/ruby/2.3.0/gems/carrierwave-1.1.0/lib/carrierwave/uploader/configuration.rb:137:in `fog_credentials='
/tmp/build_5e7923a7e29e56747598006c2e9e9163/AndrewSanford-oafd-9b30ac69df2758e10ba9a44697e3a457f344f4eb/config/initializers/carrier_wave.rb:3:in `block in <top (required)>'
/tmp/build_5e7923a7e29e56747598006c2e9e9163/AndrewSanford-oafd-9b30ac69df2758e10ba9a44697e3a457f344f4eb/vendor/bundle/ruby/2.3.0/gems/carrierwave-1.1.0/lib/carrierwave/uploader/configuration.rb:159:in `configure'
/tmp/build_5e7923a7e29e56747598006c2e9e9163/AndrewSanford-oafd-9b30ac69df2758e10ba9a44697e3a457f344f4eb/vendor/bundle/ruby/2.3.0/gems/carrierwave-1.1.0/lib/carrierwave.rb:14:in `configure'
/tmp/build_5e7923a7e29e56747598006c2e9e9163/AndrewSanford-oafd-9b30ac69df2758e10ba9a44697e3a457f344f4eb/config/initializers/carrier_wave.rb:2:in `<top (required)>'
/tmp/build_5e7923a7e29e56747598006c2e9e9163/AndrewSanford-oafd-9b30ac69df2758e10ba9a44697e3a457f344f4eb/vendor/bundle/ruby/2.3.0/gems/activesupport-5.1.2/lib/active_support/dependencies.rb:286:in `load'
/tmp/build_5e7923a7e29e56747598006c2e9e9163/AndrewSanford-oafd-9b30ac69df2758e10ba9a44697e3a457f344f4eb/vendor/bundle/ruby/2.3.0/gems/activesupport-5.1.2/lib/active_support/dependencies.rb:286:in `block in load'
/tmp/build_5e7923a7e29e56747598006c2e9e9163/AndrewSanford-oafd-9b30ac69df2758e10ba9a44697e3a457f344f4eb/vendor/bundle/ruby/2.3.0/gems/activesupport-5.1.2/lib/active_support/dependencies.rb:258:in `load_dependency'
/tmp/build_5e7923a7e29e56747598006c2e9e9163/AndrewSanford-oafd-9b30ac69df2758e10ba9a44697e3a457f344f4eb/vendor/bundle/ruby/2.3.0/gems/activesupport-5.1.2/lib/active_support/dependencies.rb:286:in `load'
/tmp/build_5e7923a7e29e56747598006c2e9e9163/AndrewSanford-oafd-9b30ac69df2758e10ba9a44697e3a457f344f4eb/vendor/bundle/ruby/2.3.0/gems/railties-5.1.2/lib/rails/engine.rb:655:in `block in load_config_initializer'
/tmp/build_5e7923a7e29e56747598006c2e9e9163/AndrewSanford-oafd-9b30ac69df2758e10ba9a44697e3a457f344f4eb/vendor/bundle/ruby/2.3.0/gems/activesupport-5.1.2/lib/active_support/notifications.rb:168:in `instrument'
/tmp/build_5e7923a7e29e56747598006c2e9e9163/AndrewSanford-oafd-9b30ac69df2758e10ba9a44697e3a457f344f4eb/vendor/bundle/ruby/2.3.0/gems/railties-5.1.2/lib/rails/engine.rb:654:in `load_config_initializer'
/tmp/build_5e7923a7e29e56747598006c2e9e9163/AndrewSanford-oafd-9b30ac69df2758e10ba9a44697e3a457f344f4eb/vendor/bundle/ruby/2.3.0/gems/railties-5.1.2/lib/rails/engine.rb:612:in `block (2 levels) in <class:Engine>'
/tmp/build_5e7923a7e29e56747598006c2e9e9163/AndrewSanford-oafd-9b30ac69df2758e10ba9a44697e3a457f344f4eb/vendor/bundle/ruby/2.3.0/gems/railties-5.1.2/lib/rails/engine.rb:611:in `each'
/tmp/build_5e7923a7e29e56747598006c2e9e9163/AndrewSanford-oafd-9b30ac69df2758e10ba9a44697e3a457f344f4eb/vendor/bundle/ruby/2.3.0/gems/railties-5.1.2/lib/rails/engine.rb:611:in `block in <class:Engine>'
/tmp/build_5e7923a7e29e56747598006c2e9e9163/AndrewSanford-oafd-9b30ac69df2758e10ba9a44697e3a457f344f4eb/vendor/bundle/ruby/2.3.0/gems/railties-5.1.2/lib/rails/initializable.rb:30:in `instance_exec'
/tmp/build_5e7923a7e29e56747598006c2e9e9163/AndrewSanford-oafd-9b30ac69df2758e10ba9a44697e3a457f344f4eb/vendor/bundle/ruby/2.3.0/gems/railties-5.1.2/lib/rails/initializable.rb:30:in `run'
/tmp/build_5e7923a7e29e56747598006c2e9e9163/AndrewSanford-oafd-9b30ac69df2758e10ba9a44697e3a457f344f4eb/vendor/bundle/ruby/2.3.0/gems/railties-5.1.2/lib/rails/initializable.rb:59:in `block in run_initializers'
/tmp/build_5e7923a7e29e56747598006c2e9e9163/AndrewSanford-oafd-9b30ac69df2758e10ba9a44697e3a457f344f4eb/vendor/bundle/ruby/2.3.0/gems/railties-5.1.2/lib/rails/initializable.rb:48:in `each'
/tmp/build_5e7923a7e29e56747598006c2e9e9163/AndrewSanford-oafd-9b30ac69df2758e10ba9a44697e3a457f344f4eb/vendor/bundle/ruby/2.3.0/gems/railties-5.1.2/lib/rails/initializable.rb:48:in `tsort_each_child'
/tmp/build_5e7923a7e29e56747598006c2e9e9163/AndrewSanford-oafd-9b30ac69df2758e10ba9a44697e3a457f344f4eb/vendor/bundle/ruby/2.3.0/gems/railties-5.1.2/lib/rails/initializable.rb:58:in `run_initializers'
/tmp/build_5e7923a7e29e56747598006c2e9e9163/AndrewSanford-oafd-9b30ac69df2758e10ba9a44697e3a457f344f4eb/vendor/bundle/ruby/2.3.0/gems/railties-5.1.2/lib/rails/application.rb:353:in `initialize!'
/tmp/build_5e7923a7e29e56747598006c2e9e9163/AndrewSanford-oafd-9b30ac69df2758e10ba9a44697e3a457f344f4eb/config/environment.rb:5:in `<top (required)>'
/tmp/build_5e7923a7e29e56747598006c2e9e9163/AndrewSanford-oafd-9b30ac69df2758e10ba9a44697e3a457f344f4eb/vendor/bundle/ruby/2.3.0/gems/railties-5.1.2/lib/rails/application.rb:329:in `require'
/tmp/build_5e7923a7e29e56747598006c2e9e9163/AndrewSanford-oafd-9b30ac69df2758e10ba9a44697e3a457f344f4eb/vendor/bundle/ruby/2.3.0/gems/railties-5.1.2/lib/rails/application.rb:329:in `require_environment!'
/tmp/build_5e7923a7e29e56747598006c2e9e9163/AndrewSanford-oafd-9b30ac69df2758e10ba9a44697e3a457f344f4eb/vendor/bundle/ruby/2.3.0/gems/railties-5.1.2/lib/rails/application.rb:445:in `block in run_tasks_blocks'
/tmp/build_5e7923a7e29e56747598006c2e9e9163/AndrewSanford-oafd-9b30ac69df2758e10ba9a44697e3a457f344f4eb/vendor/bundle/ruby/2.3.0/gems/sprockets-rails-3.2.1/lib/sprockets/rails/task.rb:62:in `block (2 levels) in define'
/tmp/build_5e7923a7e29e56747598006c2e9e9163/AndrewSanford-oafd-9b30ac69df2758e10ba9a44697e3a457f344f4eb/vendor/bundle/ruby/2.3.0/gems/rake-12.3.0/exe/rake:27:in `<top (required)>'
Tasks: TOP => environment
(See full trace by running task with --trace)
! !预编译资产失败。 ! !推送拒绝,无法编译Ruby应用程序。 !推送失败
Gemfile(部分):
gem 'rails', '5.1.2'
gem 'bcrypt', '3.1.11'
gem 'faker', '1.7.3'
gem 'carrierwave', '1.1.0'
gem 'mini_magick', '4.7.0'
gem 'fog-aws', '2.0.0'
gem 'nokogiri', '1.8.1'
gem 'will_paginate', '3.1.6'
gem 'bootstrap-will_paginate', '1.0.0'
gem 'bootstrap-sass', '3.3.7'
gem 'puma', '3.9.1'
gem 'sass-rails', '5.0.6'
gem 'uglifier', '3.2.0'
gem 'coffee-rails', '4.2.2'
gem 'jquery-rails', '4.3.1'
gem 'turbolinks', '5.0.1'
gem 'jbuilder', '2.7.0'
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 = "oafd_#{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 = 'fathomless-island-79606.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
答案
我希望您在production.rb中进行了以下更改:
config.serve_static_assets = true
如果没有进行此更改并尝试再次部署。
另一答案
你可以发布你的config / initializers / carrierwave.rb吗?看起来你可能需要'雾',但在应用程序中只包含'fog-aws'。我认为这也可能在开发中破坏所以它很奇怪你只是在部署到heroku时才看到它但它可能与此有关:https://github.com/carrierwaveuploader/carrierwave/issues/1648
以上是关于Ruby on Rails - Heroku上的Carrierwave错误的主要内容,如果未能解决你的问题,请参考以下文章