question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Uglifier::Error: - Solution: Switch to terser

See original GitHub issue

Hi there,

I am using:

  • Ruby 3.1.2p20
  • Rails 7.0.3
  • Uglifier 4.2.0

In a previous version of Rails/Ruby (Rails 6 on Ruby 3.0), it was working correctly. However now I just see this:

$ RAILS_ENV=production bundle exec rails assets:precompile
autoprefixer: /Users/hackeron/Development/Tether/timeline/app/assets/stylesheets/application_dark_theme.scss:26033:3: Replace color-adjust to print-color-adjust. The color-adjust shorthand is currently deprecated.
rails aborted!
Uglifier::Error:

Tasks: TOP => assets:precompile
(See full trace by running task with --trace)

When I run with trace, I see this:

$ RAILS_ENV=production bundle exec rails assets:precompile --trace
** Invoke assets:precompile (first_time)
** Invoke assets:environment (first_time)
** Execute assets:environment
** Invoke environment (first_time)
** Execute environment
** Execute assets:precompile
autoprefixer: /Users/hackeron/Development/Tether/timeline/app/assets/stylesheets/application_dark_theme.scss:26033:3: Replace color-adjust to print-color-adjust. The color-adjust shorthand is currently deprecated.
rails aborted!
Uglifier::Error:
/usr/local/lib/ruby/gems/3.1.0/gems/uglifier-4.2.0/lib/uglifier.rb:291:in `parse_result'
/usr/local/lib/ruby/gems/3.1.0/gems/uglifier-4.2.0/lib/uglifier.rb:221:in `run_uglifyjs'
/usr/local/lib/ruby/gems/3.1.0/gems/uglifier-4.2.0/lib/uglifier.rb:166:in `compile'
/usr/local/lib/ruby/gems/3.1.0/gems/sprockets-4.0.3/lib/sprockets/compressing.rb:84:in `block in js_compressor='
/usr/local/lib/ruby/gems/3.1.0/gems/sprockets-4.0.3/lib/sprockets/processor_utils.rb:84:in `call_processor'
/usr/local/lib/ruby/gems/3.1.0/gems/sprockets-4.0.3/lib/sprockets/processor_utils.rb:66:in `block in call_processors'
/usr/local/lib/ruby/gems/3.1.0/gems/sprockets-4.0.3/lib/sprockets/processor_utils.rb:65:in `reverse_each'
/usr/local/lib/ruby/gems/3.1.0/gems/sprockets-4.0.3/lib/sprockets/processor_utils.rb:65:in `call_processors'
/usr/local/lib/ruby/gems/3.1.0/gems/sprockets-4.0.3/lib/sprockets/loader.rb:182:in `load_from_unloaded'
/usr/local/lib/ruby/gems/3.1.0/gems/sprockets-4.0.3/lib/sprockets/loader.rb:59:in `block in load'
/usr/local/lib/ruby/gems/3.1.0/gems/sprockets-4.0.3/lib/sprockets/loader.rb:337:in `fetch_asset_from_dependency_cache'
/usr/local/lib/ruby/gems/3.1.0/gems/sprockets-4.0.3/lib/sprockets/loader.rb:43:in `load'
/usr/local/lib/ruby/gems/3.1.0/gems/sprockets-4.0.3/lib/sprockets/cached_environment.rb:44:in `load'
/usr/local/lib/ruby/gems/3.1.0/gems/sprockets-4.0.3/lib/sprockets/bundle.rb:32:in `block in call'
/usr/local/Cellar/ruby/3.1.2/lib/ruby/3.1.0/set.rb:511:in `each_key'
/usr/local/Cellar/ruby/3.1.2/lib/ruby/3.1.0/set.rb:511:in `each'
/usr/local/lib/ruby/gems/3.1.0/gems/sprockets-4.0.3/lib/sprockets/bundle.rb:31:in `call'
/usr/local/lib/ruby/gems/3.1.0/gems/sprockets-4.0.3/lib/sprockets/processor_utils.rb:84:in `call_processor'
/usr/local/lib/ruby/gems/3.1.0/gems/sprockets-4.0.3/lib/sprockets/processor_utils.rb:66:in `block in call_processors'
/usr/local/lib/ruby/gems/3.1.0/gems/sprockets-4.0.3/lib/sprockets/processor_utils.rb:65:in `reverse_each'
/usr/local/lib/ruby/gems/3.1.0/gems/sprockets-4.0.3/lib/sprockets/processor_utils.rb:65:in `call_processors'
/usr/local/lib/ruby/gems/3.1.0/gems/sprockets-4.0.3/lib/sprockets/loader.rb:182:in `load_from_unloaded'
/usr/local/lib/ruby/gems/3.1.0/gems/sprockets-4.0.3/lib/sprockets/loader.rb:59:in `block in load'
/usr/local/lib/ruby/gems/3.1.0/gems/sprockets-4.0.3/lib/sprockets/loader.rb:337:in `fetch_asset_from_dependency_cache'
/usr/local/lib/ruby/gems/3.1.0/gems/sprockets-4.0.3/lib/sprockets/loader.rb:43:in `load'
/usr/local/lib/ruby/gems/3.1.0/gems/sprockets-4.0.3/lib/sprockets/cached_environment.rb:44:in `load'
/usr/local/lib/ruby/gems/3.1.0/gems/sprockets-4.0.3/lib/sprockets/base.rb:81:in `find_asset'
/usr/local/lib/ruby/gems/3.1.0/gems/sprockets-4.0.3/lib/sprockets/base.rb:88:in `find_all_linked_assets'
/usr/local/lib/ruby/gems/3.1.0/gems/sprockets-4.0.3/lib/sprockets/manifest.rb:125:in `each'
/usr/local/lib/ruby/gems/3.1.0/gems/sprockets-4.0.3/lib/sprockets/manifest.rb:125:in `to_a'
/usr/local/lib/ruby/gems/3.1.0/gems/sprockets-4.0.3/lib/sprockets/manifest.rb:125:in `block (2 levels) in find'
/usr/local/lib/ruby/gems/3.1.0/gems/concurrent-ruby-1.1.10/lib/concurrent-ruby/concurrent/executor/safe_task_executor.rb:24:in `block in execute'
/usr/local/lib/ruby/gems/3.1.0/gems/concurrent-ruby-1.1.10/lib/concurrent-ruby/concurrent/synchronization/mutex_lockable_object.rb:47:in `block in synchronize'
/usr/local/lib/ruby/gems/3.1.0/gems/concurrent-ruby-1.1.10/lib/concurrent-ruby/concurrent/synchronization/mutex_lockable_object.rb:47:in `synchronize'
/usr/local/lib/ruby/gems/3.1.0/gems/concurrent-ruby-1.1.10/lib/concurrent-ruby/concurrent/synchronization/mutex_lockable_object.rb:47:in `synchronize'
/usr/local/lib/ruby/gems/3.1.0/gems/concurrent-ruby-1.1.10/lib/concurrent-ruby/concurrent/executor/safe_task_executor.rb:22:in `execute'
/usr/local/lib/ruby/gems/3.1.0/gems/concurrent-ruby-1.1.10/lib/concurrent-ruby/concurrent/promise.rb:564:in `block in realize'
/usr/local/lib/ruby/gems/3.1.0/gems/concurrent-ruby-1.1.10/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:352:in `run_task'
/usr/local/lib/ruby/gems/3.1.0/gems/concurrent-ruby-1.1.10/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:343:in `block (3 levels) in create_worker'
/usr/local/lib/ruby/gems/3.1.0/gems/concurrent-ruby-1.1.10/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:334:in `loop'
/usr/local/lib/ruby/gems/3.1.0/gems/concurrent-ruby-1.1.10/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:334:in `block (2 levels) in create_worker'
/usr/local/lib/ruby/gems/3.1.0/gems/concurrent-ruby-1.1.10/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:333:in `catch'
/usr/local/lib/ruby/gems/3.1.0/gems/concurrent-ruby-1.1.10/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:333:in `block in create_worker'
Tasks: TOP => assets:precompile

The autoprefixer warning shows up when I disable uglifier too and doesn’t seem to be related to this.

I can’t for the life of me figure out what’s wrong… any ideas how to troubleshoot this or what could be going wrong?

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:14

github_iconTop GitHub Comments

7reactions
puneetpandeycommented, May 26, 2022

Hi @rgaufman, replacing config.assets.js_compressor = Uglifier.new(harmony: true) with the block below:

config.assets.configure do |env|
  env.js_compressor  = :uglifier # or :closure, :yui
  env.css_compressor = :sass   # or :yui
end

worked for me. I have gem "sprockets-rails", :require => 'sprockets/railtie' in my Gemfile.

Need to confirm if this is a valid fix.

3reactions
puneetpandeycommented, May 26, 2022

As per Uglifier’s Readme: UglifyJS only works with ES5. If you need to compress ES6, ruby-terser is a better option. It seems ES6 won’t work well with Uglifier

Read more comments on GitHub >

github_iconTop Results From Across the Web

Rails won't precompile assets due to Uglifier error (Uglifier
Easy solution: switch to "Terser". Here's the ruby wrapper for Terser: https://github.com ...
Read more >
Uglifier error during assets precompile - Discourse Meta
I'm seeing some errors trying to run rake assets:precompile on 2.1.0 (stable branch), which appears to be due to the use of const...
Read more >
Switch to terser gem to replace uglifier - Merge requests - GitLab
An error occurred while retrieving approval data for this merge request. Switch to terser gem to replace uglifier.
Read more >
When use js_compressor compile stimulus controller
I knew this should be a Uglifier issue, but all Uglifier solution is ... I already did it, event tried terser , still...
Read more >
terser-webpack-plugin | Yarn - Package Manager
All notable changes to this project will be documented in this file. See standard-version for commit guidelines. 5.3.6 (2022-08-29). Bug Fixes. allow disable ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found