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


(Padraig) #1

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 - Importing Xenforo to Discourse

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

and I get the following:

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


(Matt Palmer) #2

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


(Kane York) #3

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


(Padraig) #4

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

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.

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?


(Matt Palmer) #5

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


(Padraig) #6

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

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,


(Padraig) #7

I think I may be onto something here.

In Step 8 of this tutorial: Importing Xenforo to Discourse , it says to run echo "gem 'mysql2'" >Gemfile

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

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 :stuck_out_tongue: )

But it ended with this:

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.

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:

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:

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

(Matt Palmer) #8

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

Don't run Bundler as root.

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

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


(Padraig) #9

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

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,


(Matt Palmer) #10

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


(Rafael dos Santos Silva) #11

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.


(Padraig) #12

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


(Padraig) #13

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 :stuck_out_tongue: )

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:

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 :slight_smile:


(Matt Palmer) #14

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


(Padraig) #15

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.


(Matt Palmer) #16

OK. Howto topic updated again.