Rails Heroku应用程序-预编译资产失败

时间:2019-05-13 01:50:19

标签: ruby-on-rails heroku deployment

我最近制作了一个Rails应用程序,并且一直在尝试将其部署在Heroku上。我不确定是什么原因阻止了我这样做。我将Heroku与我的Github链接在一起,并从那里手动进行部署。

Github存储库是最新的,当我输入

时,rails应用程序可以运行
rails s

我也尝试从计算机上手动部署。我一直在遵循本指南: https://www.codecademy.com/articles/deploy-rails-to-heroku

这是错误日志:

 !     Warning: Multiple default buildpacks reported the ability to handle this app. The first buildpack in the list below will be used.
            Detected buildpacks: Ruby,Node.js
            See https://devcenter.heroku.com/articles/buildpacks#buildpack-detect-order
-----> Ruby app detected
-----> Compiling Ruby/Rails
-----> Using Ruby version: ruby-2.5.5
###### WARNING:
       Removing `Gemfile.lock` because it was generated on Windows.
       Bundler will do a full resolve so native gems are handled properly.
       This may result in unexpected gem versions being used in your app.
       In rare occasions Bundler may not be able to resolve your dependencies at all.
       https://devcenter.heroku.com/articles/bundler-windows-gemfile
-----> Installing dependencies using bundler 2.0.1
       Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4
       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`.
       Fetching gem metadata from https://rubygems.org/...........
       Fetching gem metadata from https://rubygems.org/.
       Resolving dependencies.....
       Fetching rake 12.3.2
       Installing rake 12.3.2
       Fetching concurrent-ruby 1.1.5
       Fetching minitest 5.11.3
       Fetching thread_safe 0.3.6
       Installing minitest 5.11.3
       Installing thread_safe 0.3.6
       Installing concurrent-ruby 1.1.5
       Fetching builder 3.2.3
       Installing builder 3.2.3
       Fetching erubi 1.8.0
       Installing erubi 1.8.0
       Fetching mini_portile2 2.4.0
       Fetching crass 1.0.4
       Installing mini_portile2 2.4.0
       Installing crass 1.0.4
       Fetching rack 2.0.7
       Installing rack 2.0.7
       Fetching nio4r 2.3.1
       Installing nio4r 2.3.1 with native extensions
       Fetching websocket-extensions 0.1.3
       Installing websocket-extensions 0.1.3
       Fetching mini_mime 1.0.1
       Installing mini_mime 1.0.1
       Fetching arel 9.0.0
       Installing arel 9.0.0
       Fetching mimemagic 0.3.3
       Fetching bcrypt 3.1.12
       Installing bcrypt 3.1.12 with native extensions
       Installing mimemagic 0.3.3
       Fetching msgpack 1.2.10
       Installing msgpack 1.2.10 with native extensions
       Fetching rb-fsevent 0.10.3
       Installing rb-fsevent 0.10.3
       Fetching ffi 1.10.0
       Installing ffi 1.10.0 with native extensions
       Fetching thor 0.20.3
       Installing thor 0.20.3
       Using bundler 2.0.1
       Fetching method_source 0.9.2
       Installing method_source 0.9.2
       Fetching coffee-script-source 1.12.2
       Installing coffee-script-source 1.12.2
       Fetching execjs 2.7.0
       Installing execjs 2.7.0
       Fetching duktape 2.0.1.0
       Installing duktape 2.0.1.0 with native extensions
       Fetching multipart-post 2.1.0
       Installing multipart-post 2.1.0
       Fetching multi_json 1.13.1
       Installing multi_json 1.13.1
       Fetching jwt 2.1.0
       Installing jwt 2.1.0
       Fetching pg 0.18.1
       Installing pg 0.18.1 with native extensions
       Fetching puma 3.12.1
       Installing puma 3.12.1 with native extensions
       Fetching rails_serve_static_assets 0.0.5
       Installing rails_serve_static_assets 0.0.5
       Fetching rails_stdout_logging 0.0.5
       Installing rails_stdout_logging 0.0.5
       Fetching tilt 2.0.9
       Installing tilt 2.0.9
       Fetching turbolinks-source 5.2.0
       Installing turbolinks-source 5.2.0
       Fetching tzinfo 1.2.5
       Installing tzinfo 1.2.5
       Fetching nokogiri 1.10.3
       Installing nokogiri 1.10.3 with native extensions
       Fetching i18n 1.6.0
       Installing i18n 1.6.0
       Fetching websocket-driver 0.7.0
       Installing websocket-driver 0.7.0 with native extensions
       Fetching mail 2.7.1
       Installing mail 2.7.1
       Fetching rack-test 1.1.0
       Installing rack-test 1.1.0
       Fetching sprockets 3.7.2
       Installing sprockets 3.7.2
       Fetching marcel 0.3.3
       Installing marcel 0.3.3
       Fetching coffee-script 2.4.1
       Installing coffee-script 2.4.1
       Fetching uglifier 4.1.20
       Installing uglifier 4.1.20
       Fetching bootsnap 1.4.4
       Installing bootsnap 1.4.4 with native extensions
       Fetching faraday 0.15.4
       Installing faraday 0.15.4
       Fetching rb-inotify 0.10.0
       Installing rb-inotify 0.10.0
       Fetching rails_12factor 0.0.3
       Installing rails_12factor 0.0.3
       Fetching turbolinks 5.2.0
       Installing turbolinks 5.2.0
       Fetching activesupport 5.2.3
       Installing activesupport 5.2.3
       Fetching loofah 2.2.3
       Installing loofah 2.2.3
       Fetching twilio-ruby 5.22.3
       Installing twilio-ruby 5.22.3
       Fetching sass-listen 4.0.0
       Installing sass-listen 4.0.0
       Fetching rails-html-sanitizer 1.0.4
       Installing rails-html-sanitizer 1.0.4
       Fetching rails-dom-testing 2.0.3
       Installing rails-dom-testing 2.0.3
       Fetching globalid 0.4.2
       Fetching activemodel 5.2.3
       Installing globalid 0.4.2
       Installing activemodel 5.2.3
       Fetching jbuilder 2.8.0
       Installing jbuilder 2.8.0
       Fetching sass 3.7.4
       Fetching actionview 5.2.3
       Installing sass 3.7.4
       Installing actionview 5.2.3
       Fetching activejob 5.2.3
       Installing activejob 5.2.3
       Fetching activerecord 5.2.3
       Fetching email_validator 1.6.0
       Installing email_validator 1.6.0
       Installing activerecord 5.2.3
       Fetching actionpack 5.2.3
       Installing actionpack 5.2.3
       Fetching bourbon 5.1.0
       Installing bourbon 5.1.0
       Fetching actioncable 5.2.3
       Installing actioncable 5.2.3
       Fetching actionmailer 5.2.3
       Installing actionmailer 5.2.3
       Fetching railties 5.2.3
       Fetching sprockets-rails 3.2.1
       Installing sprockets-rails 3.2.1
       Installing railties 5.2.3
       Fetching activestorage 5.2.3
       Installing activestorage 5.2.3
       Fetching coffee-rails 4.2.2
       Fetching clearance 1.17.0
       Fetching rails 5.2.3
       Installing rails 5.2.3
       Installing coffee-rails 4.2.2
       Installing clearance 1.17.0
       Fetching sass-rails 5.0.7
       Installing sass-rails 5.0.7
       Bundle complete! 22 Gemfile dependencies, 73 gems now installed.
       Gems in the groups development and test were not installed.
       Bundled gems are installed into `./vendor/bundle`
       Post-install message from i18n:

       HEADS UP! i18n 1.1 changed fallbacks to exclude default locale.
       But that may break your application.

       Please check your Rails app for 'config.i18n.fallbacks = true'.
       If you're using I18n (>= 1.1.0) and Rails (< 5.2.2), this should be
       'config.i18n.fallbacks = [I18n.default_locale]'.
       If not, fallbacks will be broken in your app by I18n 1.1.x.

       For more info see:
       https://github.com/svenfuchs/i18n/releases/tag/v1.1.0

       Post-install message from sass:

       Ruby Sass has reached end-of-life and should no longer be used.

       * If you use Sass as a command-line tool, we recommend using Dart Sass, the new
         primary implementation: https://sass-lang.com/install

       * If you use Sass as a plug-in for a Ruby web framework, we recommend using the
         sassc gem: https://github.com/sass/sassc-ruby#readme

       * For more details, please refer to the Sass blog:
         https://sass-lang.com/blog/posts/7828841

       Bundle completed (69.29s)
       Cleaning up the bundler cache.
-----> Installing node-v10.14.1-linux-x64
-----> Detecting rake tasks
-----> Preparing app for Rails asset pipeline
       Running: rake assets:precompile
       Yarn executable was not detected in the system.
       Download Yarn at https://yarnpkg.com/en/docs/install
       rake aborted!
       Uglifier::Error: Unexpected token: name (Chat). To use ES6 syntax, harmony mode must be enabled with Uglifier.new(:harmony => true).
       /tmp/build_009829cc03f1e07b3bba9f3f29879621/vendor/bundle/ruby/2.5.0/gems/uglifier-4.1.20/lib/uglifier.rb:234:in `parse_result'
       /tmp/build_009829cc03f1e07b3bba9f3f29879621/vendor/bundle/ruby/2.5.0/gems/uglifier-4.1.20/lib/uglifier.rb:216:in `run_uglifyjs'
       /tmp/build_009829cc03f1e07b3bba9f3f29879621/vendor/bundle/ruby/2.5.0/gems/uglifier-4.1.20/lib/uglifier.rb:168:in `compile'
       /tmp/build_009829cc03f1e07b3bba9f3f29879621/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.2/lib/sprockets/uglifier_compressor.rb:53:in `call'
       /tmp/build_009829cc03f1e07b3bba9f3f29879621/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.2/lib/sprockets/uglifier_compressor.rb:28:in `call'
       /tmp/build_009829cc03f1e07b3bba9f3f29879621/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.2/lib/sprockets/processor_utils.rb:75:in `call_processor'
       /tmp/build_009829cc03f1e07b3bba9f3f29879621/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.2/lib/sprockets/processor_utils.rb:57:in `block in call_processors'
       /tmp/build_009829cc03f1e07b3bba9f3f29879621/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.2/lib/sprockets/processor_utils.rb:56:in `reverse_each'
       /tmp/build_009829cc03f1e07b3bba9f3f29879621/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.2/lib/sprockets/processor_utils.rb:56:in `call_processors'
       /tmp/build_009829cc03f1e07b3bba9f3f29879621/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.2/lib/sprockets/loader.rb:134:in `load_from_unloaded'
       /tmp/build_009829cc03f1e07b3bba9f3f29879621/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.2/lib/sprockets/loader.rb:60:in `block in load'
       /tmp/build_009829cc03f1e07b3bba9f3f29879621/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.2/lib/sprockets/loader.rb:317:in `fetch_asset_from_dependency_cache'
       /tmp/build_009829cc03f1e07b3bba9f3f29879621/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.2/lib/sprockets/loader.rb:44:in `load'
       /tmp/build_009829cc03f1e07b3bba9f3f29879621/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.2/lib/sprockets/cached_environment.rb:20:in `block in initialize'
       /tmp/build_009829cc03f1e07b3bba9f3f29879621/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.2/lib/sprockets/cached_environment.rb:47:in `load'
       /tmp/build_009829cc03f1e07b3bba9f3f29879621/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.2/lib/sprockets/base.rb:66:in `find_asset'
       /tmp/build_009829cc03f1e07b3bba9f3f29879621/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.2/lib/sprockets/base.rb:73:in `find_all_linked_assets'
       /tmp/build_009829cc03f1e07b3bba9f3f29879621/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.2/lib/sprockets/manifest.rb:142:in `block in find'
       /tmp/build_009829cc03f1e07b3bba9f3f29879621/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.2/lib/sprockets/legacy.rb:114:in `block (2 levels) in logical_paths'
       /tmp/build_009829cc03f1e07b3bba9f3f29879621/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.2/lib/sprockets/path_utils.rb:228:in `block in stat_tree'
       /tmp/build_009829cc03f1e07b3bba9f3f29879621/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.2/lib/sprockets/path_utils.rb:212:in `block in stat_directory'
       /tmp/build_009829cc03f1e07b3bba9f3f29879621/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.2/lib/sprockets/path_utils.rb:209:in `each'
       /tmp/build_009829cc03f1e07b3bba9f3f29879621/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.2/lib/sprockets/path_utils.rb:209:in `stat_directory'
       /tmp/build_009829cc03f1e07b3bba9f3f29879621/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.2/lib/sprockets/path_utils.rb:227:in `stat_tree'
       /tmp/build_009829cc03f1e07b3bba9f3f29879621/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.2/lib/sprockets/legacy.rb:105:in `each'
       /tmp/build_009829cc03f1e07b3bba9f3f29879621/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.2/lib/sprockets/legacy.rb:105:in `block in logical_paths'
       /tmp/build_009829cc03f1e07b3bba9f3f29879621/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.2/lib/sprockets/legacy.rb:104:in `each'
       /tmp/build_009829cc03f1e07b3bba9f3f29879621/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.2/lib/sprockets/legacy.rb:104:in `logical_paths'
       /tmp/build_009829cc03f1e07b3bba9f3f29879621/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.2/lib/sprockets/manifest.rb:140:in `find'
       /tmp/build_009829cc03f1e07b3bba9f3f29879621/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.2/lib/sprockets/manifest.rb:186:in `compile'
       /tmp/build_009829cc03f1e07b3bba9f3f29879621/vendor/bundle/ruby/2.5.0/gems/sprockets-rails-3.2.1/lib/sprockets/rails/task.rb:68:in `block (3 levels) in define'
       /tmp/build_009829cc03f1e07b3bba9f3f29879621/vendor/bundle/ruby/2.5.0/gems/sprockets-3.7.2/lib/rake/sprocketstask.rb:147:in `with_logger'
       /tmp/build_009829cc03f1e07b3bba9f3f29879621/vendor/bundle/ruby/2.5.0/gems/sprockets-rails-3.2.1/lib/sprockets/rails/task.rb:67:in `block (2 levels) in define'
       /tmp/build_009829cc03f1e07b3bba9f3f29879621/vendor/bundle/ruby/2.5.0/gems/rake-12.3.2/exe/rake:27:in `<top (required)>'
       Tasks: TOP => assets:precompile
       (See full trace by running task with --trace)
 !
 !     Precompiling assets failed.
 !
 !     Push rejected, failed to compile Ruby app.
 !     Push failed

2 个答案:

答案 0 :(得分:1)

问题本身已经在错误说明中提供了解决方案

To use ES6 syntax, harmony mode must be enabled with Uglifier.new(:harmony => true)

解决方案:

要解决此问题,请在config/environments/production.rb

中替换以下内容
config.assets.js_compressor = :uglifier

使用

config.assets.js_compressor = Uglifier.new(harmony: true)

请参阅,这个问题在uglifier https://github.com/lautis/uglifier/issues/127

中提出

答案 1 :(得分:0)

您可以尝试使用以下命令在上载到heroku之前对其进行预编译:

RAILS_ENV=production bundle exec rake assets:precompile

并创建一个新的提交并推送

git add .
git commit -m "precompile"
git push

还值得检查:color words