# Vagrant based server failing on db:migrate

**URL:** https://meta.discourse.org/t/vagrant-based-server-failing-on-db-migrate/34566
**Category:** Bug
**Created:** [October 15, 2015, 6:28pm UTC](https://meta.discourse.org/t/vagrant-based-server-failing-on-db-migrate/34566 "2015-10-15T18:28:05Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![kcoop](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/kcoop/32/108612_2.png) [@kcoop](https://meta.discourse.org/u/kcoop)
#### Post date: [October 15, 2015, 6:28pm UTC](https://meta.discourse.org/t/vagrant-based-server-failing-on-db-migrate/34566/1 "2015-10-15T18:28:05Z")

</div>

I just ran through the instructions in the developer guide to install an environment using a virtual machine with vagrant I found [here](https://github.com/discourse/discourse/blob/master/docs/VAGRANT.md).

In my newly created instance, after a bundle update, updating the database with rake like so

```
bundle exec rake db:migrate

```

generates the following error:

```
rake aborted!
NameError: uninitialized constant SiteSettings::DbProvider::RailsMultisite
/vagrant/lib/site_settings/db_provider.rb:52:in `current_site'
/vagrant/lib/site_setting_extension.rb:44:in `current'
/vagrant/lib/site_setting_extension.rb:96:in `block in setting'
/vagrant/lib/site_setting_extension.rb:93:in `synchronize'
/vagrant/lib/site_setting_extension.rb:93:in `setting'
/vagrant/lib/site_setting_extension.rb:151:in `client_setting'
/vagrant/app/models/site_setting.rb:18:in `block in load_settings'
/vagrant/lib/site_settings/yaml_loader.rb:29:in `block (2 levels) in load'
/vagrant/lib/site_settings/yaml_loader.rb:20:in `each'
/vagrant/lib/site_settings/yaml_loader.rb:20:in `block in load'
/vagrant/lib/site_settings/yaml_loader.rb:19:in `each_key'
/vagrant/lib/site_settings/yaml_loader.rb:19:in `load'
/vagrant/app/models/site_setting.rb:16:in `load_settings'
/vagrant/app/models/site_setting.rb:25:in `<class:SiteSetting>'
/vagrant/app/models/site_setting.rb:4:in `<top (required)>'
/vagrant/config/initializers/04-message_bus.rb:39:in `<top (required)>'
/var/lib/gems/2.2.0/gems/railties-4.2.4/lib/rails/engine.rb:652:in `block in load_config_initializer'
/var/lib/gems/2.2.0/gems/activesupport-4.2.4/lib/active_support/notifications.rb:166:in `instrument'
/var/lib/gems/2.2.0/gems/railties-4.2.4/lib/rails/engine.rb:651:in `load_config_initializer'
/var/lib/gems/2.2.0/gems/railties-4.2.4/lib/rails/engine.rb:616:in `block (2 levels) in <class:Engine>'
/var/lib/gems/2.2.0/gems/railties-4.2.4/lib/rails/engine.rb:615:in `each'
/var/lib/gems/2.2.0/gems/railties-4.2.4/lib/rails/engine.rb:615:in `block in <class:Engine>'
/var/lib/gems/2.2.0/gems/railties-4.2.4/lib/rails/initializable.rb:30:in `instance_exec'
/var/lib/gems/2.2.0/gems/railties-4.2.4/lib/rails/initializable.rb:30:in `run'
/var/lib/gems/2.2.0/gems/railties-4.2.4/lib/rails/initializable.rb:55:in `block in run_initializers'
/var/lib/gems/2.2.0/gems/railties-4.2.4/lib/rails/initializable.rb:44:in `each'
/var/lib/gems/2.2.0/gems/railties-4.2.4/lib/rails/initializable.rb:44:in `tsort_each_child'
/var/lib/gems/2.2.0/gems/railties-4.2.4/lib/rails/initializable.rb:54:in `run_initializers'
/var/lib/gems/2.2.0/gems/railties-4.2.4/lib/rails/application.rb:352:in `initialize!'
/var/lib/gems/2.2.0/gems/railties-4.2.4/lib/rails/railtie.rb:194:in `public_send'
/var/lib/gems/2.2.0/gems/railties-4.2.4/lib/rails/railtie.rb:194:in `method_missing'
/vagrant/config/environment.rb:5:in `<top (required)>'
/var/lib/gems/2.2.0/gems/railties-4.2.4/lib/rails/application.rb:328:in `require_environment!'
/var/lib/gems/2.2.0/gems/railties-4.2.4/lib/rails/application.rb:457:in `block in run_tasks_blocks'
Tasks: TOP => db:migrate => environment
(See full trace by running task with --trace)

```

I cloned the github repo from the instructions, and it’s pristine. Is this a bug? Any thoughts on what I’m doing wrong?

---

<div class="post-metadata">

### Author: ![dmitry\_fedyuk](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dmitry_fedyuk/32/293153_2.png) [@dmitry\_fedyuk](https://meta.discourse.org/u/dmitry_fedyuk)
#### Post date: [October 15, 2015, 6:50pm UTC](https://meta.discourse.org/t/vagrant-based-server-failing-on-db-migrate/34566/2 "2015-10-15T18:50:26Z")

</div>

Yes, the same as [https://meta.discourse.org/t/upgrade-failed-after-the-recent-todays-commits-cannot-load-such-file-rails-multisite/34396](https://meta.discourse.org/t/upgrade-failed-after-the-recent-todays-commits-cannot-load-such-file-rails-multisite/34396)

---

<div class="post-metadata">

### Author: ![kcoop](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/kcoop/32/108612_2.png) [@kcoop](https://meta.discourse.org/u/kcoop)
#### Post date: [October 15, 2015, 6:55pm UTC](https://meta.discourse.org/t/vagrant-based-server-failing-on-db-migrate/34566/3 "2015-10-15T18:55:19Z")

</div>

Thanks, Dmitry. This didn’t show up in my googling. I’ll use sunsijie’s workaround.

---

<div class="post-metadata">

### Author: ![kcoop](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/kcoop/32/108612_2.png) [@kcoop](https://meta.discourse.org/u/kcoop)
#### Post date: [October 15, 2015, 7:02pm UTC](https://meta.discourse.org/t/vagrant-based-server-failing-on-db-migrate/34566/4 "2015-10-15T19:02:37Z")

</div>

Hmm… no joy. The gem was already in my Gemfile, and the chmod had no positive impact (it wasn’t readable by all, FWIW).

Any more thoughts on this?

---

<div class="post-metadata">

### Author: ![riking](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riking/32/170938_2.png) [@riking](https://meta.discourse.org/u/riking)
#### Post date: [October 16, 2015, 5:57am UTC](https://meta.discourse.org/t/vagrant-based-server-failing-on-db-migrate/34566/5 "2015-10-16T05:57:48Z")

</div>

I solved this by basically wiping all my installed gems and reinstalling all of them. It’s possible you have a bad copy of something. I have no idea what it is, though ¯\_(ツ)\_/¯

---

<div class="post-metadata">

### Author: ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)
#### Post date: [October 16, 2015, 6:34am UTC](https://meta.discourse.org/t/vagrant-based-server-failing-on-db-migrate/34566/6 "2015-10-16T06:34:05Z")

</div>

I just tried running `rake db:migrate` on the Vagrant image on a mac and got the same results you are getting.

You might try using the setup outlined in this article for Development. It’s working well.

> [@Install Discourse on macOS for development](https://meta.discourse.org/t/beginners-guide-to-install-discourse-on-mac-os-x-for-development/15772):
>
> warning This guide covers installation instructions for a macOS development environment, for production guides see: [Install Discourse in production with the official supported instructions](https://meta.discourse.org/t/how-to-install-discourse-in-production/142537) So you want to set up Discourse on macOS to hack on and develop with? We’ll assume that you don’t have Ruby/Rails/Postgres/Redis installed on your Mac. Let’s begin rocket ! Install Discourse Dependencies You will need the following packages on your system: [Git](http://git-scm.com/)[rbenv](https://github.com/sstephenson/rbenv) or [asdf](https://asdf-vm.com/guide/getting-started.html)[ruby-build](https://github.com/sstephenson/ruby-build)[Ruby](https://www.ruby-lang.org/) (latest s…

---

<div class="post-metadata">

### Author: ![kcoop](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/kcoop/32/108612_2.png) [@kcoop](https://meta.discourse.org/u/kcoop)
#### Post date: [October 16, 2015, 8:10pm UTC](https://meta.discourse.org/t/vagrant-based-server-failing-on-db-migrate/34566/7 "2015-10-16T20:10:39Z")

</div>

Thanks, Simon. I’ll try that out.

---

<div class="post-metadata">

### Author: ![mpalmer](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mpalmer/32/45740_2.png) [@mpalmer](https://meta.discourse.org/u/mpalmer)
#### Post date: [October 21, 2015, 10:57pm UTC](https://meta.discourse.org/t/vagrant-based-server-failing-on-db-migrate/34566/8 "2015-10-21T22:57:07Z")

</div>

I’ve tracked down the problem: the `rails_multisite` gem has restrictive permissions on some of the files, and so the vagrant user can’t read them (and hence can’t load the code).

While @sam is unavailable to make a new (fixed) release of `rails_multisite`, the simplest workaround is to run the following:

```
sudo chmod -R a+r /var/lib/gems/2.2.0/gems/rails_multisite-1.0.2

```

That’ll fix the permissions and you’ll be off and running.

---

<div class="post-metadata">

### Author: ![OnceWas](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/oncewas/32/40734_2.png) [@OnceWas](https://meta.discourse.org/u/OnceWas)
#### Post date: [October 24, 2015, 2:25am UTC](https://meta.discourse.org/t/vagrant-based-server-failing-on-db-migrate/34566/9 "2015-10-24T02:25:18Z")

</div>

As of October 23, you’ll need to bump up the `rails_multisite` version:

```
sudo chmod -R a+r /var/lib/gems/2.2.0/gems/rails_multisite-1.0.2

```

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [February 20, 2017, 3:08pm UTC](https://meta.discourse.org/t/vagrant-based-server-failing-on-db-migrate/34566/10 "2017-02-20T15:08:47Z")

</div>


