Project

General

Profile

Actions

Defect #13692

closed

warning: already initialized constant on Ruby 1.8.7

Added by Kieran Delaney over 11 years ago. Updated about 11 years ago.

Status:
Closed
Priority:
Low
Assignee:
-
Category:
Ruby support
Target version:
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:
Fixed
Affected version:

Description

When running the following command (either from the command line or git's post-receive hook) output generated produces warnings.

Command
rails runner "Repository.fetch_changesets" -e production

Warnings
/usr/lib64/ruby/gems/1.8/gems/coderay-1.0.9/lib/coderay/helpers/file_type.rb:19: warning: already initialized constant UnknownFileType
/usr/lib64/ruby/gems/1.8/gems/coderay-1.0.9/lib/coderay/helpers/file_type.rb:126: warning: already initialized constant TypeFromExt
/usr/lib64/ruby/gems/1.8/gems/coderay-1.0.9/lib/coderay/helpers/file_type.rb:132: warning: already initialized constant TypeFromShebang
/usr/lib64/ruby/gems/1.8/gems/coderay-1.0.9/lib/coderay/helpers/file_type.rb:138: warning: already initialized constant TypeFromName

We're running redmine via passenger, and almost exclusively calling this script from gits post-receive hook. No functionality is broken, it's just generating warning output in the developers git bash when they push and trigger the script, which is causing a little bit of panic.

We upgraded directly from 2.1.6 so I do not know if this affected 2.2.x

Actions #1

Updated by Peter Panther over 11 years ago

Have the same Issue with Version 2.3.1

Every runner-scripts produces warnings. The Apache log is is also flooded with these messages .....

/var/lib/gems/1.8/gems/coderay-1.0.8/lib/coderay/helpers/file_type.rb:19: warning: already initialized constant UnknownFileType
/var/lib/gems/1.8/gems/coderay-1.0.8/lib/coderay/helpers/file_type.rb:126: warning: already initialized constant TypeFromExt
/var/lib/gems/1.8/gems/coderay-1.0.8/lib/coderay/helpers/file_type.rb:132: warning: already initialized constant TypeFromShebang
/var/lib/gems/1.8/gems/coderay-1.0.8/lib/coderay/helpers/file_type.rb:138: warning: already initialized constant TypeFromName

Actions #2

Updated by Toshi MARUYAMA over 11 years ago

  • Subject changed from Updating to warning: already initialized constant
Actions #3

Updated by xilong pei over 11 years ago

My redmine, http://elastos.org/project/ has the same Issue.

Environment:
  Redmine version                          2.0.3.stable
  Ruby version                             1.8.7 (x86_64-linux)
  Rails version                            3.2.6
  Environment                              production
  Database adapter                         MySQL
Redmine plugins:
  no plugin installed

Actions #4

Updated by Sen Haerens over 11 years ago

Same issue in 2.3.1

RAILS_ENV=production ./script/about

/usr/lib/ruby/gems/1.8/gems/coderay-1.0.9/lib/coderay/helpers/file_type.rb:19: warning: already initialized constant UnknownFileType
/usr/lib/ruby/gems/1.8/gems/coderay-1.0.9/lib/coderay/helpers/file_type.rb:126: warning: already initialized constant TypeFromExt
/usr/lib/ruby/gems/1.8/gems/coderay-1.0.9/lib/coderay/helpers/file_type.rb:132: warning: already initialized constant TypeFromShebang
/usr/lib/ruby/gems/1.8/gems/coderay-1.0.9/lib/coderay/helpers/file_type.rb:138: warning: already initialized constant TypeFromName

Environment:
  Redmine version                          2.3.1.stable.11903
  Ruby version                             1.8.7 (i686-linux)
  Rails version                            3.2.13
  Environment                              production
  Database adapter                         MySQL
Redmine plugins:
  no plugin installed
Actions #5

Updated by Toshi MARUYAMA over 11 years ago

  • Category set to Ruby support
Actions #6

Updated by Nicolas Bouthors over 11 years ago

Hi all,

I had the same issue and I could fix it by commenting the line 36

require 'coderay/helpers/file_type'
in redmine/syntax_highlighting.rb.

It seems to me that this combination of libs causes a include-loop (coderay auto loads syntax_highlighting).
Syntax highlight still works after ;)

Actions #7

Updated by Toshi MARUYAMA over 11 years ago

  • Related to Defect #11089: UTF-8 encoding not showing correctly when looking highlighted php file contents added
Actions #8

Updated by Toshi MARUYAMA over 11 years ago

  • Related to deleted (Defect #11089: UTF-8 encoding not showing correctly when looking highlighted php file contents)
Actions #9

Updated by Toshi MARUYAMA over 11 years ago

  • Subject changed from warning: already initialized constant to warning: already initialized constant on Ruby 1.8.7
Actions #10

Updated by Toshi MARUYAMA over 11 years ago

  • Target version set to 2.4.0
Actions #11

Updated by Toshi MARUYAMA over 11 years ago

  • Target version changed from 2.4.0 to 2.3.2
Actions #12

Updated by Toshi MARUYAMA over 11 years ago

  • Status changed from New to Closed
  • Resolution set to Fixed

Committed in trunk r11925 and 2.3-stable r11929, thanks.

Actions #13

Updated by Bert Fraterman about 11 years ago

We're running ruby 2.0.0, but the fix in r11925 causes a problem in displaying code files for us. We're getting a 500 error when trying to view file from the repository. Details:

Started GET "/projects/apps/repository/entry/trunk/code/Form1.cs" for 10.0.0.150 at 2013-11-08 10:41:35 +0100
Processing by RepositoriesController#entry as HTML
  Parameters: {"id"=>"apps", "path"=>"trunk/code/Form1.cs"}
  Current user: b.fraterman (id=11)
  Rendered repositories/_navigation.html.erb (3.1ms)
  Rendered repositories/_breadcrumbs.html.erb (1.9ms)
  Rendered repositories/_link_to_functions.html.erb (2.2ms)
  Rendered common/_file.html.erb (2.8ms)
  Rendered repositories/entry.html.erb within layouts/base (11.3ms)
Completed 500 Internal Server Error in 175ms

ActionView::Template::Error (uninitialized constant CodeRay::FileType):
    2: <table class="filecontent syntaxhl">
    3: <tbody>
    4: <% line_num = 1 %>
    5: <% syntax_highlight_lines(filename, Redmine::CodesetUtil.to_utf8_by_setting(content)).each do |line| %>
    6:   <tr>
    7:     <th class="line-num" id="L<%= line_num %>">
    8:       <a href="#L<%= line_num %>"><%= line_num %></a>
  lib/redmine/syntax_highlighting.rb:41:in `highlight_by_filename'
  lib/redmine/syntax_highlighting.rb:23:in `highlight_by_filename'
  app/helpers/application_helper.rb:394:in `syntax_highlight'
  app/helpers/application_helper.rb:389:in `syntax_highlight_lines'
  app/views/common/_file.html.erb:5:in `_app_views_common__file_html_erb___3771560638950630625_70345913460960'
  app/views/repositories/entry.html.erb:11:in `_app_views_repositories_entry_html_erb___25072457751040657_70345912345220'

With

require 'coderay/helpers/file_type'

everything works as expected.

Actions #14

Updated by Toshi MARUYAMA about 11 years ago

Bert Fraterman wrote:

We're running ruby 2.0.0, but the fix in r11925 causes a problem in displaying code files for us. We're getting a 500 error when trying to view file from the repository. Details:

[...]

With
[...]
everything works as expected.

I cannot reproduce on trunk r12297.

Started GET "/projects/redmine-bb-all/repository/entry/app/models/attachment.rb" for 127.0.0.1 at 2013-11-19 02:06:50 +0900
Processing by RepositoriesController#entry as HTML
  Parameters: {"id"=>"redmine-bb-all", "path"=>"app/models/attachment.rb"}
  Current user: anonymous
  Rendered repositories/_navigation.html.erb (424.2ms)
  Rendered repositories/_breadcrumbs.html.erb (3.7ms)
  Rendered repositories/_link_to_functions.html.erb (4.1ms)
  Rendered common/_file.html.erb (214.1ms)
  Rendered repositories/entry.html.erb within layouts/base (673.5ms)
Completed 200 OK in 1593.9ms (Views: 708.3ms | ActiveRecord: 5.8ms)

$ ruby --version
ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-linux]
Actions

Also available in: Atom PDF