# Import data from Phorum

**URL:** https://meta.discourse.org/t/import-data-from-phorum/40294
**Category:** Support
**Created:** [February 28, 2016, 4:19pm UTC](https://meta.discourse.org/t/import-data-from-phorum/40294 "2016-02-28T16:19:53Z")
**Posts on this page:** 18
**Page:** 1

<div class="post-metadata">

### Author: ![fra](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fra/32/121847_2.png) [@fra](https://meta.discourse.org/u/fra)
#### Post date: [February 28, 2016, 4:19pm UTC](https://meta.discourse.org/t/import-data-from-phorum/40294/1 "2016-02-28T16:19:53Z")

</div>

Hi,  
I am trying to import data from Phorum database. I have filled db data to the phorum.rb script (mysql name, pass, db name) and tried to run the script with: `ruby script/import_scripts/phorum.rb`

but it failed with this error:

```plaintext
/var/discourse/script/import_scripts/base.rb:14:in `require_relative': cannot load such file --
/var/discourse/config/environment (LoadError)
from /var/discourse/script/import_scripts/base.rb:14:in `<top (required)>'
from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:54:in `require'
from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:54:in `require'
from script/import_scripts/phorum.rb:3:in `<main>'

```

Have you any idea what am I doing wrong?

Thanks so much!

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [February 29, 2016, 11:38am UTC](https://meta.discourse.org/t/import-data-from-phorum/40294/2 "2016-02-29T11:38:12Z")

</div>

Have you installed the `mysql2` gem? It’s not in our `Gemfile` since we use postgresql. You can install with `gem install mysql2`.

---

<div class="post-metadata">

### Author: ![fra](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fra/32/121847_2.png) [@fra](https://meta.discourse.org/u/fra)
#### Post date: [February 29, 2016, 12:20pm UTC](https://meta.discourse.org/t/import-data-from-phorum/40294/3 "2016-02-29T12:20:26Z")

</div>

Yup, I have installed that (it was first thing I have done, import script showed different error and it was clear that mysql2 was missing).

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [February 29, 2016, 1:51pm UTC](https://meta.discourse.org/t/import-data-from-phorum/40294/4 "2016-02-29T13:51:00Z")

</div>

Ok, pinging @techAPJ since he wrote it. He might be able to help you out.

---

<div class="post-metadata">

### Author: ![techAPJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/techapj/32/342990_2.png) [@techAPJ](https://meta.discourse.org/u/techAPJ)
#### Post date: [February 29, 2016, 2:10pm UTC](https://meta.discourse.org/t/import-data-from-phorum/40294/5 "2016-02-29T14:10:20Z")

</div>

Are you running the import script on production server? If yes, can you confirm you’re running import script like this:

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

```

---

<div class="post-metadata">

### Author: ![fra](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fra/32/121847_2.png) [@fra](https://meta.discourse.org/u/fra)
#### Post date: [February 29, 2016, 2:54pm UTC](https://meta.discourse.org/t/import-data-from-phorum/40294/6 "2016-02-29T14:54:24Z")

</div>

I am not sure if it’s production server (I’ve followed Discourse installation guide [here](https://github.com/discourse/discourse/blob/master/docs/INSTALL-cloud.md)) and if I try to run command you’ve mentioned it ends with: _Could not locate Gemfile_ (even if I try it from directory with phorum.rb).

---

<div class="post-metadata">

### Author: ![fra](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fra/32/121847_2.png) [@fra](https://meta.discourse.org/u/fra)
#### Post date: [March 9, 2016, 11:12pm UTC](https://meta.discourse.org/t/import-data-from-phorum/40294/7 "2016-03-09T23:12:36Z")

</div>

Hey @techAPJ , sorry for pinging you. I’d be happy if you could point at what I am doing wrong. Thank you very much!

---

<div class="post-metadata">

### Author: ![gerhard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gerhard/32/119479_2.png) [@gerhard](https://meta.discourse.org/u/gerhard)
#### Post date: [March 10, 2016, 11:06am UTC](https://meta.discourse.org/t/import-data-from-phorum/40294/8 "2016-03-10T11:06:28Z")

</div>

Looks like you’re trying to run the importer inside the Docker container. This should work:

```plaintext
cd /var/www/discourse
su discourse -c 'bundle exec ruby script/import_scripts/phorum.rb'

```

---

<div class="post-metadata">

### Author: ![fra](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fra/32/121847_2.png) [@fra](https://meta.discourse.org/u/fra)
#### Post date: [March 10, 2016, 11:10am UTC](https://meta.discourse.org/t/import-data-from-phorum/40294/9 "2016-03-10T11:10:44Z")

</div>

No, the result is same:  
`Could not locate Gemfile`

Command to start was: `su root -c 'bundle exec ruby script/import_scripts/phorum.rb'` from /var/discourse. I have Vagrantfile there but really no Gemfile.

---

<div class="post-metadata">

### Author: ![gerhard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gerhard/32/119479_2.png) [@gerhard](https://meta.discourse.org/u/gerhard)
#### Post date: [March 10, 2016, 11:16am UTC](https://meta.discourse.org/t/import-data-from-phorum/40294/10 "2016-03-10T11:16:18Z")

</div>

Did you delete the Gemfile? Try running

```bash
cd /var/www/discourse
git reset HEAD --hard

```

or recreate your Docker container.

---

<div class="post-metadata">

### Author: ![fra](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fra/32/121847_2.png) [@fra](https://meta.discourse.org/u/fra)
#### Post date: [March 10, 2016, 8:43pm UTC](https://meta.discourse.org/t/import-data-from-phorum/40294/11 "2016-03-10T20:43:13Z")

</div>

I tried:  
`git reset HEAD --hard`  
`git pull`  
`./launcher rebuild app`  
`bundle exec ruby script/import_scripts/phorum.rb` as root

Still no Gemfile. I forgot to mention that I always have to modify launcher, because it detects uppercase characters, spaces or special characters in `app`, so I just comment out `exit 1` line.

---

<div class="post-metadata">

### Author: ![fra](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fra/32/121847_2.png) [@fra](https://meta.discourse.org/u/fra)
#### Post date: [March 10, 2016, 11:02pm UTC](https://meta.discourse.org/t/import-data-from-phorum/40294/12 "2016-03-10T23:02:39Z")

</div>

Ok, some progress at least. I’ve manually downloaded Gemfile and did bundle install but right now it’s ending because of:  
`script/import_scripts/phorum.rb:1:in `require’: cannot load such file – mysql2`

(even if mysql2 gem is installed)

---

<div class="post-metadata">

### Author: ![gerhard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gerhard/32/119479_2.png) [@gerhard](https://meta.discourse.org/u/gerhard)
#### Post date: [March 10, 2016, 11:31pm UTC](https://meta.discourse.org/t/import-data-from-phorum/40294/13 "2016-03-10T23:31:56Z")

</div>

You need to enter the Docker container:

```bash
./launcher enter app

```

Then install the mysql2 gem…

```bash
apt-get update && apt-get install -y nano libmysqlclient-dev
cd /var/www/discourse
echo "gem 'mysql2'" >> Gemfile
su discourse -c 'bundle install --no-deployment --without test --without development --path vendor/bundle'

```

… configure the import script

```bash
nano script/import_scripts/phorum.rb

```

and execute the importer

```bash
su discourse -c 'bundle exec ruby script/import_scripts/phorum.rb'

```

---

<div class="post-metadata">

### Author: ![fra](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fra/32/121847_2.png) [@fra](https://meta.discourse.org/u/fra)
#### Post date: [March 11, 2016, 10:13am UTC](https://meta.discourse.org/t/import-data-from-phorum/40294/14 "2016-03-11T10:13:31Z")

</div>

It ended with:

```
/var/discourse/script/import_scripts/base.rb:14:in `require_relative': cannot load such file -- /var/discourse/config/environment (LoadError)
    from /var/discourse/script/import_scripts/base.rb:14:in `<top (required)>'
    from script/import_scripts/phorum.rb:3:in `require'
    from script/import_scripts/phorum.rb:3:in `<main>'

```

If I compare directories on github and in /var/discourse I have missing a lot of them (I don’t know how that’s possible). Shouldn’t I try to remove entire /var/discourse and download it again?

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [March 11, 2016, 10:17am UTC](https://meta.discourse.org/t/import-data-from-phorum/40294/15 "2016-03-11T10:17:16Z")

</div>

Sincerely, it would be much easier for you to set up a development environment and run the import there rather than in a production server.

---

<div class="post-metadata">

### Author: ![fra](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fra/32/121847_2.png) [@fra](https://meta.discourse.org/u/fra)
#### Post date: [April 18, 2016, 1:55pm UTC](https://meta.discourse.org/t/import-data-from-phorum/40294/16 "2016-04-18T13:55:36Z")

</div>

I finally managed to find time to set up development installation and import worked perfectly.

Thanks!

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [January 7, 2019, 8:25pm UTC](https://meta.discourse.org/t/import-data-from-phorum/40294/17 "2019-01-07T20:25:17Z")

</div>



---

<div class="post-metadata">

### Author: ![jomaxro](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jomaxro/32/126216_2.png) [@jomaxro](https://meta.discourse.org/u/jomaxro)
#### Post date: [January 7, 2019, 8:32pm UTC](https://meta.discourse.org/t/import-data-from-phorum/40294/18 "2019-01-07T20:32:08Z")

</div>


