Project

General

Profile

Actions

Defect #12590

closed

Plugin routes.rb files are not getting included on Windows

Added by Stefan Mueller about 12 years ago. Updated over 10 years ago.

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

0%

Estimated time:
Resolution:
Cant reproduce
Affected version:

Description

Don't know if this is a new defect, the only defect I found similar has been #11609.
Routes.rb of plugins do not get processed, as a loop in routes.rb of Redmine does not read include them.

In short: Ruby 1.9.3, RubyGems 1.8.24, Rails 3.2.8, development and production, Windows 2012 Standard Server
See rake about and gem list attached for more Information.

I narrowed the issue down to a problem with the routes.rb file of Redmine.
On the bottom of the file there is some logic that does a Dir.glob(File.join(...)) and processes the directories within a loop.
Unfortunately only one iteration is done in this loop, thus only <REDMINE_ROOT>\plugins\.\routes.rb is being examined by File.exists.

I rewrote the loop now all plugins are loading correctly, and the controllers are getting mapped.

  plugin_root = File.join(Rails.root, "plugins")

  Dir.foreach(File.join(plugin_root) do |plugin_dir|
    next if plugin_dir == '.' or plugin_dir == '..'

    file = File.join(plugin_root, plugin_dir, "config/routes.rb")    

    if File.exists?(file)    
      begin
        Rails.logger.info 'Loading plugin routes from ' + file
        instance_eval File.read(file)
      rescue Exception => e
        puts "An error occurred while loading the routes definition of #{File.basename(plugin_dir)} plugin (#{file}): #{e.message}." 
        exit 1
      end
    end
  end


Files

rack.about.TXT (1.17 KB) rack.about.TXT rack about Stefan Mueller, 2012-12-14 00:38
gems.txt (1.04 KB) gems.txt gem list Stefan Mueller, 2012-12-14 00:38
about.TXT (413 Bytes) about.TXT ruby/scripts about Stefan Mueller, 2012-12-14 00:38

Related issues

Related to Redmine - Patch #12790: ActionController::RoutingError. No route matches for any installed plugins in Redmine 2.1.5.stableClosed

Actions
Related to Redmine - Defect #11609: Override redmine routes.rb in a plugin in redmine 2.xClosedJean-Baptiste Barth

Actions
Actions #1

Updated by Stefan Mueller about 12 years ago

sorry typo in code block.

  plugin_root = File.join(Rails.root, "plugins")

  Dir.foreach(plugin_root) do |plugin_dir|
    next if plugin_dir == '.' or plugin_dir == '..'

    file = File.join(plugin_root, plugin_dir, "config/routes.rb")    

    if File.exists?(file)    
      begin
        Rails.logger.info 'Loading plugin routes from ' + file
        instance_eval File.read(file)
      rescue Exception => e
        puts "An error occurred while loading the routes definition of #{File.basename(plugin_dir)} plugin (#{file}): #{e.message}." 
        exit 1
      end
    end
  end

Actions #2

Updated by Jean-Philippe Lang about 12 years ago

  • Resolution set to Cant reproduce

Stefan Mueller wrote:

I narrowed the issue down to a problem with the routes.rb file of Redmine.
On the bottom of the file there is some logic that does a Dir.glob(File.join(...)) and processes the directories within a loop.
Unfortunately only one iteration is done in this loop, thus only <REDMINE_ROOT>\plugins\.\routes.rb is being examined by File.exists.

I just made the test with 2 plugins under Windows 7. The routes of both plugins are loaded just fine.

Actions #3

Updated by Logan Raarup about 12 years ago

Hi,
This issue seems to be related with a bug in File.expand_path: http://bugs.ruby-lang.org/issues/7374

Actions #4

Updated by Jean-Baptiste Barth over 10 years ago

  • Status changed from New to Closed
  • Assignee set to Jean-Baptiste Barth

Unable to reproduce on Windows XP too. I close the issue for now but encourage anybody who might experience it to reopen and comment with all details (especially ruby version, and informations about the operating system).

Actions

Also available in: Atom PDF