Skip to content

Commit

Permalink
DEV: Fixup plugin initialization guard (discourse#24628)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
davidtaylorhq authored Nov 29, 2023
1 parent 1881ae5 commit 265a8cd
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/plugin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ def self.initialization_guard(&block)
.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 }
Expand Down Expand Up @@ -42,7 +44,7 @@ def self.initialization_guard(&block)
** 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!
Expand All @@ -51,7 +53,7 @@ def self.initialization_guard(&block)
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}
Expand Down

0 comments on commit 265a8cd

Please sign in to comment.