From 3157d5ee1b2ff830c8fa7c7e72996dcdc8389a1c Mon Sep 17 00:00:00 2001 From: Joffrey JAFFEUX Date: Fri, 16 Apr 2021 15:25:20 +0200 Subject: [PATCH] DEV: ensures stylesheet watcher isn't crashing with gems plugins (#12733) * DEV: ensures stylesheet watcher isn't crashing with gems plugins This bug has been exhibited since discourse_dev is now including an auth plugin which was loaded as a relative path instead of an absolute path, eg: `Users/bob/.gem/ruby/2.6.6/gems/discourse_dev-0.1.0/auth/plugin.rb` Instead of `/Users/bob/.gem/ruby/2.6.6/gems/discourse_dev-0.1.0/auth/plugin.rb` --- lib/stylesheet/watcher.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/stylesheet/watcher.rb b/lib/stylesheet/watcher.rb index f814d1b782..a8bbda5f00 100644 --- a/lib/stylesheet/watcher.rb +++ b/lib/stylesheet/watcher.rb @@ -20,8 +20,14 @@ module Stylesheet return @default_paths if @default_paths @default_paths = ["app/assets/stylesheets"] - Discourse.plugins.each do |p| - @default_paths << File.dirname(p.path).sub(Rails.root.to_s, '').sub(/^\//, '') + Discourse.plugins.each do |plugin| + if plugin.path.to_s.include?(Rails.root.to_s) + @default_paths << File.dirname(plugin.path).sub(Rails.root.to_s, '').sub(/^\//, '') + else + # if plugin doesn’t seem to be in our app, consider it as outside of the app + # and ignore it + warn("[stylesheet watcher] Ignoring outside of rails root plugin: #{plugin.path.to_s}") + end end @default_paths end