Vagrant based server failing on db:migrate

I just ran through the instructions in the developer guide to install an environment using a virtual machine with vagrant I found here.

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?

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

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

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?

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 ¯\_(ツ)_/¯

1 Like

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.

Thanks, Simon. I’ll try that out.

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.

4 Likes

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