Defect #31337

Explicitly load redmine/info in order to avoid "uninitialized constant" error

Added by Lluís Gili 4 months ago. Updated 4 months ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:Go MAEDA% Done:

0%

Category:Rails support
Target version:4.0.4
Resolution:Fixed Affected version:4.0.0

Description

with Rails.env production, where we have:

  config.cache_classes = true
  config.eager_load = true

if you comment this line on lib/redmine.rb

  #menu.push :help, Redmine::Info.help_url, :last => true

accessing http://localhost:3000/admin/info crashes with

  uninitialized constant Redmine::Info
Did you mean?  TZInfo
  app/views/admin/info.html.erb:3:in `_app_views_admin_info_html_erb__3650592729958042480_47028059654180'

rails 5 does not autoload code in production and does not eager_load lib, so shouldn't lib files be moved to app? (or required in a initializer)

Associated revisions

Revision 18193
Added by Go MAEDA 4 months ago

Explicitly load redmine/info in order to avoid "uninitialized constant" error (#31337).

Contributed by Lluís Gili.

Revision 18194
Added by Go MAEDA 4 months ago

Merged r18193 from trunk to 4.0-stable (#31337).

History

#1 Updated by Go MAEDA 4 months ago

  • Status changed from New to Confirmed
  • Affected version set to 4.0.0

Confirmed the problem in production mode.

Started GET "/" for 127.0.0.1 at 2019-05-12 09:09:58 +0900
Processing by WelcomeController#index as HTML
  Current user: anonymous
  Rendering welcome/index.html.erb within layouts/base
  Rendered collection of news/_news.html.erb [2 times] (3.2ms)
  Rendered welcome/index.html.erb within layouts/base (4.8ms)
Completed 500 Internal Server Error in 34ms (ActiveRecord: 1.8ms)

ActionView::Template::Error (uninitialized constant Redmine::Info
Did you mean?  TZInfo):
     5: <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
     6: <title><%= html_title %></title>
     7: <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
     8: <meta name="description" content="<%= Redmine::Info.app_name %>" />
     9: <meta name="keywords" content="issue,bug,tracker" />
    10: <%= csrf_meta_tag %>
    11: <%= favicon %>

app/views/layouts/base.html.erb:8:in `_app_views_layouts_base_html_erb___407490831146708261_70306253856560'
lib/redmine/sudo_mode.rb:65:in `sudo_mode'
diff --git a/lib/redmine.rb b/lib/redmine.rb
index 2de351c07..600b9df57 100644
--- a/lib/redmine.rb
+++ b/lib/redmine.rb
@@ -194,7 +194,7 @@ Redmine::MenuManager.map :top_menu do |menu|
   menu.push :my_page, { :controller => 'my', :action => 'page' }, :if => Proc.new { User.current.logged? }
   menu.push :projects, { :controller => 'projects', :action => 'index' }, :caption => :label_project_plural
   menu.push :administration, { :controller => 'admin', :action => 'index' }, :if => Proc.new { User.current.admin? }, :last => true
-  menu.push :help, Redmine::Info.help_url, :last => true
+  # menu.push :help, Redmine::Info.help_url, :last => true
 end

 Redmine::MenuManager.map :account_menu do |menu|

#2 Updated by Go MAEDA 4 months ago

  • Target version set to Candidate for next minor release

The following patch fixes the problem.

diff --git a/lib/redmine.rb b/lib/redmine.rb
index 7c06ac344..7e4f65370 100644
--- a/lib/redmine.rb
+++ b/lib/redmine.rb
@@ -40,6 +40,7 @@ require 'redmine/activity/fetcher'
 require 'redmine/ciphering'
 require 'redmine/codeset_util'
 require 'redmine/field_format'
+require 'redmine/info'
 require 'redmine/menu_manager'
 require 'redmine/notifiable'
 require 'redmine/platform'
</diff>

#3 Updated by Go MAEDA 4 months ago

  • Subject changed from move lib to app? to redmine/info should be loaded explicitly
  • Category set to Rails support
  • Target version changed from Candidate for next minor release to 4.0.4

#4 Updated by Go MAEDA 4 months ago

  • Subject changed from redmine/info should be loaded explicitly to Explicitly load redmine/info in order to avoid "uninitialized constant" error
  • Status changed from Confirmed to Closed
  • Assignee set to Go MAEDA
  • Resolution set to Fixed

Committed the fix. Thank you for reporting this issue.

Also available in: Atom PDF