I may be a bit late to the party ![]()
I’m hitting the same issue in a new plugin, and searched a bit. It seems this issue hits other plugins too (e.g.: the official chat plugin), but I found a working solution to avoid the tasks being registered multiple times:
# Clear any previous registration
task('import_json:preview').clear
# Task definition
desc 'Previews changes which would be applied by import_json'
task 'import_json:preview', [:file_path] => :environment do |_task, args|
puts "Hello world!"
end
Clearing after the task description will prevent the task to be listed with rake --tasks, so it must be cleared before.