Autoload/spring not working due to various "Unable to autoload constant" errors
Summary
In development mode, when trying to use spring, subsequent runs give various "Unable to autoload constant" errors, such as
Unable to autoload constant Gitlab::EncodingHelper
Unable to autoload constant EE::ProjectsHelper
Unable to autoload constant EE::Namespace
Steps to reproduce
Use spring:
spring stop
spring rails c
Quit the console once it's up, then change a line of code somewhere (like in application_controller.rb) and run spring rails c again.
Relevant logs and/or screenshots
/Users/my_user/.rvm/gems/ruby-2.3.6/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:495:in `load_missing_constant': Unable to autoload constant EE::ProjectsHelper, expected /Users/my_user/dev/gitlab/ee/gitlab/ee/app/helpers/ee/projects_helper.rb to define it (LoadError)
from /Users/my_user/.rvm/gems/ruby-2.3.6/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:184:in `const_missing'
from /Users/my_user/dev/gitlab/ee/gitlab/app/helpers/projects_helper.rb:2:in `<module:ProjectsHelper>'
from /Users/my_user/dev/gitlab/ee/gitlab/app/helpers/projects_helper.rb:1:in `<top (required)>'
from /Users/my_user/.rvm/gems/ruby-2.3.6/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:457:in `load'
from /Users/my_user/.rvm/gems/ruby-2.3.6/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:457:in `block in load_file'
from /Users/my_user/.rvm/gems/ruby-2.3.6/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:647:in `new_constants_in'
from /Users/my_user/.rvm/gems/ruby-2.3.6/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:456:in `load_file'
from /Users/my_user/.rvm/gems/ruby-2.3.6/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:354:in `require_or_load'
from /Users/my_user/.rvm/gems/ruby-2.3.6/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:494:in `load_missing_constant'
from /Users/my_user/.rvm/gems/ruby-2.3.6/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:184:in `const_missing'
from /Users/my_user/dev/gitlab/ee/gitlab/ee/app/helpers/ee/gitlab_routing_helper.rb:3:in `<module:GitlabRoutingHelper>'
from /Users/my_user/dev/gitlab/ee/gitlab/ee/app/helpers/ee/gitlab_routing_helper.rb:2:in `<module:EE>'
from /Users/my_user/dev/gitlab/ee/gitlab/ee/app/helpers/ee/gitlab_routing_helper.rb:1:in `<top (required)>'
Possible fixes
My research shows it was introduced in ea10dec6 Merge branch 'ee-37698-current-settings' into 'master', introduced in https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/4337.
All files seem to work correctly, except for lib/gitlab/visibilty_level.rb.
The removal of
extend CurrentSettings
from that file seems to cause the error.
Changing it to
include CurrentSettings
seems to fix it, but I'm not sure if that's the correct fix or not.