# Error Trying to Start Import Process - Xenforo to Discourse

**URL:** https://meta.discourse.org/t/error-trying-to-start-import-process-xenforo-to-discourse/43258
**Category:** Migration
**Created:** [Avril 26, 2016, 5:35 UTC](https://meta.discourse.org/t/error-trying-to-start-import-process-xenforo-to-discourse/43258 "2016-04-26T17:35:11Z")
**Posts on this page:** 13
**Page:** 1

<div class="post-metadata">

### Author: ![Overmind](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/overmind/32/55446_2.png) [@Overmind](https://meta.discourse.org/u/Overmind)
#### Post date: [Avril 26, 2016, 5:35 UTC](https://meta.discourse.org/t/error-trying-to-start-import-process-xenforo-to-discourse/43258/1 "2016-04-26T17:35:11Z")

</div>

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/script/import\_scripts/xenforo.rb at main · discourse/discourse · GitHub](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.

---

<div class="post-metadata">

### Author: ![Overmind](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/overmind/32/55446_2.png) [@Overmind](https://meta.discourse.org/u/Overmind)
#### Post date: [Avril 27, 2016, 12:46 UTC](https://meta.discourse.org/t/error-trying-to-start-import-process-xenforo-to-discourse/43258/3 "2016-04-27T00:46:45Z")

</div>

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

---

<div class="post-metadata">

### Author: ![DeanMarkTaylor](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/deanmarktaylor/32/102462_2.png) [@DeanMarkTaylor](https://meta.discourse.org/u/DeanMarkTaylor)
#### Post date: [Avril 27, 2016, 1:02 UTC](https://meta.discourse.org/t/error-trying-to-start-import-process-xenforo-to-discourse/43258/4 "2016-04-27T01:02:17Z")

</div>

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

> [@Migrate a phpBB3 forum to Discourse](https://meta.discourse.org/t/importing-from-phpbb3/30810):
>
> So, you discovered Discourse and want to know how to migrate from your existing phpBB3 forum? Great! Then keep on reading. This guide will show you how to use the [phpBB3 import script](https://github.com/discourse/discourse/blob/main/script/import_scripts/phpbb3.rb) for importing from phpBB 3.0 up to 3.3. What data can be imported? Users Avatars (optional) Anonymous users (either as user “system” or as suspended users) Password hashes, which can be used with the [migratepassword plugin](https://github.com/communiteq/discourse-migratepassword) (optional) User profile data (birth date, website, location, custom fields, etc.) G…

There is also this more generic howto topic:

> [@Migrate from another forum to Discourse](https://meta.discourse.org/t/migrating-to-discourse-from-another-forum-software/16616):
>
> mega This guide serves as a high level overview of the migration process. For specifics on the wide range of forum softwares to import, including Vanilla, phpBB3, SMF2, bbPress, and vBulletin, review our [dedicated tutorials](https://meta.discourse.org/tags/c/documentation/10/migrations). Not all scripts have tutorials, but an exhaustive list of available imports is available under the [script/import\_scripts](https://github.com/discourse/discourse/tree/main/script/import_scripts) folder on GitHub. For larger migrations, there is also a faster [script/bulk\_import](https://github.com/discourse/discourse/tree/main/script/bulk_import) system that writes directly to the database. So you want to mi…

---

<div class="post-metadata">

### Author: ![Overmind](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/overmind/32/55446_2.png) [@Overmind](https://meta.discourse.org/u/Overmind)
#### Post date: [Avril 27, 2016, 2:08 UTC](https://meta.discourse.org/t/error-trying-to-start-import-process-xenforo-to-discourse/43258/5 "2016-04-27T02:08:01Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![riking](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riking/32/170938_2.png) [@riking](https://meta.discourse.org/u/riking)
#### Post date: [Avril 27, 2016, 2:23 UTC](https://meta.discourse.org/t/error-trying-to-start-import-process-xenforo-to-discourse/43258/6 "2016-04-27T02:23:04Z")

</div>

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](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.

---

<div class="post-metadata">

### Author: ![Overmind](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/overmind/32/55446_2.png) [@Overmind](https://meta.discourse.org/u/Overmind)
#### Post date: [Avril 27, 2016, 2:39 UTC](https://meta.discourse.org/t/error-trying-to-start-import-process-xenforo-to-discourse/43258/7 "2016-04-27T02:39:25Z")

</div>

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

```

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [Avril 27, 2016, 3:01 UTC](https://meta.discourse.org/t/error-trying-to-start-import-process-xenforo-to-discourse/43258/8 "2016-04-27T03:01:08Z")

</div>

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

---

<div class="post-metadata">

### Author: ![riking](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riking/32/170938_2.png) [@riking](https://meta.discourse.org/u/riking)
#### Post date: [Avril 27, 2016, 3:55 UTC](https://meta.discourse.org/t/error-trying-to-start-import-process-xenforo-to-discourse/43258/9 "2016-04-27T03:55:03Z")

</div>

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/templates/web.template.yml at master · discourse/discourse\_docker · GitHub](https://github.com/discourse/discourse_docker/blob/master/templates/web.template.yml#L168)

---

<div class="post-metadata">

### Author: ![Overmind](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/overmind/32/55446_2.png) [@Overmind](https://meta.discourse.org/u/Overmind)
#### Post date: [Avril 27, 2016, 4:32 UTC](https://meta.discourse.org/t/error-trying-to-start-import-process-xenforo-to-discourse/43258/10 "2016-04-27T04:32:46Z")

</div>

> [@riking](#):
>
> 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/templates/web.template.yml at master · discourse/discourse\_docker · GitHub](https://github.com/discourse/discourse_docker/blob/master/templates/web.template.yml#L168)

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.

> [@codinghorror](#):
>
> We are planning to write a Xenforo converter fairly soon, I was just talking to someone yesterday about starting that.

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.

---

<div class="post-metadata">

### Author: ![riking](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riking/32/170938_2.png) [@riking](https://meta.discourse.org/u/riking)
#### Post date: [Avril 27, 2016, 4:39 UTC](https://meta.discourse.org/t/error-trying-to-start-import-process-xenforo-to-discourse/43258/11 "2016-04-27T04:39:14Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Overmind](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/overmind/32/55446_2.png) [@Overmind](https://meta.discourse.org/u/Overmind)
#### Post date: [Avril 27, 2016, 4:42 UTC](https://meta.discourse.org/t/error-trying-to-start-import-process-xenforo-to-discourse/43258/12 "2016-04-27T04:42:46Z")

</div>

> [@riking](#):
>
> Ooooh, right - you need to add it to the Gemfile and bundle update.

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:

---

<div class="post-metadata">

### Author: ![RoldanLT](https://avatars.discourse-cdn.com/v4/letter/r/da6949/32.png) [@RoldanLT](https://meta.discourse.org/u/RoldanLT)
#### Post date: [Novembre 20, 2016, 10:44 UTC](https://meta.discourse.org/t/error-trying-to-start-import-process-xenforo-to-discourse/43258/13 "2016-11-20T22:44:59Z")

</div>

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

---

<div class="post-metadata">

### Author: ![erlend\_sh](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/erlend_sh/32/119475_2.png) [@erlend\_sh](https://meta.discourse.org/u/erlend_sh)
#### Post date: [Novembre 21, 2016, 1:51 UTC](https://meta.discourse.org/t/error-trying-to-start-import-process-xenforo-to-discourse/43258/14 "2016-11-21T13:51:39Z")

</div>

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

> [@Migrate a XenForo forum to Discourse](https://meta.discourse.org/t/importing-xenforo-to-discourse/45232):
>
> Hey guys so after trying for a week or so I decided to import the database on docker app which I hoped it will succeed without any issues. TBH I got some issues at first but it turned to be all easy to solve. Now I would recommend doing this only once before you deploy your production site, after importing everything take a Discourse backup, wipe everything out and install new Discourse instance then restore the imported db. Ok let’s begin: First lets backup your old database from your old …
