Project

General

Profile

Actions

Defect #31337

closed

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

Added by Lluís Gili almost 5 years ago. Updated almost 5 years ago.

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

0%

Estimated time:
Resolution:
Fixed
Affected version:

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)

Actions #1

Updated by Go MAEDA almost 5 years 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|
Actions #2

Updated by Go MAEDA almost 5 years 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>
Actions #3

Updated by Go MAEDA almost 5 years 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
Actions #4

Updated by Go MAEDA almost 5 years 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.

Actions

Also available in: Atom PDF