本文介绍了Heroku推送错误:“NameError:未初始化的常量Uglifier :: VERSION”在rake资产上:预编译的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试推向生产时,我收到以下错误消息。这是推送的结果:

  $ git push production master 
计数对象:124,完成。
使用多达4个线程的增量压缩。
压缩对象:100%(118/118),完成。
写作对象:100%(124/124),19.73 KiB | 0字节/秒,完成。
总计124(增量66),重用1(增量0)
远程:压缩源文件...完成。
remote:建筑来源:
remote:
remote:-----> Ruby应用检测到
remote:----->编译Ruby / Rails
remote:----->使用Ruby版本:ruby-2.2.2
remote:----->使用1.9.7安装依赖项$ b $ remote:检测到Ruby版本更改。清除捆绑器缓存。
remote:old:ruby 2.0.0p645(2015-04-13 revision 50299)[x86_64-linux]
remote:New:ruby 2.2.2p95(2015-04-13 revision 50295)[x86_64- linux]
remote:运行:bundle install - 无需开发:test --path vendor / bundle --binstubs vendor / bundle / bin -j4 --deployment
remote:获取gem元数据...< ;省略>
remote:正在安装...<忽略>
remote:捆绑完成! 33 Gemfile依赖项,现在安装了70个宝石。
remote:群组开发和测试中的宝石没有安装。
remote:捆绑的gems被安装到./vendor/bundle中。

...< misc发布安装通知被省略> ...

remote:捆绑已完成(93.05s)
远程:清理捆绑缓存。
remote:----->为Rails资产管道准备应用程序
remote:运行:rake资产:预编译
remote:rake中止!
remote:NameError:未初始化的常量Uglifier :: VERSION
remote:/tmp/build_1185918c8fd4fbf904b3d7c2f09505d5/vendor/bundle/ruby/2.2.0/gems/sprockets-3.1.0/lib/sprockets/uglifier_compressor.rb :48:在`initialize'
remote:/tmp/build_1185918c8fd4fbf904b3d7c2f09505d5/vendor/bundle/ruby/2.2.0/gems/sprockets-3.1.0/lib/sprockets/uglifier_compressor.rb:24:in`new'
remote:/tmp/build_1185918c8fd4fbf904b3d7c2f09505d5/vendor/bundle/ruby/2.2.0/gems/sprockets-3.1.0/lib/sprockets/uglifier_compressor.rb:24:in`instance'
remote:/ bmp tmp / build_1185918c8fd4fbf904b3d7c2f09505d5 / vendor / bundle / ruby​​ / 2.2.0 / gems / sprockets-3.1.0 / lib / sprockets / uglifier_compressor.rb:28:in`call'
remote:/ tmp / build_1185918c8fd4fbf904b3d7c2f09505d5 / vendor / bundle /ruby/2.2.0/gems/sprockets-3.1.0/lib/sprockets/processor_utils.rb:75:in`call_processor'
remote:/tmp/build_1185918c8fd4fbf904b3d7c2f09505d5/vendor/bundle/ruby/2.2.0/宝石/链轮-3.1.0 / lib / sprockets / processor_utils.rb:57:在`block in call_processors'
remote:/tmp/build_1185918c8fd4fbf904b3d7c2f09505d5/vendor/bundle/ruby/2.2.0/gems/sprockets-3.1.0/ lib / sprockets / processor_utils.rb:56:在`reverse_each'
remote:/tmp/build_1185918c8fd4fbf904b3d7c2f09505d5/vendor/bundle/ruby/2.2.0/gems/sprockets-3.1.0/lib/sprockets/processor_utils.rb :56:`call_processors'
remote:/tmp/build_1185918c8fd4fbf904b3d7c2f09505d5/vendor/bundle/ruby/2.2.0/gems/sprockets-3.1.0/lib/sprockets/loader.rb:86:in`load_asset_by_uri'
remote:/tmp/build_1185918c8fd4fbf904b3d7c2f09505d5/vendor/bundle/ruby/2.2.0/gems/sprockets-3.1.0/lib/sprockets/loader.rb:45:in`block in load'
remote :/tmp/build_1185918c8fd4fbf904b3d7c2f09505d5/vendor/bundle/ruby/2.2.0/gems/sprockets-3.1.0/lib/sprockets/loader.rb:156:in`fetch_asset_from_dependency_cache'
remote:/ tmp / build_1185918c8fd4fbf904b3d7c2f09505d5 / vendor /bundle/ruby/2.2.0/ge ms / sprockets-3.1.0 / lib / sprockets / loader.rb:38:in`load'
remote:/tmp/build_1185918c8fd4fbf904b3d7c2f09505d5/vendor/bundle/ruby/2.2.0/gems/sprockets-3.1.0 /lib/sprockets/cached_environment.rb:20:in`block in initialize'
remote:/tmp/build_1185918c8fd4fbf904b3d7c2f09505d5/vendor/bundle/ruby/2.2.0/gems/sprockets-3.1.0/lib/sprockets/ cached_environment.rb:47:在'yield'中
remote:/tmp/build_1185918c8fd4fbf904b3d7c2f09505d5/vendor/bundle/ruby/2.2.0/gems/sprockets-3.1.0/lib/sprockets/cached_environment.rb:47:in `load'
remote:/tmp/build_1185918c8fd4fbf904b3d7c2f09505d5/vendor/bundle/ruby/2.2.0/gems/sprockets-3.1.0/lib/sprockets/base.rb:63:in`find_asset'
远程:/tmp/build_1185918c8fd4fbf904b3d7c2f09505d5/vendor/bundle/ruby/2.2.0/gems/sprockets-3.1.0/lib/sprockets/base.rb:70:in`find_all_linked_assets'
remote:/ tmp / build_1185918c8fd4fbf904b3d7c2f09505d5 /供应商/束/红宝石/ 2.2.0 /宝石/链轮-3.1.0 / LIB /链轮/米anifest.rb:138:在`block in find'
remote:/tmp/build_1185918c8fd4fbf904b3d7c2f09505d5/vendor/bundle/ruby/2.2.0/gems/sprockets-3.1.0/lib/sprockets/legacy.rb:114 :在逻辑路径中的块(2级)'
remote:/tmp/build_1185918c8fd4fbf904b3d7c2f09505d5/vendor/bundle/ruby/2.2.0/gems/sprockets-3.1.0/lib/sprockets/path_utils.rb:223:在`block in stat_tree'
remote:/tmp/build_1185918c8fd4fbf904b3d7c2f09505d5/vendor/bundle/ruby/2.2.0/gems/sprockets-3.1.0/lib/sprockets/path_utils.rb:207:in`block in stat_directory '
remote:/tmp/build_1185918c8fd4fbf904b3d7c2f09505d5/vendor/bundle/ruby/2.2.0/gems/sprockets-3.1.0/lib/sprockets/path_utils.rb:204:in`each'
remote: /tmp/build_1185918c8fd4fbf904b3d7c2f09505d5/vendor/bundle/ruby/2.2.0/gems/sprockets-3.1.0/lib/sprockets/path_utils.rb:204:in`stat_directory'
remote:/ tmp / build_1185918c8fd4fbf904b3d7c2f09505d5 / vendor /束/红宝石/ 2.2.0 /宝石/链轮-3.1.0 / LIB /链轮/ PA th_utils.rb:222:在`stat_tree'
remote:/tmp/build_1185918c8fd4fbf904b3d7c2f09505d5/vendor/bundle/ruby/2.2.0/gems/sprockets-3.1.0/lib/sprockets/legacy.rb:105:in `each'
remote:/tmp/build_1185918c8fd4fbf904b3d7c2f09505d5/vendor/bundle/ruby/2.2.0/gems/sprockets-3.1.0/lib/sprockets/legacy.rb:105:in`block in logical_paths'
remote:/tmp/build_1185918c8fd4fbf904b3d7c2f09505d5/vendor/bundle/ruby/2.2.0/gems/sprockets-3.1.0/lib/sprockets/legacy.rb:104:in`each'
remote:/ tmp / build_1185918c8fd4fbf904b3d7c2f09505d5 / vendor / bundle / ruby​​ / 2.2.0 / gems / sprockets-3.1.0 / lib / sprockets / legacy.rb:104:在`logical_paths'
remote:/ tmp / build_1185918c8fd4fbf904b3d7c2f09505d5 / vendor / bundle / ruby /2.2.0/gems/sprockets-3.1.0/lib/sprockets/manifest.rb:136:in`find'
remote:/tmp/build_1185918c8fd4fbf904b3d7c2f09505d5/vendor/bundle/ruby/2.2.0/gems/ sprockets-3.1.0 / lib / sprockets / manifest.rb:162:在`compile'
remote:/ tmp / build_11 85918c8fd4fbf904b3d7c2f09505d5 / vendor / bundle / ruby​​ / 2.2.0 / gems / sprockets-rails-2.3.1 / lib / sprockets / rails / task.rb:70:在'block(3 levels)in define'
remote: /tmp/build_1185918c8fd4fbf904b3d7c2f09505d5/vendor/bundle/ruby/2.2.0/gems/sprockets-3.1.0/lib/rake/sprocketstask.rb:147:in`with_logger'
remote:/ tmp / build_1185918c8fd4fbf904b3d7c2f09505d5 / vendor / bundle / ruby​​ / 2.2.0 / gems / sprockets-rails-2.3.1 / lib / sprockets / rails / task.rb:69:在'block(2 levels)in define'
remote:Tasks:TOP = >资产:预编译
remote:(通过使用--trace运行任务查看完整跟踪)
remote:!
remote:!预编译资产失败。
remote:!
remote:
remote:!推送被拒绝,未能编译Ruby应用程序


解决方案

是Sprockets 3.1和我使用的Uglifier压缩版本2.1之间的不兼容性。通过将此行放入我的Gemfile中升级Uglifier解决了问题:

  gem'uglifier','〜> 2.7'


I'm receiving the following error when trying to push to production. Here's the result of the push:

$ git push production master
Counting objects: 124, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (118/118), done.
Writing objects: 100% (124/124), 19.73 KiB | 0 bytes/s, done.
Total 124 (delta 66), reused 1 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Ruby app detected
remote: -----> Compiling Ruby/Rails
remote: -----> Using Ruby version: ruby-2.2.2
remote: -----> Installing dependencies using 1.9.7
remote:        Ruby version change detected. Clearing bundler cache.
remote:        Old: ruby 2.0.0p645 (2015-04-13 revision 50299) [x86_64-linux]
remote:        New: ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-linux]
remote:        Running: bundle install --without development:test --path                       vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment
remote:        Fetching gem metadata... <omitted>
remote:        Installing... <omitted>
remote:        Bundle complete! 33 Gemfile dependencies, 70 gems now installed.
remote:        Gems in the groups development and test were not installed.
remote:        Bundled gems are installed into ./vendor/bundle.

    ...<misc post install notifications omitted>...

remote:        Bundle completed (93.05s)
remote:        Cleaning up the bundler cache.
remote: -----> Preparing app for Rails asset pipeline
remote:        Running: rake assets:precompile
remote:        rake aborted!
remote:        NameError: uninitialized constant Uglifier::VERSION
remote:        /tmp/build_1185918c8fd4fbf904b3d7c2f09505d5/vendor/bundle/ruby/2.2.0/gems/sprockets-3.1.0/lib/sprockets/uglifier_compressor.rb:48:in `initialize'
remote:        /tmp/build_1185918c8fd4fbf904b3d7c2f09505d5/vendor/bundle/ruby/2.2.0/gems/sprockets-3.1.0/lib/sprockets/uglifier_compressor.rb:24:in `new'
remote:        /tmp/build_1185918c8fd4fbf904b3d7c2f09505d5/vendor/bundle/ruby/2.2.0/gems/sprockets-3.1.0/lib/sprockets/uglifier_compressor.rb:24:in `instance'
remote:        /tmp/build_1185918c8fd4fbf904b3d7c2f09505d5/vendor/bundle/ruby/2.2.0/gems/sprockets-3.1.0/lib/sprockets/uglifier_compressor.rb:28:in `call'
remote:        /tmp/build_1185918c8fd4fbf904b3d7c2f09505d5/vendor/bundle/ruby/2.2.0/gems/sprockets-3.1.0/lib/sprockets/processor_utils.rb:75:in `call_processor'
remote:        /tmp/build_1185918c8fd4fbf904b3d7c2f09505d5/vendor/bundle/ruby/2.2.0/gems/sprockets-3.1.0/lib/sprockets/processor_utils.rb:57:in `block in call_processors'
remote:        /tmp/build_1185918c8fd4fbf904b3d7c2f09505d5/vendor/bundle/ruby/2.2.0/gems/sprockets-3.1.0/lib/sprockets/processor_utils.rb:56:in `reverse_each'
remote:        /tmp/build_1185918c8fd4fbf904b3d7c2f09505d5/vendor/bundle/ruby/2.2.0/gems/sprockets-3.1.0/lib/sprockets/processor_utils.rb:56:in `call_processors'
remote:        /tmp/build_1185918c8fd4fbf904b3d7c2f09505d5/vendor/bundle/ruby/2.2.0/gems/sprockets-3.1.0/lib/sprockets/loader.rb:86:in `load_asset_by_uri'
remote:        /tmp/build_1185918c8fd4fbf904b3d7c2f09505d5/vendor/bundle/ruby/2.2.0/gems/sprockets-3.1.0/lib/sprockets/loader.rb:45:in `block in load'
remote:        /tmp/build_1185918c8fd4fbf904b3d7c2f09505d5/vendor/bundle/ruby/2.2.0/gems/sprockets-3.1.0/lib/sprockets/loader.rb:156:in `fetch_asset_from_dependency_cache'
remote:        /tmp/build_1185918c8fd4fbf904b3d7c2f09505d5/vendor/bundle/ruby/2.2.0/gems/sprockets-3.1.0/lib/sprockets/loader.rb:38:in `load'
remote:        /tmp/build_1185918c8fd4fbf904b3d7c2f09505d5/vendor/bundle/ruby/2.2.0/gems/sprockets-3.1.0/lib/sprockets/cached_environment.rb:20:in `block in initialize'
remote:        /tmp/build_1185918c8fd4fbf904b3d7c2f09505d5/vendor/bundle/ruby/2.2.0/gems/sprockets-3.1.0/lib/sprockets/cached_environment.rb:47:in `yield'
remote:        /tmp/build_1185918c8fd4fbf904b3d7c2f09505d5/vendor/bundle/ruby/2.2.0/gems/sprockets-3.1.0/lib/sprockets/cached_environment.rb:47:in `load'
remote:        /tmp/build_1185918c8fd4fbf904b3d7c2f09505d5/vendor/bundle/ruby/2.2.0/gems/sprockets-3.1.0/lib/sprockets/base.rb:63:in `find_asset'
remote:        /tmp/build_1185918c8fd4fbf904b3d7c2f09505d5/vendor/bundle/ruby/2.2.0/gems/sprockets-3.1.0/lib/sprockets/base.rb:70:in `find_all_linked_assets'
remote:        /tmp/build_1185918c8fd4fbf904b3d7c2f09505d5/vendor/bundle/ruby/2.2.0/gems/sprockets-3.1.0/lib/sprockets/manifest.rb:138:in `block in find'
remote:        /tmp/build_1185918c8fd4fbf904b3d7c2f09505d5/vendor/bundle/ruby/2.2.0/gems/sprockets-3.1.0/lib/sprockets/legacy.rb:114:in `block (2 levels) in logical_paths'
remote:        /tmp/build_1185918c8fd4fbf904b3d7c2f09505d5/vendor/bundle/ruby/2.2.0/gems/sprockets-3.1.0/lib/sprockets/path_utils.rb:223:in `block in stat_tree'
remote:        /tmp/build_1185918c8fd4fbf904b3d7c2f09505d5/vendor/bundle/ruby/2.2.0/gems/sprockets-3.1.0/lib/sprockets/path_utils.rb:207:in `block in stat_directory'
remote:        /tmp/build_1185918c8fd4fbf904b3d7c2f09505d5/vendor/bundle/ruby/2.2.0/gems/sprockets-3.1.0/lib/sprockets/path_utils.rb:204:in `each'
remote:        /tmp/build_1185918c8fd4fbf904b3d7c2f09505d5/vendor/bundle/ruby/2.2.0/gems/sprockets-3.1.0/lib/sprockets/path_utils.rb:204:in `stat_directory'
remote:        /tmp/build_1185918c8fd4fbf904b3d7c2f09505d5/vendor/bundle/ruby/2.2.0/gems/sprockets-3.1.0/lib/sprockets/path_utils.rb:222:in `stat_tree'
remote:        /tmp/build_1185918c8fd4fbf904b3d7c2f09505d5/vendor/bundle/ruby/2.2.0/gems/sprockets-3.1.0/lib/sprockets/legacy.rb:105:in `each'
remote:        /tmp/build_1185918c8fd4fbf904b3d7c2f09505d5/vendor/bundle/ruby/2.2.0/gems/sprockets-3.1.0/lib/sprockets/legacy.rb:105:in `block in logical_paths'
remote:        /tmp/build_1185918c8fd4fbf904b3d7c2f09505d5/vendor/bundle/ruby/2.2.0/gems/sprockets-3.1.0/lib/sprockets/legacy.rb:104:in `each'
remote:        /tmp/build_1185918c8fd4fbf904b3d7c2f09505d5/vendor/bundle/ruby/2.2.0/gems/sprockets-3.1.0/lib/sprockets/legacy.rb:104:in `logical_paths'
remote:        /tmp/build_1185918c8fd4fbf904b3d7c2f09505d5/vendor/bundle/ruby/2.2.0/gems/sprockets-3.1.0/lib/sprockets/manifest.rb:136:in `find'
remote:        /tmp/build_1185918c8fd4fbf904b3d7c2f09505d5/vendor/bundle/ruby/2.2.0/gems/sprockets-3.1.0/lib/sprockets/manifest.rb:162:in `compile'
remote:        /tmp/build_1185918c8fd4fbf904b3d7c2f09505d5/vendor/bundle/ruby/2.2.0/gems/sprockets-rails-2.3.1/lib/sprockets/rails/task.rb:70:in `block (3 levels) in define'
remote:        /tmp/build_1185918c8fd4fbf904b3d7c2f09505d5/vendor/bundle/ruby/2.2.0/gems/sprockets-3.1.0/lib/rake/sprocketstask.rb:147:in `with_logger'
remote:        /tmp/build_1185918c8fd4fbf904b3d7c2f09505d5/vendor/bundle/ruby/2.2.0/gems/sprockets-rails-2.3.1/lib/sprockets/rails/task.rb:69:in `block (2 levels) in define'
remote:        Tasks: TOP => assets:precompile
remote:        (See full trace by running task with --trace)
remote:  !
remote:  !     Precompiling assets failed.
remote:  !
remote:
remote:  !     Push rejected, failed to compile Ruby app
解决方案

The problem seemed to be an incompatibility between Sprockets 3.1 and the Uglifier compressor version I was using, 2.1. Upgrading Uglifier by putting this line in my Gemfile resolved the issue:

gem 'uglifier', '~> 2.7'

这篇关于Heroku推送错误:“NameError:未初始化的常量Uglifier :: VERSION”在rake资产上:预编译的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-06 06:49