Project

General

Profile

Actions

Defect #26513

closed

Rails5: production env: NameError (uninitialized constant Redmine::SortCriteria)

Added by Toshi MARUYAMA over 7 years ago. Updated over 7 years ago.

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

0%

Estimated time:
Resolution:
Fixed
Affected version:

Description

Started GET "/test-trunk/projects/redmine-svn/issues" for ::1 at 2017-07-24 22:33:49 +0900
Processing by IssuesController#index as HTML
  Parameters: {"project_id"=>"redmine-svn"}
  Current user: admin (id=1)
Completed 500 Internal Server Error in 258ms (ActiveRecord: 184.1ms)

NameError (uninitialized constant Redmine::SortCriteria):

app/models/query.rb:758:in `sort_criteria='
app/models/query.rb:380:in `build_from_params'
app/models/issue_query.rb:77:in `build_from_params'
app/helpers/queries_helper.rb:299:in `retrieve_query'
app/controllers/issues_controller.rb:43:in `index'
lib/redmine/sudo_mode.rb:63:in `sudo_mode'

It is fine in test env.


Related issues

Related to Redmine - Feature #23630: Migrate to Rails 5.2ClosedJean-Philippe Lang

Actions
Actions #1

Updated by Go MAEDA over 7 years ago

  • Status changed from New to Confirmed

Confirmed the problem.

Started GET "/projects/ecookbook/issues" for 127.0.0.1 at 2017-07-24 22:54:41 +0900
Processing by IssuesController#index as HTML
  Parameters: {"project_id"=>"ecookbook"}
  Current user: admin (id=1)
Completed 500 Internal Server Error in 112ms (ActiveRecord: 8.7ms)

NameError (uninitialized constant Redmine::SortCriteria):

app/models/query.rb:758:in `sort_criteria='
app/models/query.rb:361:in `initialize'
app/models/issue_query.rb:54:in `initialize'
app/helpers/queries_helper.rb:305:in `retrieve_query'
app/controllers/issues_controller.rb:43:in `index'
lib/redmine/sudo_mode.rb:63:in `sudo_mode'
$ bin/about

Environment:
  Redmine version                3.4.2.devel.16874
  Ruby version                   2.4.0-p0 (2016-12-24) [x86_64-darwin16]
  Rails version                  5.1.2
  Environment                    production
  Database adapter               SQLite
SCM:
  Subversion                     1.9.5
  Darcs                          2.12.0
  Mercurial                      3.8.4
  Cvs                            1.12.13
  Bazaar                         2.7.0
  Git                            2.11.0
  Filesystem
Redmine plugins:
  no plugin installed
Actions #2

Updated by Go MAEDA over 7 years ago

A workaround for this issue.
http://guides.rubyonrails.org/upgrading_ruby_on_rails.html#autoloading-is-disabled-after-booting-in-the-production-environment

Index: config/application.rb
===================================================================
--- config/application.rb    (revision 16874)
+++ config/application.rb    (working copy)
@@ -12,6 +12,7 @@

     # Custom directories with classes and modules you want to be autoloadable.
     config.autoload_paths += %W(#{config.root}/lib)
+    config.enable_dependency_loading = true

     # Only load the plugins named here, in the order given (default is alphabetical).
     # :all can be used as a placeholder for all plugins not explicitly named.
Actions #3

Updated by Jean-Philippe Lang over 7 years ago

  • Status changed from Confirmed to Closed
  • Target version deleted (4.0.0)
  • Resolution set to Fixed

Fixed in r16877.

Actions #4

Updated by Jean-Philippe Lang over 7 years ago

Actions #5

Updated by Toshi MARUYAMA over 7 years ago

I tried this.

config.eager_load_paths << Rails.root.join('lib')

But it seems we have many jobs, so I have committed r16881.

Actions #6

Updated by Pavel Rosický over 7 years ago

toshio harita it should be only a temporarly solution

all classes should be explicitly required or eager-loaded on production to avoid concurency issues
http://blog.bigbinary.com/2016/08/29/rails-5-disables-autoloading-after-booting-the-app-in-production.html

Actions #7

Updated by Toshi MARUYAMA over 7 years ago

Pavel Rosický wrote:

toshio harita it should be only a temporarly solution

all classes should be explicitly required

OK. I have committed r16882 and r16883.

or eager-loaded on production to avoid concurency issues
http://blog.bigbinary.com/2016/08/29/rails-5-disables-autoloading-after-booting-the-app-in-production.html

I tried this.

=== (+3,-2) config/application.rb ===
@@ -11,7 +11,8 @@
     # -- all .rb files in that directory are automatically loaded.

     # Custom directories with classes and modules you want to be autoloadable.
-    config.autoload_paths += %W(#{config.root}/lib)
+    #config.autoload_paths += %W(#{config.root}/lib)
+    config.eager_load_paths << Rails.root.join('lib')

then

.../lib/generators/redmine_plugin_controller/redmine_plugin_controller_generator.rb:1:in `<top (required)>':
    uninitialized constant Generators::NamedBase (NameError)

"$ rm -fR lib/generators/redmine_plugin_*", then

/home/xxxxx/.rvm/gems/ruby-2.2.7/gems/activesupport-5.1.2/lib/active_support/dependencies.rb:292:in `require': No such file to load -- test/unit.rb (LoadError)
    from /home/xxxxx/.rvm/gems/ruby-2.2.7/gems/activesupport-5.1.2/lib/active_support/dependencies.rb:292:in `block in require'
    from /home/xxxxx/.rvm/gems/ruby-2.2.7/gems/activesupport-5.1.2/lib/active_support/dependencies.rb:258:in `load_dependency'
    from /home/xxxxx/.rvm/gems/ruby-2.2.7/gems/activesupport-5.1.2/lib/active_support/dependencies.rb:292:in `require'
    from /yyyyy/lib/plugins/acts_as_tree/test/acts_as_tree_test.rb:1:in `<top (required)>'

Actions

Also available in: Atom PDF