Heroku的预编译的资产失败(Heroku Precompiling Assets Failed)

2019-10-17 11:34发布

我的应用程序突然不更新后的工作。 不知道发生了什么错误。 基本上,当我推到Heroku的,我得到这些错误:

Precompiling assets failed, enabling runtime asset compilation
Injecting rails31_enable_runtime_asset_compilation

而高一点了:

   rake aborted!
   Unexpected token: operator (>) (line: 19073, col: 9, pos: 605247)
   Error
   at new JS_Parse_Error (/tmp/execjs20121211-811-1z5vum.js:1720:22)
   at js_error (/tmp/execjs20121211-811-1z5vum.js:1728:15)
   at croak (/tmp/execjs20121211-811-1z5vum.js:2189:17)
   at token_error (/tmp/execjs20121211-811-1z5vum.js:2196:17)
   at unexpected (/tmp/execjs20121211-811-1z5vum.js:2202:17)
   at /tmp/execjs20121211-811-1z5vum.js:2580:17
   at maybe_unary (/tmp/execjs20121211-811-1z5vum.js:2665:27)
   at expr_op (/tmp/execjs20121211-811-1z5vum.js:2685:45)
   at expr_ops (/tmp/execjs20121211-811-1z5vum.js:2692:24)
   at maybe_conditional (/tmp/execjs20121211-811-1z5vum.js:2696:28)

当我真正加载了该网站(“很抱歉,但出事了”),并期待在Heroku的日志,我得到这样的:

Load path: /app
2012-12-11T23:18:13+00:00 app[web.1]:     8:     <%= stylesheet_link_tag "application", :media => "all" %>
2012-12-11T23:18:13+00:00 app[web.1]:   (in /app/app/assets/stylesheets/custom.css.scss)):
2012-12-11T23:18:13+00:00 app[web.1]:     6:     <link href='http://fonts.googleapis.com/css?family=Kreon' rel='stylesheet' type='text/css'>
2012-12-11T23:18:13+00:00 app[web.1]: ActionView::Template::Error (File to import not found or unreadable: bootstrap.
2012-12-11T23:18:13+00:00 app[web.1]:     5:     <title><%= full_title(yield(:title)) %></title>
2012-12-11T23:18:13+00:00 app[web.1]:     7:     <%= favicon_link_tag 'favicon.ico' %>
2012-12-11T23:18:13+00:00 app[web.1]:     10:     <%= csrf_meta_tags %>
2012-12-11T23:18:13+00:00 app[web.1]:   app/assets/stylesheets/custom.css.scss:1
2012-12-11T23:18:13+00:00 app[web.1]:     11:     <meta name="google-site-verification" content="idIPkgRBikSL9PCS4rVkkZfRjxYbPxNbyF6tVymBWbc" />
2012-12-11T23:18:13+00:00 app[web.1]: 
2012-12-11T23:18:13+00:00 app[web.1]: 

(Kreon是我加了,而其他字体回到一个已经工作的罚款。custom.css.scss是我的主要的CSS文件,第一行是我在这没有改变,永远地合作的方式导入引导)。

我搜索了如何应对“要导入的文件找不到或无法读取:引导”的错误,并降落在这次讨论 ,并检查了相关的Heroku排查页面 ,但改变assets.compile真我production.rb文件导致Heroku的推上面的错误,而且似乎疑难解答网页并没有太多有关我的具体问题。 真的不知道这是怎么回事,所以我只是把一堆下面可能相关的代码。

的Gemfile

source 'https://rubygems.org'

gem 'rails', '3.2.8'
gem 'googlecharts', :require => "gchart"
gem 'unicorn'
gem 'newrelic_rpm'

# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
group :production do
    gem 'pg'
end

group :development do
    gem 'sqlite3'
    gem 'rspec-rails', '2.11.0'
  gem 'guard-rspec', '1.2.1'
end

group :test do 
    gem 'capybara', '1.1.2'
  gem 'rb-fsevent', '0.9.1'
  gem 'growl', '1.0.3'
  gem 'guard-spork', '1.2.0'
  gem 'spork', '0.9.2'
  gem 'factory_girl_rails', '4.1.0'
end

gem 'annotate', '2.5.0'
gem 'faker', '1.0.1'
gem 'will_paginate', '3.0.3'
gem 'bootstrap-will_paginate', '0.0.6'

# Gems used only for assets and not required
# in production environments by default.
group :assets do
  gem 'sass-rails',   '~> 3.2.3'
  gem 'coffee-rails', '~> 3.2.1'
  gem 'bootstrap-sass', '2.0.4'
  gem 'bcrypt-ruby', '3.0.1'

  # See https://github.com/sstephenson/execjs#readme for more supported runtimes
  # gem 'therubyracer', :platforms => :ruby

  gem 'uglifier', '>= 1.0.3'
end

gem 'jquery-rails'
gem 'roadie'
gem 'stripe', :git => 'https://github.com/stripe/stripe-ruby'
gem 'delayed_job_active_record'
gem 'daemons'
gem 'foreman'

# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'

# To use Jbuilder templates for JSON
# gem 'jbuilder'

# Use unicorn as the app server
# gem 'unicorn'

# Deploy with Capistrano
# gem 'capistrano'

# To use debugger
# gem 'debugger'

production.rb

MyApp::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

  # Force all access to the app over SSL, use Strict-Transport-Security, 
  # and use secure cookies.
  config.force_ssl = true

  # Full error reports are disabled and caching is turned on
  config.consider_all_requests_local       = false
  config.action_controller.perform_caching = true

  # Disable Rails's static asset server (Apache or nginx will already do this)
  config.serve_static_assets = false

  # Compress JavaScripts and CSS
  config.assets.compress = true

  # Don't fallback to assets pipeline if a precompiled asset is missed
  config.assets.compile = true

  # Generate digests for assets URLs
  config.assets.digest = true

  # Defaults to nil and saved in location specified by config.assets.prefix
  # config.assets.manifest = YOUR_PATH

  # 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

  # See everything in the log (default is :info)
  # config.log_level = :debug

  # 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"

  # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
  # config.assets.precompile += %w( search.js )

  # Disable delivery errors, bad email addresses will be ignored
  # config.action_mailer.raise_delivery_errors = false

  # Enable threaded mode
  # config.threadsafe!

  # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
  # the I18n.default_locale when a translation can not be found)
  config.i18n.fallbacks = true

  # Send deprecation notices to registered listeners
  config.active_support.deprecation = :notify

  # Log the query plan for queries taking more than this (works
  # with SQLite, MySQL, and PostgreSQL)
  # config.active_record.auto_explain_threshold_in_seconds = 0.5
end

这真的是我扔的线是这个在我的Heroku推日志:

Unexpected token: operator (>) (line: 19073, col: 9, pos: 605247)

问题是我不知道要寻找什么文件,在这个麻烦的“>”。 任何想法如何读取该行/列/ POS命名找到实际问题的代码片段?

谢谢。

Answer 1:

用的第1行开始app/assets/stylesheets/custom.css.scss并寻找一个错误> 。 另外,也要看看,以确保application.scss是你期望的。

也只需重命名custom.css.scss只是custom.scss哎呀,这可能做到这一点。



Answer 2:

同样的事情发生在我身上为好,
“预编译资产失败。” 而力推的Heroku,
在我的开发环境,我在我的CSS的错误:
” .........
光标:指针
颜色:#808080;”

缺少“;” 该“指针”后,发展环境不介意的错误,但Heroku的预编译任务做了。

其他一些问题可能会被重复命名的文件引起的,与“CSS”和“css.scss”后缀。



Answer 3:

在终端试试这个:

rake assets:precompile RAILS_ENV=production --trace

不是试图推动在Heroku更好。

我只是有同样的错误。 问题是:

  • 色器件的config.secret_key有人评论
  • syntax_error在JavaScript文件(“的”,而不是一个一个“中的”在for循环中)


文章来源: Heroku Precompiling Assets Failed