Defect #32110

"already initialized constant Redmine::Scm::Adapters::SubversionAdapter::SVN_BIN" warning when executing rake tasks

Added by Go MAEDA 24 days ago. Updated 12 days ago.

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

0%

Category:Code cleanup/refactoring
Target version:4.0.5
Resolution:Fixed Affected version:

Description

$ bin/rails db:fixtures:load
/Users/maeda/redmines/redmine-trunk/lib/redmine/scm/adapters/subversion_adapter.rb:29: warning: already initialized constant Redmine::Scm::Adapters::SubversionAdapter::SVN_BIN
/Users/maeda/redmines/redmine-trunk/lib/redmine/scm/adapters/subversion_adapter.rb:29: warning: previous definition of SVN_BIN was here

Related issues

Related to Redmine - Defect #28920: Redmine::VERSION::revision should take subversion_command... Closed

Associated revisions

Revision 18589
Added by Go MAEDA 13 days ago

Fix "already initialized constant Redmine::Scm::Adapters::SubversionAdapter::SVN_BIN" warning when executing rake tasks (#32110).

Patch by Go MAEDA.

Revision 18591
Added by Go MAEDA 12 days ago

Merged r18589 from trunk to 4.0-stable (#32110).

History

#1 Updated by Go MAEDA 24 days ago

I found that the following change fixes the warning.

diff --git a/app/models/repository/bazaar.rb b/app/models/repository/bazaar.rb
index 8b07db34d..f7ad5b62c 100644
--- a/app/models/repository/bazaar.rb
+++ b/app/models/repository/bazaar.rb
@@ -17,7 +17,7 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

-require 'redmine/scm/adapters/bazaar_adapter'
+# require 'redmine/scm/adapters/bazaar_adapter'

 class Repository::Bazaar < Repository
   validates_presence_of :url, :log_encoding
diff --git a/app/models/repository/cvs.rb b/app/models/repository/cvs.rb
index e823275e4..03d57549d 100644
--- a/app/models/repository/cvs.rb
+++ b/app/models/repository/cvs.rb
@@ -17,7 +17,7 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

-require 'redmine/scm/adapters/cvs_adapter'
+# require 'redmine/scm/adapters/cvs_adapter'
 require 'digest/sha1'

 class Repository::Cvs < Repository
diff --git a/app/models/repository/filesystem.rb b/app/models/repository/filesystem.rb
index 5d823b9f4..51a93dfa1 100644
--- a/app/models/repository/filesystem.rb
+++ b/app/models/repository/filesystem.rb
@@ -20,7 +20,7 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

-require 'redmine/scm/adapters/filesystem_adapter'
+# require 'redmine/scm/adapters/filesystem_adapter'

 class Repository::Filesystem < Repository
   validates_presence_of :url
diff --git a/app/models/repository/git.rb b/app/models/repository/git.rb
index 839a26676..b367fe06e 100644
--- a/app/models/repository/git.rb
+++ b/app/models/repository/git.rb
@@ -18,7 +18,7 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

-require 'redmine/scm/adapters/git_adapter'
+# require 'redmine/scm/adapters/git_adapter'

 class Repository::Git < Repository
   validates_presence_of :url
diff --git a/app/models/repository/mercurial.rb b/app/models/repository/mercurial.rb
index 69f7bebdc..ac2921ccc 100644
--- a/app/models/repository/mercurial.rb
+++ b/app/models/repository/mercurial.rb
@@ -17,7 +17,7 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

-require 'redmine/scm/adapters/mercurial_adapter'
+# require 'redmine/scm/adapters/mercurial_adapter'

 class Repository::Mercurial < Repository
   # sort changesets by revision number
diff --git a/app/models/repository/subversion.rb b/app/models/repository/subversion.rb
index 0f01f863f..8e7962cd5 100644
--- a/app/models/repository/subversion.rb
+++ b/app/models/repository/subversion.rb
@@ -17,7 +17,7 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

-require 'redmine/scm/adapters/subversion_adapter'
+# require 'redmine/scm/adapters/subversion_adapter'

 class Repository::Subversion < Repository
   validates_presence_of :url

#2 Updated by Go MAEDA 14 days ago

The warning can be observed only when the current directory is a working copy of the Subversion repo. It means that you obtained the source code of Redmine using "svn" command.

#3 Updated by Go MAEDA 14 days ago

It is caused by r17407. Reverting the change fixes the issue.

#4 Updated by Go MAEDA 14 days ago

  • Related to Defect #28920: Redmine::VERSION::revision should take subversion_command setting into account added

#5 Updated by Go MAEDA 14 days ago

Here is a workaround.

diff --git a/lib/redmine/version.rb b/lib/redmine/version.rb
index 8272e29e4..2fe75c55e 100644
--- a/lib/redmine/version.rb
+++ b/lib/redmine/version.rb
@@ -1,6 +1,7 @@
 # frozen_string_literal: true

 require 'rexml/document'
+require 'redmine/scm/adapters/subversion_adapter'

 module Redmine
   # @private

Calling Redmine::Scm::Adapters::SubversionAdapter.client_command before requiring redmine/scm/adapters/subversion_adapter in the development mode gets the warning.

$ bin/rails c
Loading development environment (Rails 5.2.3)
[1] pry(main)> Redmine::Scm::Adapters::SubversionAdapter.client_command
=> "/usr/local/bin/svn" 
[2] pry(main)> require 'redmine/scm/adapters/subversion_adapter'
/Users/maeda/redmines/redmine-trunk/lib/redmine/scm/adapters/subversion_adapter.rb:29: warning: already initialized constant Redmine::Scm::Adapters::SubversionAdapter::SVN_BIN
/Users/maeda/redmines/redmine-trunk/lib/redmine/scm/adapters/subversion_adapter.rb:29: warning: previous definition of SVN_BIN was here
=> true
[3] pry(main)>

#6 Updated by Go MAEDA 14 days ago

  • Subject changed from "already initialized constant" warning when executing rake tasks to "already initialized constant Redmine::Scm::Adapters::SubversionAdapter::SVN_BIN" warning when executing rake tasks
  • Category set to Code cleanup/refactoring

#7 Updated by Go MAEDA 14 days ago

  • Target version set to Candidate for next minor release

#8 Updated by Go MAEDA 13 days ago

  • Target version changed from Candidate for next minor release to 4.0.5

Setting the target version to 4.0.5.

The patch to commit: #32110#note-5

#9 Updated by Go MAEDA 13 days ago

  • Status changed from New to Resolved
  • Assignee set to Go MAEDA
  • Resolution set to Fixed

Committed the fix.

#10 Updated by Go MAEDA 12 days ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF