# Flarum to Discourse Migration failed

**URL:** https://meta.discourse.org/t/flarum-to-discourse-migration-failed/222696
**Category:** Migration
**Tags:** flarum
**Created:** [March 31, 2022, 3:34pm UTC](https://meta.discourse.org/t/flarum-to-discourse-migration-failed/222696 "2022-03-31T15:34:24Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![thimiraonline](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/thimiraonline/32/254979_2.png) [@thimiraonline](https://meta.discourse.org/u/thimiraonline)
#### Post date: [March 31, 2022, 3:34pm UTC](https://meta.discourse.org/t/flarum-to-discourse-migration-failed/222696/1 "2022-03-31T15:34:24Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [March 31, 2022, 3:46pm UTC](https://meta.discourse.org/t/flarum-to-discourse-migration-failed/222696/2 "2022-03-31T15:46:48Z")

</div>

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

---

<div class="post-metadata">

### Author: ![thimiraonline](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/thimiraonline/32/254979_2.png) [@thimiraonline](https://meta.discourse.org/u/thimiraonline)
#### Post date: [March 31, 2022, 3:50pm UTC](https://meta.discourse.org/t/flarum-to-discourse-migration-failed/222696/3 "2022-03-31T15:50:21Z")

</div>

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

---

<div class="post-metadata">

### Author: ![thimiraonline](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/thimiraonline/32/254979_2.png) [@thimiraonline](https://meta.discourse.org/u/thimiraonline)
#### Post date: [March 31, 2022, 4:17pm UTC](https://meta.discourse.org/t/flarum-to-discourse-migration-failed/222696/4 "2022-03-31T16:17:40Z")

</div>

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

---

<div class="post-metadata">

### Author: ![RGJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rgj/32/523185_2.png) [@RGJ](https://meta.discourse.org/u/RGJ)
#### Post date: [March 31, 2022, 4:25pm UTC](https://meta.discourse.org/t/flarum-to-discourse-migration-failed/222696/5 "2022-03-31T16:25:28Z")

</div>

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

```plaintext
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`.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [March 31, 2022, 8:14pm UTC](https://meta.discourse.org/t/flarum-to-discourse-migration-failed/222696/6 "2022-03-31T20:14:08Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![RGJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rgj/32/523185_2.png) [@RGJ](https://meta.discourse.org/u/RGJ)
#### Post date: [March 31, 2022, 9:11pm UTC](https://meta.discourse.org/t/flarum-to-discourse-migration-failed/222696/7 "2022-03-31T21:11:40Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [April 1, 2022, 1:20pm UTC](https://meta.discourse.org/t/flarum-to-discourse-migration-failed/222696/8 "2022-04-01T13:20:31Z")

</div>

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

```plaintext
           - "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.

> [@RGJ](#):
>
> @thimiraonline did it work for you?

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.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [April 1, 2022, 2:26pm UTC](https://meta.discourse.org/t/flarum-to-discourse-migration-failed/222696/9 "2022-04-01T14:26:04Z")

</div>

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

```plaintext

[!] 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.

---

<div class="post-metadata">

### Author: ![reneb71](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/reneb71/32/262399_2.png) [@reneb71](https://meta.discourse.org/u/reneb71)
#### Post date: [June 2, 2022, 7:33am UTC](https://meta.discourse.org/t/flarum-to-discourse-migration-failed/222696/10 "2022-06-02T07:33:58Z")

</div>

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

```plaintext
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)

```
