Error Trying to Start Import Process - Xenforo to Discourse


(Dylan) #1

Whenever I issue the command: RAILS_ENV=production bundle exec ruby script/import_scripts/xenforo.rb

I get:

/var/discourse/script/import_scripts/base.rb:14:in `require_relative': cannot load such file -- /var/discourse/config/environment (LoadError)
        from /var/discourse/script/import_scripts/base.rb:14:in `<top (required)>'
        from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
        from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
        from script/import_scripts/xenforo.rb:3:in `<main>'

or

script/import_scripts/xenforo.rb:1:in `require': cannot load such file -- mysql2 (LoadError)
        from script/import_scripts/xenforo.rb:1:in `<main>'

Been messing with the import process for a bit and am stumped, every time I find a solution to one aspect there seems to be another issues. Definitely not user friendly on imports yet. Hope to write a detailed step by step guide to importing Xenforo here for anyone that follows whenever I’m able to get it to work.

Xenforo Import Script: discourse/xenforo.rb at master · discourse/discourse · GitHub

If anyone knows which steps to follow to start the import process that would be helpful. I couldn’t find anything related to the xenforo import steps other than what’s in that script.


XenForo Import Failing (config/application.rb:2)
(Dylan) #3

@riking & @thefreekick – since you all posted on the other thread, any idea what the steps are to actually perform the migration? There is no documentation surrounding it and I’m just going further away from the solution at this point, it has to be simpler than this surely.

I created a brand new install on Ubuntu 14.04 LTS following the docker install guide, ensured it worked, have had trouble ever since trying to get the import script to run (entered my DB info, installed any related dependencies I found in other threads for other imports, etc) – I have no clue how to actually run the import and there isn’t really any steps outlined in any threads on here, at least not related to the xenforo import script.


(Dean Taylor) #4

Here is a #howto topic on importing from phpBB which might give you clues towards your target import:

There is also this more generic howto topic:


(Dylan) #5

Thanks, but I’ve gone through those as my main resource to figuring it out since it’s the only things really written about the imports here, not much of anything is written on the xenforo importer and nothing mentioning the solution to the issues I’m having with it so far. One person mentioned a somewhat similar issue but was never given an answer.

The only remotely viable solution / workaround I’ve seen is going from Xenforo > phpBB3 > Discourse, not only would that greatly lengthen the time it would take to migrate and possibly cause other issues, the only Xenforo > phpBB3 converter I found hasn’t been updated in years so likely isn’t even compatible. Which means I’d have to probably import it to another forum software, then import it to phpBB3, then import it to Discourse. At that point it wouldn’t be worth the time or effort, I would rather just spend that time optimizing Xenforo further.

Without being able to import the users, topics, and posts to Discourse we’re unable to switch over. We can’t start from scratch.


(Kane York) #6

I think you need to gem install mysql2 inside the container.

Make sure that you read this:

You’ll install stuff needed for the migration, then when it’s all done you rebuild the container and it’ll go away.


(Dylan) #7

mysql2 is installed in the container. The error OP is what I get if I try to run it outside of the container, the errors here are what I get when I enter “./launcher enter app”. I’m completely lost in this process.

When I enter: RAILS_ENV=production bundle exec ruby script/import_scripts/xenforo.rb

I get:

/usr/local/bin/ruby: No such file or directory -- /script/import_scripts/xenforo.rb (LoadError)

When I enter: ruby script/import_scripts/xenforo.rb

I get:

URGENT: FATAL:  Peer authentication failed for user "discourse"
 Failed to initialize site default
/usr/local/lib/ruby/gems/2.0.0/gems/activerecord-4.2.6/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `initialize': FATAL:  Peer authentication failed for user "discourse" (PG::ConnectionBad)
        from /usr/local/lib/ruby/gems/2.0.0/gems/activerecord-4.2.6/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `new'
        from /usr/local/lib/ruby/gems/2.0.0/gems/activerecord-4.2.6/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `connect'
        from /usr/local/lib/ruby/gems/2.0.0/gems/activerecord-4.2.6/lib/active_record/connection_adapters/postgresql_adapter.rb:242:in `initialize'
        from /usr/local/lib/ruby/gems/2.0.0/gems/activerecord-4.2.6/lib/active_record/connection_adapters/postgresql_adapter.rb:44:in `new'
        from /usr/local/lib/ruby/gems/2.0.0/gems/activerecord-4.2.6/lib/active_record/connection_adapters/postgresql_adapter.rb:44:in `postgresql_connection'
        from /usr/local/lib/ruby/gems/2.0.0/gems/activerecord-4.2.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:438:in `new_connection'
        from /usr/local/lib/ruby/gems/2.0.0/gems/activerecord-4.2.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:448:in `checkout_new_connection'
        from /usr/local/lib/ruby/gems/2.0.0/gems/activerecord-4.2.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:422:in `acquire_connection'
        from /usr/local/lib/ruby/gems/2.0.0/gems/activerecord-4.2.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:349:in `block in checkout'
        from /usr/local/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'
        from /usr/local/lib/ruby/gems/2.0.0/gems/activerecord-4.2.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:348:in `checkout'
        from /usr/local/lib/ruby/gems/2.0.0/gems/activerecord-4.2.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:263:in `block in connection'
        from /usr/local/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'
        from /usr/local/lib/ruby/gems/2.0.0/gems/activerecord-4.2.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:262:in `connection'
        from /usr/local/lib/ruby/gems/2.0.0/gems/activerecord-4.2.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:571:in `retrieve_connection'
        from /usr/local/lib/ruby/gems/2.0.0/gems/activerecord-4.2.6/lib/active_record/connection_handling.rb:113:in `retrieve_connection'
        from /usr/local/lib/ruby/gems/2.0.0/gems/activerecord-4.2.6/lib/active_record/connection_handling.rb:87:in `connection'
        from /usr/local/lib/ruby/gems/2.0.0/gems/activerecord-4.2.6/lib/active_record/model_schema.rb:230:in `table_exists?'
        from /usr/local/lib/ruby/gems/2.0.0/gems/activerecord-4.2.6/lib/active_record/attribute_methods/primary_key.rb:97:in `get_primary_key'
        from /usr/local/lib/ruby/gems/2.0.0/gems/activerecord-4.2.6/lib/active_record/attribute_methods/primary_key.rb:85:in `reset_primary_key'
        from /usr/local/lib/ruby/gems/2.0.0/gems/activerecord-4.2.6/lib/active_record/attribute_methods/primary_key.rb:73:in `primary_key'
        from /usr/local/lib/ruby/gems/2.0.0/gems/activerecord-4.2.6/lib/active_record/core.rb:132:in `find'
        from /var/www/discourse/script/import_scripts/base.rb:464:in `<class:Base>'
        from /var/www/discourse/script/import_scripts/base.rb:20:in `<top (required)>'
        from /usr/local/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
        from /usr/local/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
        from script/import_scripts/xenforo.rb:3:in `<main>'

(Jeff Atwood) #8

We are planning to write a Xenforo converter fairly soon, I was just talking to someone yesterday about starting that.


(Kane York) #9

Try this:

(cd /var/www/discourse && RAILS_ENV=production sudo -H -E -u discourse bundle exec ruby script/import_scripts/xenforo.rb)

based off discourse_docker/web.template.yml at master · discourse/discourse_docker · GitHub


(Dylan) #10

For some reason I get this error:

script/import_scripts/xenforo.rb:1:in `require': cannot load such file -- mysql2 (LoadError)
        from script/import_scripts/xenforo.rb:1:in `<main>'

Yet when I do “gem list” – it says mysql 2 is installed, and I even reinstalled it just to be sure.

A simpler way to import would be good, but if this one works for users, posts, topics, etc (the main aspects) then figuring out how to run it would be good enough for our migration at least.


(Kane York) #11

Ooooh, right - you need to add it to the Gemfile and bundle update.


(Dylan) #12

In the Gemfile in /var/discourse it says: gem ‘mysql2’

Ran bundle update, it finished and still have the same error when running the command. D:


(RoldanLT) #13

Is this issue still exist? How is the import from XenForo?


(Erlend Sogge Heggen) #14

If any questions are still pending, please re-post them in the context of this tutorial: