Project

General

Profile

Actions

Defect #17898

closed

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

Added by Marc Waeckerlin over 10 years ago. Updated about 10 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 #1

Updated by Michael Esemplare about 10 years ago

That would not be the correct fix. The error is in the Time.at(:read_attribute) calls where it is returning nil.

The nil then being used in subtraction:

/usr/share/redmine/lib/tasks/migrate_from_trac.rake

def fake(time)
  @fake_diff = real_now - time #when time is nil it will raise an error
  res = yield
  @fake_diff = 0
 res
end

This is most likely related to the defect chain:

#14843, #10738, #6868, etc...

Marc if applicable you could try this patch #14567.

Actions #2

Updated by Marc Waeckerlin about 10 years ago

  • Status changed from New to Resolved

I have undone my change, that I've decribed above. Then downloaded and applied patch #14567 from http://www.redmine.org/attachments/download/10149/migrate_from_trac.rake.patch.txt

Result: Success! Thank you.

marc@dev0101:/usr/share/redmine/lib/tasks$ sudo patch < ~/downloads/migrate_from_trac.rake.patch.txt 
[sudo] password for marc: 
patching file migrate_from_trac.rake
marc@dev0101:/usr/share/redmine/lib/tasks$ cd /usr/share/redmine
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 []: ca

Trac database version is: 29
Migrating components...........
Migrating milestones..................
Migrating custom fields..........
Migrating tickets.......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
Migrating wiki...............................................................................................................................................................................................................................................................................................................

Components:      11/11
Milestones:      18/18
Tickets:         695/695
Ticket files:    0/111
Custom values:   5031/5031
Wiki edits:      303/303
Wiki files:      0/53
Actions #3

Updated by Toshi MARUYAMA about 10 years ago

  • Status changed from Resolved to Closed
  • Resolution set to Duplicate
Actions #4

Updated by Toshi MARUYAMA about 10 years ago

  • Is duplicate of Patch #14567: migrate_from_trac.rake does not convert timestamps in Trac database version 23 added
Actions

Also available in: Atom PDF