预编译资产失败.推送被拒绝,无法编译 Ruby 应用程序

Precompiling assets failed. Push rejected, failed to compile Ruby app

本文关键字:编译 Ruby 应用程序 拒绝 失败      更新时间:2023-09-26

我是 rails 新手,我有小项目,当我推送到 heroku 时看到此错误

Counting objects: 41, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (26/26), done.
Writing objects: 100% (26/26), 2.21 KiB | 0 bytes/s, done.
Total 26 (delta 19), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Ruby app detected
remote: -----> Compiling Ruby/Rails
remote: -----> Using Ruby version: ruby-1.9.3
remote: ###### WARNING:
remote:        Removing `Gemfile.lock` because it was generated on Windows.
remote:        Bundler will do a full resolve so native gems are handled properl
remote:        This may result in unexpected gem versions being used in your app
remote:        In rare occasions Bundler may not be able to resolve your depende
remote:        https://devcenter.heroku.com/articles/bundler-windows-gemfile
remote:
remote: -----> Installing dependencies using 1.6.3
remote:        Running: bundle install --without development:test --path vendor/
e/bin -j4
remote:        Fetching gem metadata from https://rubygems.org/..........
remote:        Resolving dependencies...
remote:        Using rake 10.4.2
remote:        Using i18n 0.6.11
remote:        Using json 1.8.1
remote:        Using minitest 5.5.0
remote:        Using thread_safe 0.3.4
remote:        Using builder 3.2.2
remote:        Using rack 1.5.2
remote:        Using erubis 2.7.0
remote:        Using mime-types 2.4.3
remote:        Using arel 5.0.1.20140414130214
remote:        Using browser 0.8.0
remote:        Using bundler 1.6.3
remote:        Using coffee-script-source 1.8.0
remote:        Using execjs 2.2.2
remote:        Using thor 0.19.1
remote:        Using hike 1.2.3
remote:        Using multi_json 1.10.1
remote:        Using pg 0.17.1
remote:        Using tilt 1.4.1
remote:        Using rails_serve_static_assets 0.0.2
remote:        Using sass 3.2.19
remote:        Using tzinfo 1.2.2
remote:        Using rack-test 0.6.2
remote:        Using coffee-script 2.3.0
remote:        Using rdoc 4.2.0
remote:        Using rails_stdout_logging 0.0.3
remote:        Using mail 2.6.3
remote:        Using activesupport 4.1.8
remote:        Using sprockets 2.12.3
remote:        Using uglifier 2.6.0
remote:        Using rails_12factor 0.0.3
remote:        Using actionview 4.1.8
remote:        Using activemodel 4.1.8
remote:        Using jbuilder 2.2.5
remote:        Using sdoc 0.4.1
remote:        Using actionpack 4.1.8
remote:        Using railties 4.1.8
remote:        Using actionmailer 4.1.8
remote:        Using coffee-rails 4.0.1
remote:        Using sprockets-rails 2.2.2
remote:        Using activerecord 4.1.8
remote:        Using jquery-rails 3.1.2
remote:        Using turbolinks 2.5.3
remote:        Using sass-rails 4.0.5
remote:        Using rails 4.1.8
remote:        Your bundle is complete!
remote:        Gems in the groups development and test were not installed.
remote:        It was installed into ./vendor/bundle
remote:        Bundle completed (6.79s)
remote:        Cleaning up the bundler cache.
remote: -----> Preparing app for Rails asset pipeline
remote:        Running: rake assets:precompile
remote:        rake aborted!
remote:        NoMethodError: undefined method `application' for Ruby3arabi:Modu
remote:        /tmp/build_d0f2bbb7ea12174ddc6ffbb7396c02ae/config/environment.rb
remote:        /tmp/build_d0f2bbb7ea12174ddc6ffbb7396c02ae/vendor/bundle/ruby/1.
ib/active_support/dependencies.rb:247:in `require'
remote:        /tmp/build_d0f2bbb7ea12174ddc6ffbb7396c02ae/vendor/bundle/ruby/1.
ib/active_support/dependencies.rb:247:in `block in require'
remote:        /tmp/build_d0f2bbb7ea12174ddc6ffbb7396c02ae/vendor/bundle/ruby/1.
ib/active_support/dependencies.rb:232:in `load_dependency'
remote:        /tmp/build_d0f2bbb7ea12174ddc6ffbb7396c02ae/vendor/bundle/ruby/1.
ib/active_support/dependencies.rb:247:in `require'
remote:        /tmp/build_d0f2bbb7ea12174ddc6ffbb7396c02ae/vendor/bundle/ruby/1.
ils/application.rb:276:in `require_environment!'
remote:        /tmp/build_d0f2bbb7ea12174ddc6ffbb7396c02ae/vendor/bundle/ruby/1.
ils/application.rb:389:in `block in run_tasks_blocks'
remote:        /tmp/build_d0f2bbb7ea12174ddc6ffbb7396c02ae/vendor/bundle/ruby/1.
/lib/sprockets/rails/task.rb:64:in `block (2 levels) in define'
remote:        Tasks: TOP => environment
remote:        (See full trace by running task with --trace)
remote:  !
remote:  !     Precompiling assets failed.
remote:  !
remote:
remote:  !     Push rejected, failed to compile Ruby app
remote:
remote: Verifying deploy...
remote:
remote: !       Push rejected to ruby3arabi.
remote:
To https://git.heroku.com/ruby3arabi.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/ruby3arabi.git'

我在我的项目中使用 mruby

我的第二个问题是我在页面中使用script标签,但它不起作用

<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
    <script src="http://d1n0x3qji82z53.cloudfront.net/src-min-noconflict/ace.js" type="text/javascript" charset="utf-8"></script>

我在本地主机中没有这个问题,但只有当我推送时

有人可以帮助我吗?

这是生产.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
  # Enable Rack::Cache to put a simple HTTP cache in front of your application
  # Add `rack-cache` to your Gemfile before enabling this.
  # For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid.
  # config.action_dispatch.rack_cache = true
  # Disable Rails's static asset server (Apache or nginx will already do this).
  config.serve_static_assets = true
  # 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 = true
  # Generate digests for assets URLs.
  config.assets.digest = true
  # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
  # 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
  # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
  # config.force_ssl = true
  # Set to :debug to see everything in the log.
  config.log_level = :info
  # Prepend all log lines with the following tags.
  # config.log_tags = [ :subdomain, :uuid ]
  # Use a different logger for distributed setups.
  # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
  # Use a different cache store in production.
  # config.cache_store = :mem_cache_store
  # Enable serving of images, stylesheets, and JavaScripts from an asset server.
  # config.action_controller.asset_host = "http://assets.example.com"
  # 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 = false
  # 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
  # Disable automatic flushing of the log to improve performance.
  # config.autoflush_log = false
  # Use default logging formatter so that PID and timestamp are not suppressed.
  config.log_formatter = ::Logger::Formatter.new
  # Do not dump schema after migrations.
  config.active_record.dump_schema_after_migration = false
end

这是应用程序.rb

require File.expand_path('../boot', __FILE__)
require 'rails/all'
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
module Ruby3arabi
  class Application < Rails::Application
    # Settings in config/environments/* take precedence over those specified here.
    # Application configuration should go into files in config/initializers
    # -- all .rb files in that directory are automatically loaded.
    # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
    # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
    # config.time_zone = 'Central Time (US & Canada)'
    # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
    # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
    # config.i18n.default_locale = :de
  end
end

环境.rb

# Load the Rails application.
require File.expand_path('../application', __FILE__)
# Initialize the Rails application.
Rails.application.initialize!

尝试在开发中手动预编译资产也许有一个错误,MRUBY认为这是一个不推:D的理由