Project

General

Profile

Actions

Defect #17898

closed

Exception in Migration from Trac to Redmine (incl. solution)

Added by Marc Waeckerlin over 9 years ago. Updated over 9 years ago.

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

0%

Estimated time:
Resolution:
Duplicate
Affected version:

Description

Problem

I tried to migrate a project from trac to redmine, as described in RedmineMigrate.

It ends with the following exception:

marc@dev0101:/usr/share/redmine$ sudo rake --trace redmine:migrate_from_trac RAILS_ENV="production"      
** Invoke redmine:migrate_from_trac (first_time)                                                         
** Invoke environment (first_time)                                                                       
** Execute environment                                                                                   
** Execute redmine:migrate_from_trac                                                                     

WARNING: a new project will be added to Redmine during this process.                                     
Are you sure you want to continue ? [y/N] y                                                              

Trac directory []: /home/marc/trac/ca                                                                    
Trac database adapter (sqlite3, mysql2, postgresql) [sqlite3]:                                           
Trac database encoding [UTF-8]:                                                                          
Target project identifier []: certficates                                                                

Migrating components...........                                                                          
Migrating milestones..................                                                                   
Migrating custom fields..........                                                                        
Migrating tickets.......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................                       
Migrating wiki...............................................................................................................................................................................................................................................................................................................rake aborted!                                                                                          
can't convert nil into an exact number                                                                   
/usr/lib/ruby/vendor_ruby/active_support/core_ext/time/calculations.rb:339:in `-'                        
/usr/lib/ruby/vendor_ruby/active_support/core_ext/time/calculations.rb:339:in `minus_with_duration'
/usr/lib/ruby/vendor_ruby/active_support/core_ext/time/calculations.rb:350:in `minus_with_coercion'
/usr/share/redmine/lib/tasks/migrate_from_trac.rake:79:in `fake'
/usr/share/redmine/lib/tasks/migrate_from_trac.rake:590:in `block in migrate'
/usr/lib/ruby/vendor_ruby/active_record/associations/collection_proxy.rb:91:in `each'
/usr/lib/ruby/vendor_ruby/active_record/associations/collection_proxy.rb:91:in `method_missing'
/usr/share/redmine/lib/tasks/migrate_from_trac.rake:588:in `migrate'
/usr/share/redmine/lib/tasks/migrate_from_trac.rake:776:in `block (2 levels) in <top (required)>'
/usr/lib/ruby/vendor_ruby/rake/task.rb:246:in `call'
/usr/lib/ruby/vendor_ruby/rake/task.rb:246:in `block in execute'
/usr/lib/ruby/vendor_ruby/rake/task.rb:241:in `each'
/usr/lib/ruby/vendor_ruby/rake/task.rb:241:in `execute'
/usr/lib/ruby/vendor_ruby/rake/task.rb:184:in `block in invoke_with_call_chain'
/usr/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/usr/lib/ruby/vendor_ruby/rake/task.rb:177:in `invoke_with_call_chain'
/usr/lib/ruby/vendor_ruby/rake/task.rb:170:in `invoke'
/usr/lib/ruby/vendor_ruby/rake/application.rb:143:in `invoke_task'
/usr/lib/ruby/vendor_ruby/rake/application.rb:101:in `block (2 levels) in top_level'
/usr/lib/ruby/vendor_ruby/rake/application.rb:101:in `each'
/usr/lib/ruby/vendor_ruby/rake/application.rb:101:in `block in top_level'
/usr/lib/ruby/vendor_ruby/rake/application.rb:110:in `run_with_threads'
/usr/lib/ruby/vendor_ruby/rake/application.rb:95:in `top_level'
/usr/lib/ruby/vendor_ruby/rake/application.rb:73:in `block in run'
/usr/lib/ruby/vendor_ruby/rake/application.rb:160:in `standard_exception_handling'
/usr/lib/ruby/vendor_ruby/rake/application.rb:70:in `run'
/usr/bin/rake:27:in `<main>'
Tasks: TOP => redmine:migrate_from_trac
marc@dev0101:/usr/share/redmine$ sudo emacs +339 /usr/lib/ruby/vendor_ruby/active_support/core_ext/time/calculations.rb
marc@dev0101:/usr/share/redmine$ sudo emacs +339 /usr/lib/ruby/vendor_ruby/active_support/core_ext/time/calculations.rb +79 /usr/share/redmine/lib/tasks/migrate_from_trac.rake

Solution

Obviousely, a time-object is undefined (nil). Although I have no idea of Ruby, after some analysis, I changed function minus_with_coercion in file /usr/lib/ruby/vendor_ruby/active_support/core_ext/time/calculations.rb around line 350 as follows:

  def minus_with_coercion(other)
    other = other.comparable_time if other.respond_to?(:comparable_time)
    if other === nil
      to_f
    else
      other.is_a?(DateTime) ? to_f - other.to_f : minus_without_coercion(other)
    end
  end

So if other is nil, to_f is returned.

Please adapt this bugfix for next release.


Related issues

Is duplicate of Redmine - Patch #14567: migrate_from_trac.rake does not convert timestamps in Trac database version 23New

Actions
Actions

Also available in: Atom PDF