Flarum to Discourse Migration failed

I have setup everything and tried to import flarum_import.rb. But it says thimira@THIMIRA:~/discourse/script/import_scripts$ bundle exec ruby flarum_import.rb Traceback (most recent call last): 1: from flarum_import.rb:3:in '`

What do I have to do? Please help.

1 Like

You’ll need to include more of the output for anyone to guess, but (proving that I’m wrong about that), line 3 is

 require "mysql2"

so it would appear that you need to add that to the Gemfile and run bundle install.


How to do that? I mean how to add it to Gemfile?

Please check DM. I have left a message at there.

It’s not needed to manually add these gems to the Gemfile nowadays, they are already there. You just need to enable them by using IMPORT=1 in front of your command.

So just do

IMPORT=1 bundle install
IMPORT=1 bundle exec ruby flarum_import.rb

If the bundle install gives you an error then you might also need to do bundle config unset deployment.

1 Like

My experience is that if you do the IMPORT=1 you get a bunch of failures if you haven’t installed all of the dependencies for all of the extra import stuff, and a couple of those are tricky to figure out.

1 Like

Hmm that’s not my experience - and I fail to understand how doing it one way or the other could influence dependencies?

@thimiraonline did it work for you?

Stuff like this:

 An error occurred while installing tiny_tds (2.1.5), and Bundler cannot continue.

And then if you install tiny_tds, which is non-trivial, you then get

 An error occurred while installing sqlite3 (1.4.2), and Bundler cannot continue.

But I think if you include

           - "templates/import/mysql-dep.template.yml"
           - "templates/import/mbox.template.yml"
           - "templates/import/mssql-dep.template.yml"

Then it might work. That’s what I’ll try next; For a time I rolled my own templates to install those dependencies, but hope to have found that I never needed to.

I gave it a shot but his setup has a db table prefix and the script has no setting for the prefix. I’ve asked him to rename the tables and I’ll try again.


. . . but the import templates add the Gem to the Gemfile, so if you try to use ``IMPORT=1` then you get

[!] There was an error parsing `Gemfile`: You cannot specify the same gem twice with different version requirements.
You specified: sqlite3 (~> 1.3, >= 1.3.13) and sqlite3 (>= 0). Bundler cannot continue.

 #  from /var/www/discourse/Gemfile:272
 #  -------------------------------------------
 #  gem 'mysql2'
 >  gem 'sqlite3'
 #  gem 'tiny_tds'
 #  -------------------------------------------

Because the Gemfile specifies a version and the template doesn’t.

So after trying pretty hard, I’m not finding a way to make IMPORT=1 be useful. I guess it would work on a development instance where you installed all of those dependencies in the OS, or you hand-rolled a way to install the dependencies in a container.

Oh, but the mbox import does much more than install sqlite3, so that’s not a good thing to do unless you really want to import an mbox.

Maybe I’ll submit a PR for an sqlite3 import template.


im getting this error when trying to run the script with IMPORT=1

1: from /home/user/.rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/gems/zeitwerk-2.5.4/lib/zeitwerk/kernel.rb:28:in `require' /home/user/.rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/gems/zeitwerk-2.5.4/lib/zeitw erk/loader/callbacks.rb:25:in `on_file_autoloaded': expected file /home/user/disco urse/lib/freedom_patches/ip_addr.rb to define constant FreedomPatches::IPAddr, but didn't (Zeitwerk:: NameError)