Rails 7 ActiveStorage文件预览.rails应用程序正在崩溃



我正在尝试预览rails 7项目中的pdf文件,如下所示:

我正在使用poppler&rails默认活动存储。我可以存储文件,链接下载,但不能在网页上预览。

<%= image_tag @user.pdf_doc.preview(resize_to_fit: [100, 100]) %>在docker容器中运行应用程序时:

一旦我进入视图,就会显示一个空的图像缩略图,而没有真正显示文件刷新页面后,rails应用程序崩溃,并显示以下错误日志:

rails7-on-docker-web-1    | #<Thread:0x0000ffff7acc2318 /usr/local/bundle/gems/actionpack-7.0.2.2/lib/action_controller/metal/live.rb:340 run> terminated with exception (report_on_exception is true):
rails7-on-docker-web-1    | /usr/local/bundle/gems/ffi-1.15.5/lib/ffi/library.rb:145:in `block in ffi_lib': Could not open library 'vips.so.42': vips.so.42: cannot open shared object file: No such file or directory. (LoadError)
rails7-on-docker-web-1    | Could not open library 'libvips.so.42': libvips.so.42: cannot open shared object file: No such file or directory
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/ffi-1.15.5/lib/ffi/library.rb:99:in `map'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/ffi-1.15.5/lib/ffi/library.rb:99:in `ffi_lib'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/ruby-vips-2.1.4/lib/vips.rb:573:in `<module:Vips>'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/ruby-vips-2.1.4/lib/vips.rb:570:in `<main>'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/bootsnap-1.10.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/bootsnap-1.10.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/zeitwerk-2.5.4/lib/zeitwerk/kernel.rb:35:in `require'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/image_processing-1.12.1/lib/image_processing/vips.rb:1:in `<main>'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/bootsnap-1.10.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/bootsnap-1.10.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/zeitwerk-2.5.4/lib/zeitwerk/kernel.rb:35:in `require'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/activestorage-7.0.2.2/lib/active_storage/transformers/image_processing_transformer.rb:26:in `const_get'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/activestorage-7.0.2.2/lib/active_storage/transformers/image_processing_transformer.rb:26:in `processor'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/activestorage-7.0.2.2/lib/active_storage/transformers/image_processing_transformer.rb:17:in `process'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/activestorage-7.0.2.2/lib/active_storage/transformers/transformer.rb:22:in `transform'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/activestorage-7.0.2.2/app/models/active_storage/variation.rb:56:in `block in transform'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/activesupport-7.0.2.2/lib/active_support/notifications.rb:206:in `block in instrument'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/activesupport-7.0.2.2/lib/active_support/notifications/instrumenter.rb:24:in `instrument'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/activesupport-7.0.2.2/lib/active_support/notifications.rb:206:in `instrument'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/activestorage-7.0.2.2/app/models/active_storage/variation.rb:55:in `transform'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/activestorage-7.0.2.2/app/models/active_storage/variant_with_record.rb:35:in `block in transform_blob'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/activestorage-7.0.2.2/lib/active_storage/downloader.rb:15:in `block in open'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/activestorage-7.0.2.2/lib/active_storage/downloader.rb:24:in `open_tempfile'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/activestorage-7.0.2.2/lib/active_storage/downloader.rb:12:in `open'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/activestorage-7.0.2.2/lib/active_storage/service.rb:90:in `open'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/activestorage-7.0.2.2/app/models/active_storage/blob.rb:301:in `open'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/activestorage-7.0.2.2/app/models/active_storage/variant_with_record.rb:34:in `transform_blob'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/activestorage-7.0.2.2/app/models/active_storage/variant_with_record.rb:19:in `process'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/activestorage-7.0.2.2/app/models/active_storage/variant_with_record.rb:14:in `processed'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/activestorage-7.0.2.2/app/models/active_storage/preview.rb:105:in `variant'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/activestorage-7.0.2.2/app/models/active_storage/preview.rb:63:in `url'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/activestorage-7.0.2.2/app/controllers/active_storage/representations/redirect_controller.rb:12:in `show'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/actionpack-7.0.2.2/lib/action_controller/metal/basic_implicit_render.rb:6:in `send_action'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/actionpack-7.0.2.2/lib/abstract_controller/base.rb:214:in `process_action'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/actionpack-7.0.2.2/lib/action_controller/metal/rendering.rb:53:in `process_action'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/actionpack-7.0.2.2/lib/abstract_controller/callbacks.rb:234:in `block in process_action'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/activesupport-7.0.2.2/lib/active_support/callbacks.rb:118:in `block in run_callbacks'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/actiontext-7.0.2.2/lib/action_text/rendering.rb:20:in `with_renderer'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/actiontext-7.0.2.2/lib/action_text/engine.rb:69:in `block (4 levels) in <class:Engine>'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/activesupport-7.0.2.2/lib/active_support/callbacks.rb:127:in `instance_exec'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/activesupport-7.0.2.2/lib/active_support/callbacks.rb:127:in `block in run_callbacks'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/activesupport-7.0.2.2/lib/active_support/callbacks.rb:138:in `run_callbacks'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/actionpack-7.0.2.2/lib/abstract_controller/callbacks.rb:233:in `process_action'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/actionpack-7.0.2.2/lib/action_controller/metal/rescue.rb:22:in `process_action'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/actionpack-7.0.2.2/lib/action_controller/metal/instrumentation.rb:67:in `block in process_action'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/activesupport-7.0.2.2/lib/active_support/notifications.rb:206:in `block in instrument'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/activesupport-7.0.2.2/lib/active_support/notifications/instrumenter.rb:24:in `instrument'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/activesupport-7.0.2.2/lib/active_support/notifications.rb:206:in `instrument'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/actionpack-7.0.2.2/lib/action_controller/metal/instrumentation.rb:66:in `process_action'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/actionpack-7.0.2.2/lib/action_controller/metal/params_wrapper.rb:259:in `process_action'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/activerecord-7.0.2.2/lib/active_record/railties/controller_runtime.rb:27:in `process_action'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/actionpack-7.0.2.2/lib/abstract_controller/base.rb:151:in `process'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/actionview-7.0.2.2/lib/action_view/rendering.rb:39:in `process'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/actionpack-7.0.2.2/lib/action_controller/metal/live.rb:266:in `block (2 levels) in process'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/activesupport-7.0.2.2/lib/active_support/concurrency/share_lock.rb:162:in `sharing'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/activesupport-7.0.2.2/lib/active_support/dependencies/interlock.rb:37:in `running'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/actionpack-7.0.2.2/lib/action_controller/metal/live.rb:258:in `block in process'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/actionpack-7.0.2.2/lib/action_controller/metal/live.rb:343:in `block in new_controller_thread'
rails7-on-docker-web-1    | Exiting
rails7-on-docker-web-1    | [ActiveJob] [ActiveStorage::AnalyzeJob] [d5d68a12-6340-443f-a225-b3b3648bbd13]   TRANSACTION (0.8ms)  COMMIT
rails7-on-docker-web-1    | [ActiveJob] [ActiveStorage::AnalyzeJob] [d5d68a12-6340-443f-a225-b3b3648bbd13] Performed ActiveStorage::AnalyzeJob (Job ID: d5d68a12-6340-443f-a225-b3b3648bbd13) from Async(default) in 160.81ms
rails7-on-docker-web-1    | /usr/local/bundle/gems/ffi-1.15.5/lib/ffi/library.rb:145:in `block in ffi_lib': Could not open library 'vips.so.42': vips.so.42: cannot open shared object file: No such file or directory. (LoadError)
rails7-on-docker-web-1    | Could not open library 'libvips.so.42': libvips.so.42: cannot open shared object file: No such file or directory
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/ffi-1.15.5/lib/ffi/library.rb:99:in `map'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/ffi-1.15.5/lib/ffi/library.rb:99:in `ffi_lib'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/ruby-vips-2.1.4/lib/vips.rb:573:in `<module:Vips>'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/ruby-vips-2.1.4/lib/vips.rb:570:in `<main>'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/bootsnap-1.10.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/bootsnap-1.10.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/zeitwerk-2.5.4/lib/zeitwerk/kernel.rb:35:in `require'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/image_processing-1.12.1/lib/image_processing/vips.rb:1:in `<main>'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/bootsnap-1.10.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/bootsnap-1.10.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/zeitwerk-2.5.4/lib/zeitwerk/kernel.rb:35:in `require'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/activestorage-7.0.2.2/lib/active_storage/transformers/image_processing_transformer.rb:26:in `const_get'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/activestorage-7.0.2.2/lib/active_storage/transformers/image_processing_transformer.rb:26:in `processor'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/activestorage-7.0.2.2/lib/active_storage/transformers/image_processing_transformer.rb:17:in `process'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/activestorage-7.0.2.2/lib/active_storage/transformers/transformer.rb:22:in `transform'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/activestorage-7.0.2.2/app/models/active_storage/variation.rb:56:in `block in transform'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/activesupport-7.0.2.2/lib/active_support/notifications.rb:206:in `block in instrument'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/activesupport-7.0.2.2/lib/active_support/notifications/instrumenter.rb:24:in `instrument'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/activesupport-7.0.2.2/lib/active_support/notifications.rb:206:in `instrument'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/activestorage-7.0.2.2/app/models/active_storage/variation.rb:55:in `transform'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/activestorage-7.0.2.2/app/models/active_storage/variant_with_record.rb:35:in `block in transform_blob'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/activestorage-7.0.2.2/lib/active_storage/downloader.rb:15:in `block in open'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/activestorage-7.0.2.2/lib/active_storage/downloader.rb:24:in `open_tempfile'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/activestorage-7.0.2.2/lib/active_storage/downloader.rb:12:in `open'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/activestorage-7.0.2.2/lib/active_storage/service.rb:90:in `open'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/activestorage-7.0.2.2/app/models/active_storage/blob.rb:301:in `open'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/activestorage-7.0.2.2/app/models/active_storage/variant_with_record.rb:34:in `transform_blob'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/activestorage-7.0.2.2/app/models/active_storage/variant_with_record.rb:19:in `process'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/activestorage-7.0.2.2/app/models/active_storage/variant_with_record.rb:14:in `processed'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/activestorage-7.0.2.2/app/models/active_storage/preview.rb:105:in `variant'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/activestorage-7.0.2.2/app/models/active_storage/preview.rb:63:in `url'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/activestorage-7.0.2.2/app/controllers/active_storage/representations/redirect_controller.rb:12:in `show'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/actionpack-7.0.2.2/lib/action_controller/metal/basic_implicit_render.rb:6:in `send_action'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/actionpack-7.0.2.2/lib/abstract_controller/base.rb:214:in `process_action'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/actionpack-7.0.2.2/lib/action_controller/metal/rendering.rb:53:in `process_action'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/actionpack-7.0.2.2/lib/abstract_controller/callbacks.rb:234:in `block in process_action'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/activesupport-7.0.2.2/lib/active_support/callbacks.rb:118:in `block in run_callbacks'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/actiontext-7.0.2.2/lib/action_text/rendering.rb:20:in `with_renderer'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/actiontext-7.0.2.2/lib/action_text/engine.rb:69:in `block (4 levels) in <class:Engine>'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/activesupport-7.0.2.2/lib/active_support/callbacks.rb:127:in `instance_exec'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/activesupport-7.0.2.2/lib/active_support/callbacks.rb:127:in `block in run_callbacks'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/activesupport-7.0.2.2/lib/active_support/callbacks.rb:138:in `run_callbacks'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/actionpack-7.0.2.2/lib/abstract_controller/callbacks.rb:233:in `process_action'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/actionpack-7.0.2.2/lib/action_controller/metal/rescue.rb:22:in `process_action'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/actionpack-7.0.2.2/lib/action_controller/metal/instrumentation.rb:67:in `block in process_action'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/activesupport-7.0.2.2/lib/active_support/notifications.rb:206:in `block in instrument'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/activesupport-7.0.2.2/lib/active_support/notifications/instrumenter.rb:24:in `instrument'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/activesupport-7.0.2.2/lib/active_support/notifications.rb:206:in `instrument'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/actionpack-7.0.2.2/lib/action_controller/metal/instrumentation.rb:66:in `process_action'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/actionpack-7.0.2.2/lib/action_controller/metal/params_wrapper.rb:259:in `process_action'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/activerecord-7.0.2.2/lib/active_record/railties/controller_runtime.rb:27:in `process_action'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/actionpack-7.0.2.2/lib/abstract_controller/base.rb:151:in `process'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/actionview-7.0.2.2/lib/action_view/rendering.rb:39:in `process'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/actionpack-7.0.2.2/lib/action_controller/metal/live.rb:266:in `block (2 levels) in process'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/activesupport-7.0.2.2/lib/active_support/concurrency/share_lock.rb:162:in `sharing'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/activesupport-7.0.2.2/lib/active_support/dependencies/interlock.rb:37:in `running'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/actionpack-7.0.2.2/lib/action_controller/metal/live.rb:258:in `block in process'
rails7-on-docker-web-1    |     from /usr/local/bundle/gems/actionpack-7.0.2.2/lib/action_controller/metal/live.rb:343:in `block in new_controller_thread'
rails7-on-docker-web-1 exited with code 1

当我在没有docker的情况下直接以本机方式运行应用程序时,我会得到另一个错误:

` `require': dlopen(/Users/heron/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/ffi-1.15.5/lib/ffi_c.bundle, 9): no suitable image found.  Did find: (LoadError)
/Users/heron/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/ffi-1.15.5/lib/ffi_c.bundle: mach-o, but wrong architecture

我不知道这是rails 7的问题,还是与我的机器有关。我使用的是M1 Mac电脑!

从这个Github线程

application.rb中的变体处理器分配给:mini_magic或机器上的任何其他处理器。

对我来说,config.active_storage.variant_processor = :mini_magick解决了崩溃问题。

相关内容

  • 没有找到相关文章

最新更新