Installing mysql2 Gem for Flarum Import

I’ve no knowledge of Rails and hence, none that of discourse. I’m trying to migrate flarum database to discourse.

P.S: I’ve successfully installed discourse for production.

Right now, I’ve installed discourse docker from official git repository. When I try to run the import script in docker container:

su discourse -c 'bundle exec ruby script/import_scripts/flarum_import.rb'

I get this error:

/usr/local/lib/ruby/3.3.0/bundled_gems.rb:74:in `require': cannot load such file -- mysql2 (LoadError)
from /usr/local/lib/ruby/3.3.0/bundled_gems.rb:74:in `block (2 levels) in replace_require'

I’ve tried all methods explained in different forum posts but none worked.
If anyone could explain in 2-3 steps what to do to run ‘flarum_import.rb’ import script, that’d be a great help.

If you look in /var/discourse/templates/import there are some examples of how to include the mysql stuff.

You also need to install mysql somewhere that Discourse can access it

2 Likes

Thanks for pointing out. I just didn’t know how to execute those scripts. Although, I’m not good at getting hints but this helped me in getting things straight.

I edited the “containers/app.yml”

cd /var/discourse/containers
sudo nano app.yml

And added the template path for mysql-dep template: - "templates/import/mysql-dep.template.yml" as shown below
discourse_reply1

After that, just rebuilt the app and all dependencies required for flarum_import.rb were installed.

Worked like a charm!

1 Like