Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

assets:precompile not working with Ruby 3 #12

Closed
Karoid opened this issue Oct 21, 2021 · 2 comments
Closed

assets:precompile not working with Ruby 3 #12

Karoid opened this issue Oct 21, 2021 · 2 comments

Comments

@Karoid
Copy link

Karoid commented Oct 21, 2021

When I run 'rails assets:precompile', I receive the following error:

rails assets:precompile --trace
** Invoke assets:precompile (first_time)
** Invoke assets:environment (first_time)
** Execute assets:environment
** Invoke environment (first_time)
** Execute environment
** Invoke yarn:install (first_time)
** Execute yarn:install
yarn install v1.22.15
info No lockfile found.
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
Done in 0.06s.
** Execute assets:precompile
rails aborted!
NoMethodError: undefined method `length' for nil:NilClass
/usr/local/bundle/gems/image_size-3.0.0/lib/image_size/seekable_io_reader.rb:21:in `chunk'
/usr/local/bundle/gems/image_size-3.0.0/lib/image_size/chunky_reader.rb:25:in `[]'
/usr/local/bundle/gems/image_size-3.0.0/lib/image_size.rb:164:in `block in size_of_jpeg'
/usr/local/bundle/gems/image_size-3.0.0/lib/image_size.rb:163:in `loop'
/usr/local/bundle/gems/image_size-3.0.0/lib/image_size.rb:163:in `size_of_jpeg'
/usr/local/bundle/gems/image_size-3.0.0/lib/image_size.rb:52:in `block in initialize'
/usr/local/bundle/gems/image_size-3.0.0/lib/image_size/reader.rb:18:in `block in open'
/usr/local/bundle/gems/image_size-3.0.0/lib/image_size/reader.rb:18:in `open'
/usr/local/bundle/gems/image_size-3.0.0/lib/image_size/reader.rb:18:in `open'
/usr/local/bundle/gems/image_size-3.0.0/lib/image_size/reader.rb:18:in `open'
/usr/local/bundle/gems/image_size-3.0.0/lib/image_size.rb:50:in `initialize'
/usr/local/bundle/gems/image_size-3.0.0/lib/image_size.rb:35:in `new'
/usr/local/bundle/gems/image_size-3.0.0/lib/image_size.rb:35:in `path'
/usr/local/bundle/gems/image_optim-0.31.1/lib/image_optim/image_meta.rb:9:in `format_for_path'
/usr/local/bundle/gems/image_optim-0.31.1/lib/image_optim/path.rb:68:in `image_format'
/usr/local/bundle/gems/image_optim-0.31.1/lib/image_optim.rb:109:in `workers_for_image'
/usr/local/bundle/gems/image_optim-0.31.1/lib/image_optim.rb:116:in `optimize_image'
/usr/local/bundle/gems/image_optim-0.31.1/lib/image_optim.rb:159:in `block in optimize_image_data'
/usr/local/bundle/gems/fspath-3.1.2/lib/fspath.rb:34:in `open'
/usr/local/bundle/gems/fspath-3.1.2/lib/fspath.rb:64:in `temp_file'
/usr/local/bundle/gems/image_optim-0.31.1/lib/image_optim.rb:154:in `optimize_image_data'
/usr/local/bundle/gems/image_optim_rails-0.4.3/lib/image_optim/railtie.rb:66:in `optimize_image_data'
/usr/local/bundle/gems/image_optim_rails-0.4.3/lib/image_optim/railtie.rb:38:in `block (2 levels) in <class:Railtie>'
/usr/local/bundle/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:84:in `call_processor'
/usr/local/bundle/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:66:in `block in call_processors'
/usr/local/bundle/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:65:in `reverse_each'
/usr/local/bundle/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:65:in `call_processors'
/usr/local/bundle/gems/sprockets-4.0.2/lib/sprockets/loader.rb:182:in `load_from_unloaded'
/usr/local/bundle/gems/sprockets-4.0.2/lib/sprockets/loader.rb:59:in `block in load'
/usr/local/bundle/gems/sprockets-4.0.2/lib/sprockets/loader.rb:337:in `fetch_asset_from_dependency_cache'
/usr/local/bundle/gems/sprockets-4.0.2/lib/sprockets/loader.rb:43:in `load'
/usr/local/bundle/gems/sprockets-4.0.2/lib/sprockets/cached_environment.rb:44:in `load'
/usr/local/bundle/gems/sprockets-4.0.2/lib/sprockets/bundle.rb:32:in `block in call'
/usr/local/lib/ruby/3.0.0/set.rb:344:in `each_key'
/usr/local/lib/ruby/3.0.0/set.rb:344:in `each'
/usr/local/bundle/gems/sprockets-4.0.2/lib/sprockets/bundle.rb:31:in `call'
/usr/local/bundle/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:84:in `call_processor'
/usr/local/bundle/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:66:in `block in call_processors'
/usr/local/bundle/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:65:in `reverse_each'
/usr/local/bundle/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:65:in `call_processors'
/usr/local/bundle/gems/sprockets-4.0.2/lib/sprockets/loader.rb:182:in `load_from_unloaded'
/usr/local/bundle/gems/sprockets-4.0.2/lib/sprockets/loader.rb:59:in `block in load'
/usr/local/bundle/gems/sprockets-4.0.2/lib/sprockets/loader.rb:337:in `fetch_asset_from_dependency_cache'
/usr/local/bundle/gems/sprockets-4.0.2/lib/sprockets/loader.rb:43:in `load'
/usr/local/bundle/gems/sprockets-4.0.2/lib/sprockets/cached_environment.rb:44:in `load'
/usr/local/bundle/gems/sprockets-4.0.2/lib/sprockets/base.rb:81:in `find_asset'
/usr/local/bundle/gems/sprockets-4.0.2/lib/sprockets/base.rb:88:in `find_all_linked_assets'
/usr/local/bundle/gems/sprockets-4.0.2/lib/sprockets/manifest.rb:125:in `block (2 levels) in find'
/usr/local/bundle/gems/concurrent-ruby-1.1.9/lib/concurrent-ruby/concurrent/executor/safe_task_executor.rb:24:in `block in execute'
/usr/local/bundle/gems/concurrent-ruby-1.1.9/lib/concurrent-ruby/concurrent/synchronization/mutex_lockable_object.rb:47:in `block in synchronize'
/usr/local/bundle/gems/concurrent-ruby-1.1.9/lib/concurrent-ruby/concurrent/synchronization/mutex_lockable_object.rb:47:in `synchronize'
/usr/local/bundle/gems/concurrent-ruby-1.1.9/lib/concurrent-ruby/concurrent/synchronization/mutex_lockable_object.rb:47:in `synchronize'
/usr/local/bundle/gems/concurrent-ruby-1.1.9/lib/concurrent-ruby/concurrent/executor/safe_task_executor.rb:19:in `execute'
/usr/local/bundle/gems/concurrent-ruby-1.1.9/lib/concurrent-ruby/concurrent/promise.rb:564:in `block in realize'
/usr/local/bundle/gems/concurrent-ruby-1.1.9/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:363:in `run_task'
/usr/local/bundle/gems/concurrent-ruby-1.1.9/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:352:in `block (3 levels) in create_worker'
/usr/local/bundle/gems/concurrent-ruby-1.1.9/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:335:in `loop'
/usr/local/bundle/gems/concurrent-ruby-1.1.9/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:335:in `block (2 levels) in create_worker'
/usr/local/bundle/gems/concurrent-ruby-1.1.9/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:334:in `catch'
/usr/local/bundle/gems/concurrent-ruby-1.1.9/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:334:in `block in create_worker'

When I tested precompile without this gem, there was no problem

[Environment Details]
docker image: ruby:3.0.2-buster
Rails 6.1.4.1
sprockets 4

@toy
Copy link
Owner

toy commented Oct 21, 2021

Thank you for reporting!
The problem is in new version of image_size gem that I released few days ago, I'll have a look.

@toy
Copy link
Owner

toy commented Oct 21, 2021

Please update image_size (to 3.0.1), that should fix the problem. And please reopen the issue if not.

netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this issue Nov 23, 2021
3.0.1 (2021-10-21)

* Fix reading file chunks starting after EOF and reading chunks
  non-consecutively toy/image_optim_rails#12 @toy

3.0.0 (2021-10-17)

* Read only required chunks of data for files and seekable IOs @toy
* Raise FormatError whenever reading data returns less data than expected
  #12 @toy
* Add w/width and h/height accessors to Size @toy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants