Project

General

Profile

Actions

Patch #23269

closed

Fix for Error: Unable to autoload constant Redmine::Version when accessing the time report in first request

Added by Holger Just over 7 years ago. Updated over 7 years ago.

Status:
Closed
Priority:
Normal
Category:
Rails support
Target version:
Start date:
Due date:
% Done:

0%

Estimated time:

Description

When starting up Redmine in development mode and accessing the /time_entries/report page on the first request, Redmine in at least versions 3.3 and trunk fails to properly autoload the Version class.

The full error is:

Unable to autoload constant Redmine::Version, expected lib/redmine/version.rb to define it

activesupport (4.2.6) lib/active_support/dependencies.rb:495:in `load_missing_constant'
activesupport (4.2.6) lib/active_support/dependencies.rb:184:in `const_missing'
activesupport (4.2.6) lib/active_support/dependencies.rb:526:in `load_missing_constant'
activesupport (4.2.6) lib/active_support/dependencies.rb:184:in `const_missing'
activesupport (4.2.6) lib/active_support/dependencies.rb:526:in `load_missing_constant'
activesupport (4.2.6) lib/active_support/dependencies.rb:184:in `const_missing'
lib/redmine/helpers/time_report.rb:111:in `load_available_criteria'
lib/redmine/helpers/time_report.rb:39:in `available_criteria'
app/views/timelog/report.html.erb:23:in `block in _app_views_timelog_report_html_erb___3330057872428091759_70181945143200'

The reason for this is that the lookup happens inside the class Redmine::Helpers::TimeReport and the Version model class is not loaded yet. Thus, the Rails autoloader tries to load the class and navigates up the module chain. It finds a file matching the naming conventions in lib/redmine/version.rb which would match the expected module/class Redmine::Version which in turn would have precedence before ::Version in the lookup chain.

Since lib/redmine/version.rb does not define Redmine::Version, the error occurs. A fix to this is to fully qualify the class on lookup to give the autoloader a hint where to look at. The attached patch fixes this.

Note that this issue doesn't seem to occur in production mode.


Files

Actions #1

Updated by Jean-Philippe Lang over 7 years ago

  • Status changed from New to Resolved
  • Assignee set to Jean-Philippe Lang
  • Target version set to 3.2.4

Committed, thanks.

Actions #2

Updated by Jean-Philippe Lang over 7 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF