trac to redmine migration problem
Added by Daniel Lee over 13 years ago
My system:
Environment:
  Redmine version                          2.0.2.stable
  Ruby version                             1.9.3 (x86_64-linux)
  Rails version                            3.2.5
  Environment                              production
  Database adapter                         Mysql2
Redmine plugins:
  no plugin installed
Running on ubuntu 12.04 lts.
Alright, so I have a problem. I'm running the trac to redmine migration script and it's dying in the middle of migrating the tickets, complaining about a problem with an Integer.
/opt/redmine$ sudo rake redmine:migrate_from_trac RAILS_ENV=production --trace- 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/test/tracbak
Trac database adapter (sqlite3, mysql2, postgresql) [sqlite3]: 
Trac database encoding [UTF-8]: 
Target project identifier []: myproject2
Migrating components......................
Migrating milestones...................................
Migrating custom fields.
Migrating tickets..................................rake aborted!
invalid value for Integer(): " "
/opt/redmine/lib/tasks/migrate_from_trac.rake:156:in `sprintf'
/opt/redmine/lib/tasks/migrate_from_trac.rake:156:in `block in trac_fullpath'
/opt/redmine/lib/tasks/migrate_from_trac.rake:156:in `gsub'
/opt/redmine/lib/tasks/migrate_from_trac.rake:156:in `trac_fullpath'
/opt/redmine/lib/tasks/migrate_from_trac.rake:135:in `exist?'
/opt/redmine/lib/tasks/migrate_from_trac.rake:519:in `block (2 levels) in migrate'
/opt/redmine/lib/tasks/migrate_from_trac.rake:518:in `each'
/opt/redmine/lib/tasks/migrate_from_trac.rake:518:in `block in migrate'
/var/lib/gems/1.9.1/gems/activerecord-3.2.5/lib/active_record/relation/batches.rb:21:in `block (2 levels) in find_each'
/var/lib/gems/1.9.1/gems/activerecord-3.2.5/lib/active_record/relation/batches.rb:21:in `each'
/var/lib/gems/1.9.1/gems/activerecord-3.2.5/lib/active_record/relation/batches.rb:21:in `block in find_each'
/var/lib/gems/1.9.1/gems/activerecord-3.2.5/lib/active_record/relation/batches.rb:72:in `find_in_batches'
/var/lib/gems/1.9.1/gems/activerecord-3.2.5/lib/active_record/relation/batches.rb:20:in `find_each'
/var/lib/gems/1.9.1/gems/activerecord-3.2.5/lib/active_record/querying.rb:8:in `find_each'
/opt/redmine/lib/tasks/migrate_from_trac.rake:465:in `migrate'
/opt/redmine/lib/tasks/migrate_from_trac.rake:769:in `block (2 levels) in <top (required)>'
/var/lib/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `call'
/var/lib/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `block in execute'
/var/lib/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `each'
/var/lib/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `execute'
/var/lib/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain'
/usr/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/var/lib/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/var/lib/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke'
/var/lib/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:116:in `invoke_task'
/var/lib/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block (2 levels) in top_level'
/var/lib/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `each'
/var/lib/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block in top_level'
/var/lib/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/var/lib/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:88:in `top_level'
/var/lib/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:66:in `block in run'
/var/lib/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/var/lib/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
/var/lib/gems/1.9.1/gems/rake-0.9.2.2/bin/rake:33:in `<top (required)>'
/usr/local/bin/rake:19:in `load'
/usr/local/bin/rake:19:in `<main>'
Tasks: TOP => redmine:migrate_from_trac
No idea what's going wrong here, can anyone point me to a solution to this problem?
Replies (5)
    
    RE: trac to redmine migration problem
    -
    Added by Daniel Lee over 13 years ago
  
  It looks like the code in the libs/tasks/migrate_from_trac.rake file is where it's trying to get information about attachments.
And it looks like the ticket migration is halting at the first ticket where there is an attachment...
any ideas on how to fix this?
    
    RE: trac to redmine migration problem
    -
    Added by Daniel Lee over 13 years ago
  
  Does anyone know how I can fix this problem? the affected code is in that rake file is trying to determine a file name, but the trac file names are all encoded since they are URL friendly, so i imagine that's why it's not working. any thoughts or ideas would be great.
    
    RE: trac to redmine migration problem
    -
    Added by Daniel Lee over 13 years ago
  
  This is the offending code, the sprintf is apparently where it is saying invalid value for Integer(): " "
private
        def trac_fullpath
          attachment_type = read_attribute(:type)
          trac_file = filename.gsub( /[^a-zA-Z0-9\-_\.!~*']/n ) {|x| sprintf('%%%02x', x[0]) }
          "#{TracMigrate.trac_attachments_directory}/#{attachment_type}/#{id}/#{trac_file}" 
        end
      end
	does anyone have any idea what the trac_file = filename....... line is doing?
    
    RE: trac to redmine migration problem
    -
    Added by Keats . over 13 years ago
  
  hi, 
changing the line did the trick for me
#trac_file = filename.gsub( /[^a-zA-Z0-9\-_\.!~*']/n ) {|x| sprintf('%%%02x', x[0]) }
trac_file = filename
    
    RE: trac to redmine migration problem
    -
    Added by Jean-Baptiste Barth over 12 years ago
  
  A bit late but it might be fixed now on trunk, see: http://www.redmine.org/issues/13990