由于“预编译资产失败”,Heroku部署rails5应用程序失败

时间:2019-04-07 00:12:24

标签: ruby-on-rails heroku assets pipeline precompile

运行git push heroku master开始了部署过程,但似乎在以下阶段挂起:

remote:        Fetching sass-rails 5.0.7
remote:        Installing sass-rails 5.0.7

最后它告诉我预编译资产失败。

我觉得我已经尽一切努力使它起作用。我正处于轮胎旋转的第三周,试图部署该应用程序。供参考,这里是仓库:https://github.com/mkrul/factory-ops

remote:        Post-install message from sass:
remote:        
remote:        Ruby Sass is deprecated and will be unmaintained as of 26 March 2019.
remote:        
remote:        * If you use Sass as a command-line tool, we recommend using Dart Sass, the new
remote:          primary implementation: https://sass-lang.com/install
remote:        
remote:        * If you use Sass as a plug-in for a Ruby web framework, we recommend using the
remote:          sassc gem: https://github.com/sass/sassc-ruby#readme
remote:        
remote:        * For more details, please refer to the Sass blog:
remote:          http://sass.logdown.com/posts/7081811
remote:        
remote:        Removing bundler (1.15.2)
remote:        Bundle completed (162.24s)
remote:        Cleaning up the bundler cache.
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: -----> Installing node-v10.14.1-linux-x64
remote: -----> Detecting rake tasks
remote: -----> Preparing app for Rails asset pipeline
remote:        Running: rake assets:precompile
remote:        Yarn executable was not detected in the system.
remote:        Download Yarn at https://yarnpkg.com/en/docs/install
remote:        rake aborted!
remote:        Uglifier::Error: Unexpected token: name (rails)
remote:        /tmp/build_515c8a50b0ac85c4870b659697d0fa8b/vendor/bundle/ruby/2.6.0/gems/uglifier-4.1.20/lib/uglifier.rb:234:in `parse_result'
remote:        /tmp/build_515c8a50b0ac85c4870b659697d0fa8b/vendor/bundle/ruby/2.6.0/gems/uglifier-4.1.20/lib/uglifier.rb:216:in `run_uglifyjs'
remote:        /tmp/build_515c8a50b0ac85c4870b659697d0fa8b/vendor/bundle/ruby/2.6.0/gems/uglifier-4.1.20/lib/uglifier.rb:168:in `compile'
remote:        /tmp/build_515c8a50b0ac85c4870b659697d0fa8b/vendor/bundle/ruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/compressing.rb:65:in `block in js_compressor='
remote:        /tmp/build_515c8a50b0ac85c4870b659697d0fa8b/vendor/bundle/ruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/legacy_proc_processor.rb:31:in `call'
remote:        /tmp/build_515c8a50b0ac85c4870b659697d0fa8b/vendor/bundle/ruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/processor_utils.rb:75:in `call_processor'
remote:        /tmp/build_515c8a50b0ac85c4870b659697d0fa8b/vendor/bundle/ruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/processor_utils.rb:57:in `block in call_processors'
remote:        /tmp/build_515c8a50b0ac85c4870b659697d0fa8b/vendor/bundle/ruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/processor_utils.rb:56:in `reverse_each'
remote:        /tmp/build_515c8a50b0ac85c4870b659697d0fa8b/vendor/bundle/ruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/processor_utils.rb:56:in `call_processors'
remote:        /tmp/build_515c8a50b0ac85c4870b659697d0fa8b/vendor/bundle/ruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/loader.rb:134:in `load_from_unloaded'
remote:        /tmp/build_515c8a50b0ac85c4870b659697d0fa8b/vendor/bundle/ruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/loader.rb:60:in `block in load'
remote:        /tmp/build_515c8a50b0ac85c4870b659697d0fa8b/vendor/bundle/ruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/loader.rb:317:in `fetch_asset_from_dependency_cache'
remote:        /tmp/build_515c8a50b0ac85c4870b659697d0fa8b/vendor/bundle/ruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/loader.rb:44:in `load'
remote:        /tmp/build_515c8a50b0ac85c4870b659697d0fa8b/vendor/bundle/ruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/cached_environment.rb:20:in `block in initialize'
remote:        /tmp/build_515c8a50b0ac85c4870b659697d0fa8b/vendor/bundle/ruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/cached_environment.rb:47:in `load'
remote:        /tmp/build_515c8a50b0ac85c4870b659697d0fa8b/vendor/bundle/ruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/base.rb:66:in `find_asset'
remote:        /tmp/build_515c8a50b0ac85c4870b659697d0fa8b/vendor/bundle/ruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/base.rb:73:in `find_all_linked_assets'
remote:        /tmp/build_515c8a50b0ac85c4870b659697d0fa8b/vendor/bundle/ruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/manifest.rb:142:in `block in find'
remote:        /tmp/build_515c8a50b0ac85c4870b659697d0fa8b/vendor/bundle/ruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/legacy.rb:114:in `block (2 levels) in logical_paths'
remote:        /tmp/build_515c8a50b0ac85c4870b659697d0fa8b/vendor/bundle/ruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/path_utils.rb:228:in `block in stat_tree'
remote:        /tmp/build_515c8a50b0ac85c4870b659697d0fa8b/vendor/bundle/ruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/path_utils.rb:212:in `block in stat_directory'
remote:        /tmp/build_515c8a50b0ac85c4870b659697d0fa8b/vendor/bundle/ruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/path_utils.rb:209:in `each'
remote:        /tmp/build_515c8a50b0ac85c4870b659697d0fa8b/vendor/bundle/ruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/path_utils.rb:209:in `stat_directory'
remote:        /tmp/build_515c8a50b0ac85c4870b659697d0fa8b/vendor/bundle/ruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/path_utils.rb:227:in `stat_tree'
remote:        /tmp/build_515c8a50b0ac85c4870b659697d0fa8b/vendor/bundle/ruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/legacy.rb:105:in `each'
remote:        /tmp/build_515c8a50b0ac85c4870b659697d0fa8b/vendor/bundle/ruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/legacy.rb:105:in `block in logical_paths'
remote:        /tmp/build_515c8a50b0ac85c4870b659697d0fa8b/vendor/bundle/ruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/legacy.rb:104:in `each'
remote:        /tmp/build_515c8a50b0ac85c4870b659697d0fa8b/vendor/bundle/ruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/legacy.rb:104:in `logical_paths'
remote:        /tmp/build_515c8a50b0ac85c4870b659697d0fa8b/vendor/bundle/ruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/manifest.rb:140:in `find'
remote:        /tmp/build_515c8a50b0ac85c4870b659697d0fa8b/vendor/bundle/ruby/2.6.0/gems/sprockets-3.7.2/lib/sprockets/manifest.rb:186:in `compile'
remote:        /tmp/build_515c8a50b0ac85c4870b659697d0fa8b/vendor/bundle/ruby/2.6.0/gems/sprockets-rails-3.2.1/lib/sprockets/rails/task.rb:68:in `block (3 levels) in define'
remote:        /tmp/build_515c8a50b0ac85c4870b659697d0fa8b/vendor/bundle/ruby/2.6.0/gems/sprockets-3.7.2/lib/rake/sprocketstask.rb:147:in `with_logger'
remote:        /tmp/build_515c8a50b0ac85c4870b659697d0fa8b/vendor/bundle/ruby/2.6.0/gems/sprockets-rails-3.2.1/lib/sprockets/rails/task.rb:67:in `block (2 levels) in define'
remote:        /tmp/build_515c8a50b0ac85c4870b659697d0fa8b/vendor/bundle/ruby/2.6.0/gems/rake-12.3.2/exe/rake:27:in `<top (required)>'
remote:        Tasks: TOP => assets:precompile
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 bar-and-pub-supply.
remote: 
To https://git.heroku.com/bar-and-pub-supply.git
 ! [remote rejected] master -> master (pre-receive hook declined)

更新美国东部标准时间4/6/8:40PM

更改sass-file gem和更改production.rb配置文件后,我运行RAILS_ENV=production bin/rails assets:precompile,并收到以下错误:

[1/5] Validating package.json...
[2/5] Resolving packages...
success Nothing to install.
success Saved lockfile.
Done in 0.18s.
rails aborted!
Uglifier::Error: Unexpected token: name (rails)
/home/mkrul/.rvm/gems/ruby-2.6.0/gems/uglifier-4.1.20/lib/uglifier.rb:234:in `parse_result'
/home/mkrul/.rvm/gems/ruby-2.6.0/gems/uglifier-4.1.20/lib/uglifier.rb:216:in `run_uglifyjs'
/home/mkrul/.rvm/gems/ruby-2.6.0/gems/uglifier-4.1.20/lib/uglifier.rb:168:in `compile'
/home/mkrul/.rvm/gems/ruby-2.6.0/gems/sprockets-3.7.2/lib/sprockets/compressing.rb:65:in `block in js_compressor='
/home/mkrul/.rvm/gems/ruby-2.6.0/gems/sprockets-3.7.2/lib/sprockets/legacy_proc_processor.rb:31:in `call'
/home/mkrul/.rvm/gems/ruby-2.6.0/gems/sprockets-3.7.2/lib/sprockets/processor_utils.rb:75:in `call_processor'
/home/mkrul/.rvm/gems/ruby-2.6.0/gems/sprockets-3.7.2/lib/sprockets/processor_utils.rb:57:in `block in call_processors'
/home/mkrul/.rvm/gems/ruby-2.6.0/gems/sprockets-3.7.2/lib/sprockets/processor_utils.rb:56:in `reverse_each'
/home/mkrul/.rvm/gems/ruby-2.6.0/gems/sprockets-3.7.2/lib/sprockets/processor_utils.rb:56:in `call_processors'
/home/mkrul/.rvm/gems/ruby-2.6.0/gems/sprockets-3.7.2/lib/sprockets/loader.rb:134:in `load_from_unloaded'
/home/mkrul/.rvm/gems/ruby-2.6.0/gems/sprockets-3.7.2/lib/sprockets/loader.rb:60:in `block in load'
/home/mkrul/.rvm/gems/ruby-2.6.0/gems/sprockets-3.7.2/lib/sprockets/loader.rb:317:in `fetch_asset_from_dependency_cache'
/home/mkrul/.rvm/gems/ruby-2.6.0/gems/sprockets-3.7.2/lib/sprockets/loader.rb:44:in `load'
/home/mkrul/.rvm/gems/ruby-2.6.0/gems/sprockets-3.7.2/lib/sprockets/cached_environment.rb:20:in `block in initialize'
/home/mkrul/.rvm/gems/ruby-2.6.0/gems/sprockets-3.7.2/lib/sprockets/cached_environment.rb:47:in `load'
/home/mkrul/.rvm/gems/ruby-2.6.0/gems/sprockets-3.7.2/lib/sprockets/base.rb:66:in `find_asset'
/home/mkrul/.rvm/gems/ruby-2.6.0/gems/sprockets-3.7.2/lib/sprockets/base.rb:73:in `find_all_linked_assets'
/home/mkrul/.rvm/gems/ruby-2.6.0/gems/sprockets-3.7.2/lib/sprockets/manifest.rb:142:in `block in find'
/home/mkrul/.rvm/gems/ruby-2.6.0/gems/sprockets-3.7.2/lib/sprockets/legacy.rb:114:in `block (2 levels) in logical_paths'
/home/mkrul/.rvm/gems/ruby-2.6.0/gems/sprockets-3.7.2/lib/sprockets/path_utils.rb:228:in `block in stat_tree'
/home/mkrul/.rvm/gems/ruby-2.6.0/gems/sprockets-3.7.2/lib/sprockets/path_utils.rb:212:in `block in stat_directory'
/home/mkrul/.rvm/gems/ruby-2.6.0/gems/sprockets-3.7.2/lib/sprockets/path_utils.rb:209:in `each'
/home/mkrul/.rvm/gems/ruby-2.6.0/gems/sprockets-3.7.2/lib/sprockets/path_utils.rb:209:in `stat_directory'
/home/mkrul/.rvm/gems/ruby-2.6.0/gems/sprockets-3.7.2/lib/sprockets/path_utils.rb:227:in `stat_tree'
/home/mkrul/.rvm/gems/ruby-2.6.0/gems/sprockets-3.7.2/lib/sprockets/legacy.rb:105:in `each'
/home/mkrul/.rvm/gems/ruby-2.6.0/gems/sprockets-3.7.2/lib/sprockets/legacy.rb:105:in `block in logical_paths'
/home/mkrul/.rvm/gems/ruby-2.6.0/gems/sprockets-3.7.2/lib/sprockets/legacy.rb:104:in `each'
/home/mkrul/.rvm/gems/ruby-2.6.0/gems/sprockets-3.7.2/lib/sprockets/legacy.rb:104:in `logical_paths'
/home/mkrul/.rvm/gems/ruby-2.6.0/gems/sprockets-3.7.2/lib/sprockets/manifest.rb:140:in `find'
/home/mkrul/.rvm/gems/ruby-2.6.0/gems/sprockets-3.7.2/lib/sprockets/manifest.rb:186:in `compile'
/home/mkrul/.rvm/gems/ruby-2.6.0/gems/sprockets-rails-3.2.1/lib/sprockets/rails/task.rb:68:in `block (3 levels) in define'
/home/mkrul/.rvm/gems/ruby-2.6.0/gems/sprockets-3.7.2/lib/rake/sprocketstask.rb:147:in `with_logger'
/home/mkrul/.rvm/gems/ruby-2.6.0/gems/sprockets-rails-3.2.1/lib/sprockets/rails/task.rb:67:in `block (2 levels) in define'
/home/mkrul/.rvm/gems/ruby-2.6.0/gems/railties-5.2.3/lib/rails/commands/rake/rake_command.rb:23:in `block in perform'
/home/mkrul/.rvm/gems/ruby-2.6.0/gems/railties-5.2.3/lib/rails/commands/rake/rake_command.rb:20:in `perform'
/home/mkrul/.rvm/gems/ruby-2.6.0/gems/railties-5.2.3/lib/rails/command.rb:48:in `invoke'
/home/mkrul/.rvm/gems/ruby-2.6.0/gems/railties-5.2.3/lib/rails/commands.rb:18:in `<main>'
/home/mkrul/.rvm/gems/ruby-2.6.0/gems/bootsnap-1.4.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require'
/home/mkrul/.rvm/gems/ruby-2.6.0/gems/bootsnap-1.4.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `block in require_with_bootsnap_lfi'
/home/mkrul/.rvm/gems/ruby-2.6.0/gems/bootsnap-1.4.2/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
/home/mkrul/.rvm/gems/ruby-2.6.0/gems/bootsnap-1.4.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require_with_bootsnap_lfi'
/home/mkrul/.rvm/gems/ruby-2.6.0/gems/bootsnap-1.4.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
/home/mkrul/.rvm/gems/ruby-2.6.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `block in require'
/home/mkrul/.rvm/gems/ruby-2.6.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:257:in `load_dependency'
/home/mkrul/.rvm/gems/ruby-2.6.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `require'
/home/mkrul/Desktop/projects/cloned_factory_ops/factory-ops/bin/rails:9:in `<top (required)>'
/home/mkrul/.rvm/gems/ruby-2.6.0/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `load'
/home/mkrul/.rvm/gems/ruby-2.6.0/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `call'
/home/mkrul/.rvm/gems/ruby-2.6.0/gems/spring-2.0.2/lib/spring/client/command.rb:7:in `call'
/home/mkrul/.rvm/gems/ruby-2.6.0/gems/spring-2.0.2/lib/spring/client.rb:30:in `run'
/home/mkrul/.rvm/gems/ruby-2.6.0/gems/spring-2.0.2/bin/spring:49:in `<top (required)>'
/home/mkrul/.rvm/gems/ruby-2.6.0/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `load'
/home/mkrul/.rvm/gems/ruby-2.6.0/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `<top (required)>'
/home/mkrul/Desktop/projects/cloned_factory_ops/factory-ops/bin/spring:15:in `<top (required)>'
bin/rails:3:in `load'
bin/rails:3:in `<main>'
Tasks: TOP => assets:precompile
(See full trace by running task with --trace)
mkrul@mkrul-ThinkPad-T440s:~/Desktop/projects/cloned_factory_ops/factory-ops$ 
mkrul@mkrul-ThinkPad-T440s:~/Desktop/projects/cloned_factory_ops/factory-ops$ RAILS_ENV=production bin/rails assets:precompileRAILS_ENV=production bin/rails assets:precompile
rails aborted!
Don't know how to build task 'assets:precompileRAILS_ENV=production' (See the list of available tasks with `rake --tasks`)
/home/mkrul/.rvm/gems/ruby-2.6.0/gems/railties-5.2.3/lib/rails/commands/rake/rake_command.rb:23:in `block in perform'
/home/mkrul/.rvm/gems/ruby-2.6.0/gems/railties-5.2.3/lib/rails/commands/rake/rake_command.rb:20:in `perform'
/home/mkrul/.rvm/gems/ruby-2.6.0/gems/railties-5.2.3/lib/rails/command.rb:48:in `invoke'
/home/mkrul/.rvm/gems/ruby-2.6.0/gems/railties-5.2.3/lib/rails/commands.rb:18:in `<main>'
/home/mkrul/.rvm/gems/ruby-2.6.0/gems/bootsnap-1.4.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require'
/home/mkrul/.rvm/gems/ruby-2.6.0/gems/bootsnap-1.4.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `block in require_with_bootsnap_lfi'
/home/mkrul/.rvm/gems/ruby-2.6.0/gems/bootsnap-1.4.2/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
/home/mkrul/.rvm/gems/ruby-2.6.0/gems/bootsnap-1.4.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require_with_bootsnap_lfi'
/home/mkrul/.rvm/gems/ruby-2.6.0/gems/bootsnap-1.4.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
/home/mkrul/.rvm/gems/ruby-2.6.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `block in require'
/home/mkrul/.rvm/gems/ruby-2.6.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:257:in `load_dependency'
/home/mkrul/.rvm/gems/ruby-2.6.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `require'
/home/mkrul/Desktop/projects/cloned_factory_ops/factory-ops/bin/rails:9:in `<top (required)>'
/home/mkrul/.rvm/gems/ruby-2.6.0/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `load'
/home/mkrul/.rvm/gems/ruby-2.6.0/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `call'
/home/mkrul/.rvm/gems/ruby-2.6.0/gems/spring-2.0.2/lib/spring/client/command.rb:7:in `call'
/home/mkrul/.rvm/gems/ruby-2.6.0/gems/spring-2.0.2/lib/spring/client.rb:30:in `run'
/home/mkrul/.rvm/gems/ruby-2.6.0/gems/spring-2.0.2/bin/spring:49:in `<top (required)>'
/home/mkrul/.rvm/gems/ruby-2.6.0/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `load'
/home/mkrul/.rvm/gems/ruby-2.6.0/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `<top (required)>'
/home/mkrul/Desktop/projects/cloned_factory_ops/factory-ops/bin/spring:15:in `<top (required)>'
bin/rails:3:in `load'
bin/rails:3:in `<main>'
(See full trace by running task with --trace)

2 个答案:

答案 0 :(得分:1)

可能有两个不同的原因。

首先,由于Heroku警告您...使用sassc而不是sass-rails ...因此用gem sass-rails替换gemfile中的gem 'sassc-rails'

第二,尝试将以下内容添加到您的config/environments/production.rb文件中(它将替换config.assets.js_compressor = :uglifier。.

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

答案 1 :(得分:1)

您如何让Heroku返回Don't know how to build task 'assets:precompileRAILS_ENV=production' (See the list of available tasks with rake --tasks)

通常,此命令:bundle exec rake assets:precompile RAILS_ENV=production将在控制台中本地完成。它允许您在本地编译资产。

此外,通过在本地执行操作,您可能会获得一些有关无法预编译的文件的信息。然后尝试调试此文件。它是JavaScript或CSS文件。

一些可能的错误:

  • Js文件(包括ES6 =>),则必须按照以下说明使用Harmony 标记
  • 某些动态内容(如果您具有css.erb或js.erb文件)

  • JS文件中有一些错字(CSS错字始终会发出警告)

  • ..