プロジェクト

全般

プロフィール

Vote #73714

完了

warning: already initialized constant on Ruby 1.8.7

Admin Redmine さんが3年以上前に追加. 3年以上前に更新.

ステータス:
Closed
優先度:
低め
担当者:
-
カテゴリ:
Ruby support_33
対象バージョン:
開始日:
2022/05/09
期日:
進捗率:

0%

予定工数:
category_id:
33
version_id:
72
issue_org_id:
13692
author_id:
58318
assigned_to_id:
0
comments:
14
status_id:
5
tracker_id:
1
plus1:
0
affected_version:
closed_on:
affected_version_id:
60
ステータス-->[Closed]

説明

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


journals

Have the same Issue with Version 2.3.1

Every runner-scripts produces warnings. The Apache log is is also flooded with these messages .....
<pre>
/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
</pre>

--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
My redmine, http://elastos.org/project/ has the same Issue.
<pre>
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
</pre>
--------------------------------------------------------------------------------
Same issue in 2.3.1

<pre>
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
</pre>
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
Hi all,

I had the same issue and I could fix it by commenting the line 36 <pre>require 'coderay/helpers/file_type'</pre> 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 ;)
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------

--------------------------------------------------------------------------------

--------------------------------------------------------------------------------

--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
Committed in trunk r11925 and 2.3-stable r11929, thanks.
--------------------------------------------------------------------------------
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:

<pre>
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'
</pre>

With
<pre>
require 'coderay/helpers/file_type'
</pre>
everything works as expected.
--------------------------------------------------------------------------------
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.

<pre>
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)

</pre>

<pre>
$ ruby --version
ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-linux]
</pre>

--------------------------------------------------------------------------------

Admin Redmine さんが3年以上前に更新

  • カテゴリRuby support_33 にセット
  • 対象バージョン2.3.2_72 にセット

他の形式にエクスポート: Atom PDF

いいね!0
いいね!0