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

**URL:** https://meta.discourse.org/t/xenforo-import-failing-config-application-rb-2/50049
**Category:** Support
**Created:** [12.Сентябрь.2016 23:47:35 UTC](https://meta.discourse.org/t/xenforo-import-failing-config-application-rb-2/50049 "2016-09-12T23:47:35Z")
**Posts on this page:** 17
**Page:** 1

<div class="post-metadata">

### Author: ![Padraig](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/padraig/32/121553_2.png) [@Padraig](https://meta.discourse.org/u/Padraig)
#### Post date: [12.Сентябрь.2016 23:47:35 UTC](https://meta.discourse.org/t/xenforo-import-failing-config-application-rb-2/50049/1 "2016-09-12T23:47:35Z")

</div>

Hi everyone.

Just got Discourse set up and now I am attempting to import my content from my XenForo Database

Follow this guide, I get to Step 11 - [Migrate a XenForo forum to Discourse](https://meta.discourse.org/t/importing-xenforo-to-discourse/45232)

> You are set to go now, run the importer:  
> `bundle exec script/import_scripts/xenforo.rb`

and I get the following:

```plaintext
root@titan-app:/var/www/discourse > RAILS_ENV=production bundle exec ruby script/import_scripts/xenforo.rb
/var/www/discourse/config/application.rb:2:in `require': cannot load such file -- rails/all (LoadError)
        from /var/www/discourse/config/application.rb:2:in `<top (required)>'
        from /var/www/discourse/config/environment.rb:2:in `require'
        from /var/www/discourse/config/environment.rb:2:in `<top (required)>'
        from /var/www/discourse/script/import_scripts/base.rb:14:in `require_relative'
        from /var/www/discourse/script/import_scripts/base.rb:14:in `<top (required)>'
        from script/import_scripts/xenforo.rb:3:in `require'
        from script/import_scripts/xenforo.rb:3:in `<main>'

```

It looks to be the same error as this thread: [Error Trying to Start Import Process - Xenforo to Discourse](https://meta.discourse.org/t/error-trying-to-start-import-process-xenforo-to-discourse/43258) but it devolves into nothing.

Can anyone shed some light as to what I might be doing wrong or is there any issue with the import script for XF?

Kind regards,

---

<div class="post-metadata">

### Author: ![mpalmer](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mpalmer/32/45740_2.png) [@mpalmer](https://meta.discourse.org/u/mpalmer)
#### Post date: [12.Сентябрь.2016 23:50:18 UTC](https://meta.discourse.org/t/xenforo-import-failing-config-application-rb-2/50049/2 "2016-09-12T23:50:18Z")

</div>

That sounds like you don’t have all the gems installed; what does `bundle show railties` say?

---

<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: [13.Сентябрь.2016 05:10:26 UTC](https://meta.discourse.org/t/xenforo-import-failing-config-application-rb-2/50049/3 "2016-09-13T05:10:26Z")

</div>

You’re not using the discourse account. Run `cat `which rails` ` and copy the `sudo` command line out of that file.

---

<div class="post-metadata">

### Author: ![Padraig](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/padraig/32/121553_2.png) [@Padraig](https://meta.discourse.org/u/Padraig)
#### Post date: [13.Сентябрь.2016 06:17:13 UTC](https://meta.discourse.org/t/xenforo-import-failing-config-application-rb-2/50049/4 "2016-09-13T06:17:13Z")

</div>

Hey guys, thanks for getting back to me on this issue!

> [@mpalmer](#):
>
> That sounds like you don’t have all the gems installed; what does bundle show railties say?

```plaintext
root@titan-app:/var/www/discourse> bundle show railties
Could not find gem 'railties'.

```

I will admit, I installed the `railties` gem and then re-ran the above command and got the same result.

> [@riking](#):
>
> You’re not using the discourse account. Run cat `which rails` and copy the sudo command line out of that file.

```plaintext
root@titan-app:/var/www/discourse> cat `which rails`
#!/usr/local/bin/ruby
#
# This file was generated by RubyGems.
#
# The application 'railties' is installed as part of a gem, and
# this file is here to facilitate running it.
#

require 'rubygems'

version = ">= 0.a"

if ARGV.first
  str = ARGV.first
  str = str.dup.force_encoding("BINARY") if str.respond_to? :force_encoding
  if str =~ /\A_(.*)_\z/ and Gem::Version.correct?($1) then
    version = $1
    ARGV.shift
  end
end

gem 'railties', version
load Gem.bin_path('railties', 'rails', version)

```

(Note, I got the same result under the ‘discourse’ user)

Maybe I botched something?

---

<div class="post-metadata">

### Author: ![mpalmer](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mpalmer/32/45740_2.png) [@mpalmer](https://meta.discourse.org/u/mpalmer)
#### Post date: [13.Сентябрь.2016 06:46:03 UTC](https://meta.discourse.org/t/xenforo-import-failing-config-application-rb-2/50049/5 "2016-09-13T06:46:03Z")

</div>

Well, that’s rather strange. What did the `bundle install --no-deployment` step print when you ran it?

---

<div class="post-metadata">

### Author: ![Padraig](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/padraig/32/121553_2.png) [@Padraig](https://meta.discourse.org/u/Padraig)
#### Post date: [13.Сентябрь.2016 07:01:11 UTC](https://meta.discourse.org/t/xenforo-import-failing-config-application-rb-2/50049/6 "2016-09-13T07:01:11Z")

</div>

Hi Matt, this is what I got. Should I be running this as the `root` user within the container or the `discourse` user?

```plaintext
root@titan-app:/var/www/discourse# bundle install --no-deployment
Don't run Bundler as root. Bundler can ask for sudo if it is needed, and installing your bundle as root will break this application for all non-root users on this machine.
Using mysql2 0.4.4
Using bundler 1.13.0
Bundle complete! 1 Gemfile dependency, 2 gems now installed.
Gems in the group development were not installed.
Use `bundle show [gemname]` to see where a bundled gem is installed.

root@titan-app:/var/www/discourse# bundle show railties
Could not find gem 'railties'.

```

Kind regards,

---

<div class="post-metadata">

### Author: ![Padraig](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/padraig/32/121553_2.png) [@Padraig](https://meta.discourse.org/u/Padraig)
#### Post date: [13.Сентябрь.2016 08:48:52 UTC](https://meta.discourse.org/t/xenforo-import-failing-config-application-rb-2/50049/7 "2016-09-13T08:48:52Z")

</div>

I think I may be onto something here.

In Step 8 of this tutorial: [Migrate a XenForo forum to Discourse](https://meta.discourse.org/t/importing-xenforo-to-discourse/45232) , it says to run `echo "gem 'mysql2'" >Gemfile`

I looked in the `Gemfile` only to see this in the file:

```plaintext
gem 'mysql2'

```

So I went to GitHub and got the latest `Gemfile` and I added the `gem 'mysql2'` to the file.

Ran `bundle install --no-deployment` and it installed a BUNCH of stuff (Too many to copy and paste here) (Side note: Do not use tmux and go into the container..it didn’t work at all 😛 )

But it ended with this:

```plaintext
Bundle complete! 100 Gemfile dependencies, 180 gems now installed.
Gems in the group development were not installed.
Use `bundle show [gemname]` to see where a bundled gem is installed.
Post-install message from certified:
IMPORTANT: Remember to use the included executable `certifed-update` regularly to keep your certificate bundle up to date.

```

```plaintext
root@titan-app:/var/www/discourse# bundle show railties
/usr/local/lib/ruby/gems/2.3.0/gems/railties-4.2.7.1

```

That looks good in my eyes.

So it looks like the Step 8 in that tutorial above is incorrect.

But when all seems good in the world, I get this:

```plaintext
root@titan-app:/var/www/discourse# bundle exec script/import_scripts/xenforo.rb
bundler: not executable: script/import_scripts/xenforo.rb

```

Do I need to `chmod +x` or something? (I don’t have a lot of experience in Ruby to know lol)

Thanks for all the help so far!

EDIT: Chmod X’d the xenforo.rb and now I’m getting this:

```plaintext
root@titan-app:/var/www/discourse# bundle exec script/import_scripts/xenforo.rb
script/import_scripts/xenforo.rb: 1: script/import_scripts/xenforo.rb: require: not found
script/import_scripts/xenforo.rb: 3: script/import_scripts/xenforo.rb: Syntax error: "(" unexpected

```

---

<div class="post-metadata">

### Author: ![mpalmer](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mpalmer/32/45740_2.png) [@mpalmer](https://meta.discourse.org/u/mpalmer)
#### Post date: [13.Сентябрь.2016 10:11:28 UTC](https://meta.discourse.org/t/xenforo-import-failing-config-application-rb-2/50049/8 "2016-09-13T10:11:28Z")

</div>

> [@Padraig](#):
>
> Should I be running this as the root user within the container or the discourse user?

As `discourse`. The console output you pasted says it nice and clearly, too:

```
Don't run Bundler as root.

```

> [@Padraig](#):
>
> it says to run `echo "gem 'mysql2'" >Gemfile`

Hmm, yeah, that’s never going to end well. Fixed the howto.

> [@Padraig](#):
>
> `bundler: not executable: script/import_scripts/xenforo.rb`

Unfortunately, `chmod +x` won’t work because the file doesn’t have a “shebang” (`#!/usr/bin/ruby` or similar) to tell the system what language it’s in. I’ve just changed the howto to run ruby explicitly; if you do that, it’ll work better (or at least break _differently_).

---

<div class="post-metadata">

### Author: ![Padraig](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/padraig/32/121553_2.png) [@Padraig](https://meta.discourse.org/u/Padraig)
#### Post date: [13.Сентябрь.2016 10:21:56 UTC](https://meta.discourse.org/t/xenforo-import-failing-config-application-rb-2/50049/9 "2016-09-13T10:21:56Z")

</div>

Massive thank you for the help @mpalmer. I really appreciate it!

```plaintext
discourse@titan-app:/var/www/discourse$ bundle exec ruby script/import_scripts/xenforo.rb
DEPRECATION WARNING: Sprockets method `register_engine` is deprecated.
Please register a mime type using `register_mime_type` then
use `register_compressor` or `register_transformer`.
https://github.com/rails/sprockets/blob/master/guides/extending_sprockets.md#supporting-all-versions-of-sprockets-in-processors
 (called from <top (required)> at /var/www/discourse/lib/es6_module_transpiler/sprockets.rb:3)
/usr/local/lib/ruby/2.3.0/fileutils.rb:1392:in `initialize': No such file or directory @ rb_sysopen - /usr/local/lib/ruby/gems/2.3.0/gems/ember-data-source-2.3.0.beta.5/dist/ember-data.js (Errno::ENOENT)
        from /usr/local/lib/ruby/2.3.0/fileutils.rb:1392:in `open'
        from /usr/local/lib/ruby/2.3.0/fileutils.rb:1392:in `copy_file'
        from /usr/local/lib/ruby/2.3.0/fileutils.rb:486:in `copy_file'
        from /usr/local/lib/ruby/2.3.0/fileutils.rb:403:in `block in cp'
        from /usr/local/lib/ruby/2.3.0/fileutils.rb:1571:in `block in fu_each_src_dest'
        from /usr/local/lib/ruby/2.3.0/fileutils.rb:1587:in `fu_each_src_dest0'
        from /usr/local/lib/ruby/2.3.0/fileutils.rb:1569:in `fu_each_src_dest'
        from /usr/local/lib/ruby/2.3.0/fileutils.rb:402:in `cp'
        from /usr/local/lib/ruby/gems/2.3.0/gems/ember-rails-0.18.5/lib/ember_rails.rb:68:in `block in <class:Railtie>'
        from /usr/local/lib/ruby/gems/2.3.0/gems/railties-4.2.7.1/lib/rails/initializable.rb:30:in `instance_exec'
        from /usr/local/lib/ruby/gems/2.3.0/gems/railties-4.2.7.1/lib/rails/initializable.rb:30:in `run'
        from /usr/local/lib/ruby/gems/2.3.0/gems/railties-4.2.7.1/lib/rails/initializable.rb:55:in `block in run_initializers'
        from /usr/local/lib/ruby/2.3.0/tsort.rb:228:in `block in tsort_each'
        from /usr/local/lib/ruby/2.3.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
        from /usr/local/lib/ruby/2.3.0/tsort.rb:431:in `each_strongly_connected_component_from'
        from /usr/local/lib/ruby/2.3.0/tsort.rb:349:in `block in each_strongly_connected_component'
        from /usr/local/lib/ruby/2.3.0/tsort.rb:347:in `each'
        from /usr/local/lib/ruby/2.3.0/tsort.rb:347:in `call'
        from /usr/local/lib/ruby/2.3.0/tsort.rb:347:in `each_strongly_connected_component'
        from /usr/local/lib/ruby/2.3.0/tsort.rb:226:in `tsort_each'
        from /usr/local/lib/ruby/2.3.0/tsort.rb:205:in `tsort_each'
        from /usr/local/lib/ruby/gems/2.3.0/gems/railties-4.2.7.1/lib/rails/initializable.rb:54:in `run_initializers'
        from /usr/local/lib/ruby/gems/2.3.0/gems/railties-4.2.7.1/lib/rails/application.rb:352:in `initialize!'
        from /usr/local/lib/ruby/gems/2.3.0/gems/railties-4.2.7.1/lib/rails/railtie.rb:194:in `public_send'
        from /usr/local/lib/ruby/gems/2.3.0/gems/railties-4.2.7.1/lib/rails/railtie.rb:194:in `method_missing'
        from /var/www/discourse/config/environment.rb:5:in `<top (required)>'
        from /var/www/discourse/script/import_scripts/base.rb:14:in `require_relative'
        from /var/www/discourse/script/import_scripts/base.rb:14:in `<top (required)>'
        from script/import_scripts/xenforo.rb:3:in `require'
        from script/import_scripts/xenforo.rb:3:in `<main>'

```

It looks like now that I am missing gems or something needs to be defined..

Kind regards,

---

<div class="post-metadata">

### Author: ![mpalmer](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mpalmer/32/45740_2.png) [@mpalmer](https://meta.discourse.org/u/mpalmer)
#### Post date: [13.Сентябрь.2016 11:02:11 UTC](https://meta.discourse.org/t/xenforo-import-failing-config-application-rb-2/50049/10 "2016-09-13T11:02:11Z")

</div>

I got nothing this time… sprockets is well out of my area of knowledge. Sorry.

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [13.Сентябрь.2016 13:35:30 UTC](https://meta.discourse.org/t/xenforo-import-failing-config-application-rb-2/50049/11 "2016-09-13T13:35:30Z")

</div>

I think that on this overwrite Gemfile thing, you’ve got some incompatible bundle. I would try a rebuild to get things back to a working state. Backup all manual changes inside the container before, it’s gonna be wiped.

---

<div class="post-metadata">

### Author: ![Padraig](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/padraig/32/121553_2.png) [@Padraig](https://meta.discourse.org/u/Padraig)
#### Post date: [13.Сентябрь.2016 14:54:32 UTC](https://meta.discourse.org/t/xenforo-import-failing-config-application-rb-2/50049/12 "2016-09-13T14:54:32Z")

</div>

I am just going to scrap it and try from the beginning again.

---

<div class="post-metadata">

### Author: ![Padraig](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/padraig/32/121553_2.png) [@Padraig](https://meta.discourse.org/u/Padraig)
#### Post date: [13.Сентябрь.2016 18:31:43 UTC](https://meta.discourse.org/t/xenforo-import-failing-config-application-rb-2/50049/13 "2016-09-13T18:31:43Z")

</div>

Well, after all that… I rebuilt the app, went in and followed all the instructions to a T…It magically worked (Reading is hard some days 😛 )

```plaintext
RAILS_ENV=production bundle exec ruby script/import_scripts/xenforo.rb

```

Step 10 to the XF tutorial needs to be updated to reflect with the above line!

Anyway, the final result was:

```plaintext
updating featured topic users
      966 / 966 (100.0%)
updating featured topics in categories
       53 / 53 (100.0%)
updating user topic reply counts
      241 / 241 (100.0%)
resetting topic counters
      966 / 966 (100.0%)

Done (00h 04min 55sec)

```

Thanks to everyone for the assistance 🙂

---

<div class="post-metadata">

### Author: ![mpalmer](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mpalmer/32/45740_2.png) [@mpalmer](https://meta.discourse.org/u/mpalmer)
#### Post date: [13.Сентябрь.2016 23:29:57 UTC](https://meta.discourse.org/t/xenforo-import-failing-config-application-rb-2/50049/14 "2016-09-13T23:29:57Z")

</div>

So without the `RAILS_ENV=production` it didn’t work? That’s surprising, because that should already be set in the environment.

---

<div class="post-metadata">

### Author: ![Padraig](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/padraig/32/121553_2.png) [@Padraig](https://meta.discourse.org/u/Padraig)
#### Post date: [14.Сентябрь.2016 00:05:55 UTC](https://meta.discourse.org/t/xenforo-import-failing-config-application-rb-2/50049/15 "2016-09-14T00:05:55Z")

</div>

> [@mpalmer](#):
>
> So without the RAILS\_ENV=production it didn’t work?

Pretty much. Funnily enough, the correct command:

`RAILS_ENV=production bundle exec ruby script/import_scripts/xenforo.rb`

was in as a comment in the `xenforo.rb` file but not in the documentation in the linked above.

It only caught my eye this evening.

---

<div class="post-metadata">

### Author: ![mpalmer](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mpalmer/32/45740_2.png) [@mpalmer](https://meta.discourse.org/u/mpalmer)
#### Post date: [14.Сентябрь.2016 01:44:10 UTC](https://meta.discourse.org/t/xenforo-import-failing-config-application-rb-2/50049/16 "2016-09-14T01:44:10Z")

</div>

OK. Howto topic updated again.

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [08.Июнь.2024 12:45:20 UTC](https://meta.discourse.org/t/xenforo-import-failing-config-application-rb-2/50049/17 "2024-06-08T12:45:20Z")

</div>

Эта тема была автоматически закрыта через 2825 дней. Новые ответы больше не допускаются.
