Error Trying to Start Import Process - Xenforo to Discourse

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: https://github.com/discourse/discourse/blob/master/script/import_scripts/xenforo.rb

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.

@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.

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:

1 Like

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.

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

Make sure that you read this:
https://meta.discourse.org/t/advanced-troubleshooting-with-docker/15927

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

2 Likes

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>'

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

1 Like

Try this:

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

based off https://github.com/discourse/discourse_docker/blob/master/templates/web.template.yml#L168

2 Likes

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.

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

1 Like

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:

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

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