没有那个文件或目录 - 转换

No such file or directory - convert

我是 Rails 的新手。今天我开始遇到与 Nokogiri 和 Digest MD5 相关的问题。当我 运行 rails s 为我贡献的应用程序时,它开始抱怨,首先是没有安装 Nokogiri,然后是 Digest md5。

discourse git:(after-hook-event) ✗ bundle install
/Users/jlijo/.rvm/rubies/ruby-2.4.0-turbo/lib/ruby/2.4.0/digest.rb:16:in `const_missing': library not found for class Digest::MD5 -- digest/md5 (LoadError)

我已经解决了 Nokogiri 执行 xcode-select --install 的问题。控制台也停止抱怨 digest md5 但应用程序仍然无法运行(即使 rails 服务器启动),它会引发错误:

Digest::MD5.hexdigest(`convert --version` << `convert -list font`)

undefined method `<<' for nil:NilClass

这真是令人绝望,我花了整个下午试图解决这个问题。我不知道它的根源。我又重新安装了 Ruby 2.4.0。我有 运行 gem install bundlerbundle install

日志:

 D, [2017-08-18T19:28:22.945251 #64797] DEBUG -- :   ThemeField Load (1.3ms)  SELECT "theme_fields".* FROM "theme_fields" JOIN (
          SELECT 2 AS theme_id, 0 AS sort_column
        ) as X ON X.theme_id = theme_fields.theme_id WHERE "theme_fields"."target_id" IN (1, 0) AND "theme_fields"."name" = 'header'  ORDER BY sort_column, target_id  [["name", "header"]]
bin/rails: No such file or directory - convert
bin/rails: No such file or directory - convert
I, [2017-08-18T19:28:22.973323 #64797]  INFO -- :   Rendered common/_discourse_javascript.html.erb (22.8ms)
I, [2017-08-18T19:28:22.975885 #64797]  INFO -- : Completed 500 Internal Server Error in 683ms (ActiveRecord: 98.6ms)
F, [2017-08-18T19:28:22.994012 #64797] FATAL -- :
NoMethodError - undefined method `<<' for nil:NilClass:
  lib/letter_avatar.rb:103:in `image_magick_version'
  lib/letter_avatar.rb:26:in `version'
  app/views/common/_discourse_javascript.html.erb:44:in `_app_views_common__discourse_javascript_html_erb___995238869359027967_70217684279780'
  actionview (4.2.9) lib/action_view/template.rb:145:in `block in render'
  activesupport (4.2.9) lib/active_support/notifications.rb:166:in `instrument'
  actionview (4.2.9) lib/action_view/template.rb:333:in `instrument'
  actionview (4.2.9) lib/action_view/template.rb:143:in `render'
  rack-mini-profiler (0.10.5) lib/mini_profiler/profiling_methods.rb:102:in `block in profile_method'
  actionview (4.2.9) lib/action_view/renderer/partial_renderer.rb:339:in `render_partial'
  actionview (4.2.9) lib/action_view/renderer/partial_renderer.rb:310:in `block in render'
  actionview (4.2.9) lib/action_view/renderer/abstract_renderer.rb:39:in `block in instrument'
  activesupport (4.2.9) lib/active_support/notifications.rb:164:in `block in instrument'
  activesupport (4.2.9) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
  activesupport (4.2.9) lib/active_support/notifications.rb:164:in `instrument'
  actionview (4.2.9) lib/action_view/renderer/abstract_renderer.rb:39:in `instrument'
  actionview (4.2.9) lib/action_view/renderer/partial_renderer.rb:309:in `render'
  actionview (4.2.9) lib/action_view/renderer/renderer.rb:51:in `render_partial'
  actionview (4.2.9) lib/action_view/renderer/renderer.rb:25:in `render'
  actionview (4.2.9) lib/action_view/helpers/rendering_helper.rb:32:in `render'
  app/views/layouts/application.html.erb:121:in `_app_views_layouts_application_html_erb___469980189180314768_70217688394860'
  actionview (4.2.9) lib/action_view/template.rb:145:in `block in render'
  activesupport (4.2.9) lib/active_support/notifications.rb:166:in `instrument'
  actionview (4.2.9) lib/action_view/template.rb:333:in `instrument'
  actionview (4.2.9) lib/action_view/template.rb:143:in `render'
  rack-mini-profiler (0.10.5) lib/mini_profiler/profiling_methods.rb:102:in `block in profile_method'
  actionview (4.2.9) lib/action_view/renderer/template_renderer.rb:66:in `render_with_layout'
  actionview (4.2.9) lib/action_view/renderer/template_renderer.rb:52:in `render_template'
  actionview (4.2.9) lib/action_view/renderer/template_renderer.rb:14:in `render'
  actionview (4.2.9) lib/action_view/renderer/renderer.rb:46:in `render_template'
  actionview (4.2.9) lib/action_view/renderer/renderer.rb:27:in `render'
  actionview (4.2.9) lib/action_view/rendering.rb:100:in `_render_template'
  actionpack (4.2.9) lib/action_controller/metal/streaming.rb:217:in `_render_template'
  actionview (4.2.9) lib/action_view/rendering.rb:83:in `render_to_body'
  actionpack (4.2.9) lib/action_controller/metal/rendering.rb:32:in `render_to_body'
  actionpack (4.2.9) lib/action_controller/metal/renderers.rb:37:in `render_to_body'
  actionpack (4.2.9) lib/abstract_controller/rendering.rb:25:in `render'
  actionpack (4.2.9) lib/action_controller/metal/rendering.rb:16:in `render'
  actionpack (4.2.9) lib/action_controller/metal/instrumentation.rb:44:in `block (2 levels) in render'
  activesupport (4.2.9) lib/active_support/core_ext/benchmark.rb:12:in `block in ms'
  /Users/jlijo/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/benchmark.rb:308:in `realtime'
  activesupport (4.2.9) lib/active_support/core_ext/benchmark.rb:12:in `ms'
  actionpack (4.2.9) lib/action_controller/metal/instrumentation.rb:44:in `block in render'
  actionpack (4.2.9) lib/action_controller/metal/instrumentation.rb:87:in `cleanup_view_runtime'
  activerecord (4.2.9) lib/active_record/railties/controller_runtime.rb:25:in `cleanup_view_runtime'
  actionpack (4.2.9) lib/action_controller/metal/instrumentation.rb:43:in `render'
  lib/topic_list_responder.rb:15:in `block (2 levels) in respond_with_list'
  actionpack (4.2.9) lib/action_controller/metal/mime_responds.rb:217:in `respond_to'
  lib/topic_list_responder.rb:11:in `respond_with_list'
  app/controllers/list_controller.rb:91:in `block (2 levels) in <class:ListController>'
  actionpack (4.2.9) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
  actionpack (4.2.9) lib/abstract_controller/base.rb:198:in `process_action'
  actionpack (4.2.9) lib/action_controller/metal/rendering.rb:10:in `process_action'
  actionpack (4.2.9) lib/abstract_controller/callbacks.rb:20:in `block in process_action'
  activesupport (4.2.9) lib/active_support/callbacks.rb:117:in `call'
  activesupport (4.2.9) lib/active_support/callbacks.rb:555:in `block (2 levels) in compile'
  activesupport (4.2.9) lib/active_support/callbacks.rb:505:in `call'
  activesupport (4.2.9) lib/active_support/callbacks.rb:92:in `__run_callbacks__'
  activesupport (4.2.9) lib/active_support/callbacks.rb:778:in `_run_process_action_callbacks'
  activesupport (4.2.9) lib/active_support/callbacks.rb:81:in `run_callbacks'
  actionpack (4.2.9) lib/abstract_controller/callbacks.rb:19:in `process_action'
  actionpack (4.2.9) lib/action_controller/metal/rescue.rb:29:in `process_action'
  actionpack (4.2.9) lib/action_controller/metal/instrumentation.rb:32:in `block in process_action'
  activesupport (4.2.9) lib/active_support/notifications.rb:164:in `block in instrument'
  activesupport (4.2.9) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
  activesupport (4.2.9) lib/active_support/notifications.rb:164:in `instrument'
  actionpack (4.2.9) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
  actionpack (4.2.9) lib/action_controller/metal/params_wrapper.rb:250:in `process_action'
  activerecord (4.2.9) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
  actionpack (4.2.9) lib/abstract_controller/base.rb:137:in `process'
  actionview (4.2.9) lib/action_view/rendering.rb:30:in `process'
  rack-mini-profiler (0.10.5) lib/mini_profiler/profiling_methods.rb:102:in `block in profile_method'
  actionpack (4.2.9) lib/action_controller/metal.rb:196:in `dispatch'
  actionpack (4.2.9) lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
  actionpack (4.2.9) lib/action_controller/metal.rb:237:in `block in action'
  actionpack (4.2.9) lib/action_dispatch/routing/route_set.rb:74:in `dispatch'
  actionpack (4.2.9) lib/action_dispatch/routing/route_set.rb:43:in `serve'
  actionpack (4.2.9) lib/action_dispatch/routing/mapper.rb:49:in `serve'
  actionpack (4.2.9) lib/action_dispatch/journey/router.rb:43:in `block in serve'
  actionpack (4.2.9) lib/action_dispatch/journey/router.rb:30:in `serve'
  actionpack (4.2.9) lib/action_dispatch/routing/route_set.rb:817:in `call'
  rack-protection (1.5.3) lib/rack/protection/frame_options.rb:31:in `call'
  omniauth (1.6.1) lib/omniauth/strategy.rb:189:in `call!'
  omniauth (1.6.1) lib/omniauth/strategy.rb:167:in `call'
  omniauth (1.6.1) lib/omniauth/strategy.rb:189:in `call!'
  omniauth (1.6.1) lib/omniauth/strategy.rb:167:in `call'
  omniauth (1.6.1) lib/omniauth/strategy.rb:189:in `call!'
  omniauth (1.6.1) lib/omniauth/strategy.rb:167:in `call'
  omniauth (1.6.1) lib/omniauth/strategy.rb:189:in `call!'
  omniauth (1.6.1) lib/omniauth/strategy.rb:167:in `call'
  omniauth (1.6.1) lib/omniauth/strategy.rb:189:in `call!'
  omniauth (1.6.1) lib/omniauth/strategy.rb:167:in `call'
  omniauth (1.6.1) lib/omniauth/strategy.rb:189:in `call!'
  omniauth (1.6.1) lib/omniauth/strategy.rb:167:in `call'
  omniauth (1.6.1) lib/omniauth/builder.rb:63:in `call'
  rack (1.6.8) lib/rack/conditionalget.rb:25:in `call'
  rack (1.6.8) lib/rack/head.rb:13:in `call'
  actionpack (4.2.9) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
  actionpack (4.2.9) lib/action_dispatch/middleware/flash.rb:260:in `call'
  rack (1.6.8) lib/rack/session/abstract/id.rb:225:in `context'
  rack (1.6.8) lib/rack/session/abstract/id.rb:220:in `call'
  actionpack (4.2.9) lib/action_dispatch/middleware/cookies.rb:560:in `call'
  activerecord (4.2.9) lib/active_record/query_cache.rb:36:in `call'
  activerecord (4.2.9) lib/active_record/connection_adapters/abstract/connection_pool.rb:653:in `call'
  activerecord (4.2.9) lib/active_record/migration.rb:377:in `call'
  actionpack (4.2.9) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
  activesupport (4.2.9) lib/active_support/callbacks.rb:88:in `__run_callbacks__'
  activesupport (4.2.9) lib/active_support/callbacks.rb:778:in `_run_call_callbacks'
  activesupport (4.2.9) lib/active_support/callbacks.rb:81:in `run_callbacks'
  actionpack (4.2.9) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
  actionpack (4.2.9) lib/action_dispatch/middleware/reloader.rb:73:in `call'
  actionpack (4.2.9) lib/action_dispatch/middleware/remote_ip.rb:78:in `call'
  better_errors (2.1.1) lib/better_errors/middleware.rb:84:in `protected_app_call'
  better_errors (2.1.1) lib/better_errors/middleware.rb:79:in `better_errors_call'
  better_errors (2.1.1) lib/better_errors/middleware.rb:57:in `call'
  actionpack (4.2.9) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
  actionpack (4.2.9) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
  logster (1.2.7) lib/logster/middleware/reporter.rb:31:in `call'
  railties (4.2.9) lib/rails/rack/logger.rb:38:in `call_app'
  railties (4.2.9) lib/rails/rack/logger.rb:22:in `call'
  config/initializers/100-quiet_logger.rb:17:in `call_with_quiet_assets'
  config/initializers/100-silence_logger.rb:29:in `call'
  actionpack (4.2.9) lib/action_dispatch/middleware/request_id.rb:21:in `call'
  rack (1.6.8) lib/rack/methodoverride.rb:22:in `call'
  rack (1.6.8) lib/rack/runtime.rb:18:in `call'
  actionpack (4.2.9) lib/action_dispatch/middleware/static.rb:120:in `call'
  actionpack (4.2.9) lib/action_dispatch/middleware/static.rb:120:in `call'
  rack (1.6.8) lib/rack/sendfile.rb:113:in `call'
  lib/middleware/missing_avatars.rb:21:in `call'
  lib/middleware/turbo_dev.rb:34:in `call'
  rack-mini-profiler (0.10.5) lib/mini_profiler/profiler.rb:282:in `call'
  message_bus (2.0.5) lib/message_bus/rack/middleware.rb:63:in `call'
  railties (4.2.9) lib/rails/engine.rb:518:in `call'
  railties (4.2.9) lib/rails/application.rb:165:in `call'
  railties (4.2.9) lib/rails/railtie.rb:194:in `method_missing'
  rack (1.6.8) lib/rack/urlmap.rb:66:in `block in call'
  rack (1.6.8) lib/rack/urlmap.rb:50:in `call'
  rack (1.6.8) lib/rack/content_length.rb:15:in `call'
  puma (3.9.1) lib/puma/configuration.rb:224:in `call'
  puma (3.9.1) lib/puma/server.rb:602:in `handle_request'
  puma (3.9.1) lib/puma/server.rb:435:in `process_client'
  puma (3.9.1) lib/puma/server.rb:299:in `block in run'
  puma (3.9.1) lib/puma/thread_pool.rb:120:in `block in spawn_thread'

D, [2017-08-18T19:28:23.107322 #64797] DEBUG -- :
D, [2017-08-18T19:28:23.107454 #64797] DEBUG -- :
I, [2017-08-18T19:28:23.107604 #64797]  INFO -- : Started POST "/__better_errors/5a9496d634c72ab8/variables" for ::1 at 2017-08-18 19:28:23 +0200
bin/rails: No such file or directory - convert
bin/rails: No such file or directory - convert
bin/rails: No such file or directory - convert
bin/rails: No such file or directory - convert
bin/rails: No such file or directory - convert
bin/rails: No such file or directory - convert

您可能没有安装 ImageMagick,这是 convert 命令的来源。那会出错并留下 nil.