error in my init.rb
ashrafalzyoud opened this issue · 8 comments
my init. rb
$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/lib"
require 'issues_helper_patch'
my issues_helper_patch.rb
module SubtasksInheritedFields
module IssuesHelperPatch
module InstanceMethods
# Returns a link for adding a new subtask to the given issue
def link_to_new_subtask_plugin(issue)
attrs = SubtasksInheritedFields::Helpers.inherit_attrs(issue)
link_to(l(:button_add), new_project_issue_path(issue.project, :issue => attrs, :back_url => issue_path(issue)))
end
end
def self.included(receiver)
receiver.send :include, InstanceMethods
receiver.class_eval do
unloadable
alias_method :link_to_new_subtask, :link_to_new_subtask_plugin
end
end
end
end
unless IssuesHelper.included_modules.include?(SubtasksInheritedFields::IssuesHelperPatch)
puts "Including module into IssuesHelper"
IssuesHelper.send(:include, SubtasksInheritedFields::IssuesHelperPatch)
end
my error
rake aborted!
Zeitwerk::NameError: expected file /home/redmine/5.0.2/plugins/redmine_subtasks_inherited_fields/lib/issues_controller_patch.rb to define constant IssuesControllerPatch, but didn't
raise Zeitwerk::NameError.new("expected file #{file} to define constant #{cpath}, but didn't", cref.last)
this line error
how i can define IssuesHelper
???
Hey, let's grab some more context. Is this a Rails application?
yes redmine application,its using ruby on rails
but in new version its using zeitwek and i need update this plugin
u can see the plugin
i must now using zeitwek to load this plugin
https://github.com/edosoft/redmine-inherit-fields-plugin
I am not familiar with Redmine, but the error is about lib/issues_controller_patch.rb
not defining IssuesControllerPatch
.
Two questions:
- When is
init.rb
executed during the boot process? Does it run before the files inconfig/initializers
or later? - Can you paste
lib/issues_controller_patch.rb
? - I guess the application has
lib
in the autoload paths?
https://github.com/edosoft/redmine-inherit-fields-plugin
open this link plz all files there
redmine version 5 now using zeitwek
and must all plugins change loader
im do in my init.rb
$LOAD_PATH.unshift "#{File.dirname(FILE)}/lib"
require 'issues_helper_patch'
require 'issues_controller_patch'
......
but the error in name inside 'issues_helper_patch,'issues_controller_patch'
in this code
unless IssuesHelper.included_modules.include?(SubtasksInheritedFields::IssuesHelperPatch)
puts "Including module into IssuesHelper"
IssuesHelper.send(:include, SubtasksInheritedFields::IssuesHelperPatch)
end
how i define issues_helper include (SubtasksInheritedFields::IssuesHelperPatch)
in my lib folder i have 3 files
1-lib/issues_controller_patch.rb
2-lib/issues_helper_patch.rb
3-lib/subtasks_inherited_fields.rb
im do in my init.rb
if Rails.configuration.respond_to?(:autoloader) && Rails.configuration.autoloader == :zeitwerk
Rails.autoloaders.each { |loader| loader.ignore(File.dirname(__FILE__) + '/lib') }
end
require File.dirname(__FILE__) + '/lib/subtasks_inherited_fields'
require File.dirname(__FILE__) + '/lib/issues_helper_patch'
require File.dirname(__FILE__) + '/lib/issues_controller_patch'
in my -lib/issues_helper_patch.rb
module SubtasksInheritedFields
module IssuesHelperPatch
module InstanceMethods
# Returns a link for adding a new subtask to the given issue
def link_to_new_subtask_plugin(issue)
attrs = SubtasksInheritedFields::Helpers.inherit_attrs(issue)
link_to(l(:button_add), new_project_issue_path(issue.project, :issue => attrs, :back_url => issue_path(issue)))
end
end
def self.included(receiver)
receiver.send :include, InstanceMethods
receiver.class_eval do
unloadable
alias_method :link_to_new_subtask, :link_to_new_subtask_plugin
end
end
end
end
unless IssuesHelper.included_modules.include?(SubtasksInheritedFields::IssuesHelperPatch)
#puts "Including module into IssuesHelper"
IssuesHelper.send(:include, SubtasksInheritedFields::IssuesHelperPatch)
end
this msg its give to me
redmine@redmine:~/5.0.2$ bundle exec rake redmine:plugins:migrate RAILS_ENV=production
rake aborted!
Zeitwerk::NameError: expected file /home/redmine/5.0.2/plugins/redmine_subtasks_inherited_fields/lib/issues_helper_patch.rb to define constant IssuesHelperPatch, but didn't
raise Zeitwerk::NameError.new("expected file #{file} to define constant #{cpath}, but didn't", cref.last)
^^^^^
im sure bec module IssuesHelper
how i can loaded it
unless IssuesHelper.included_modules.include?(SubtasksInheritedFields::IssuesHelperPatch)
From the error, it seems that Zeitwerk believes it has to manage that lib
directory, and it is trying to load files in there before init.rb
is executed.
I'd love to help you, but I am not familiar with Redmine plugins and this is not a bug in Zeitwerk. I suggest that you open an issue in https://github.com/edosoft/redmine-inherit-fields-plugin explaining that the plugin is not compatible with Redmine 5.
I see the plugin seems to be working on this, please don't hesitate to ping me there if those patches need any help.