From 265a8cd2b25697fcdd6eac7dca1b126ba57537a1 Mon Sep 17 00:00:00 2001 From: David Taylor Date: Wed, 29 Nov 2023 11:44:09 +0000 Subject: [PATCH] DEV: Fixup plugin initialization guard (#24628) In development, I sometimes get `nil` `location.absolute_path` values. It looks like this is sometimes expected (https://bugs.ruby-lang.org/issues/10561) so we should fallback to `.path` and add a nil check. --- lib/plugin.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/plugin.rb b/lib/plugin.rb index 44e90530a6a..c384d905667 100644 --- a/lib/plugin.rb +++ b/lib/plugin.rb @@ -13,8 +13,10 @@ module Plugin .backtrace_locations .lazy .map do |location| + resolved_path = location.absolute_path || location.path + next if resolved_path.nil? Pathname - .new(location.absolute_path) + .new(resolved_path) .ascend .lazy .find { |path| path.parent == plugins_directory } @@ -42,7 +44,7 @@ module Plugin ** INCOMPATIBLE PLUGIN ** - You are unable to build Discourse due to errors in the plugin at + You are unable to start Discourse due to errors in the plugin at #{plugin_path} Please try removing this plugin and rebuilding again! @@ -51,7 +53,7 @@ module Plugin STDERR.puts <<~TEXT ** PLUGIN FAILURE ** - You are unable to build Discourse due to this error during plugin + You are unable to start Discourse due to this error during plugin initialization: #{error}