Running Meteor in a Vagrant (virtual)box

If you’re trying to run Meteor in a Vagrant VirtualBox, and getting an error like this when starting the local server:

vagrant@precise32:/vagrant$ meteor 
[[[[[ /vagrant ]]]]]

Unexpected mongo exit code 100. Restarting.
Unexpected mongo exit code 100. Restarting.
Unexpected mongo exit code 100. Restarting.
Can't start mongod

MongoDB had an unspecified uncaught exception.
This can be caused by MongoDB being unable to write to a local database.
Check that you have permissions to write to .meteor/local. MongoDB does
not support filesystems like NFS that do not allow file locking.

As the error message suggests, the problem is caused by the way Vagrant is sharing the src folder with the VM. The easiest solution (suggested here) is to move the Mongo DB data folder to somewhere on the VM, with a symlink in the Meteor folder:

vagrant@precise32:/vagrant/.meteor/local$ ln -s ~/db/                  
vagrant@precise32:/vagrant/.meteor/local$ ls -la
total 12
drwxr-xr-x 1 vagrant vagrant 4096 Jun 17  2013 .
drwxr-xr-x 1 vagrant vagrant 4096 Jun 17 21:47 ..
lrwxrwxrwx 1 vagrant vagrant   17 Jun 17  2013 db -> /home/vagrant/db/

And you should be back in business!

vagrant@precise32:/vagrant$ meteor 
[[[[[ /vagrant ]]]]]

=> Meteor server running on: http://localhost:3000/

UPDATE: this won’t work on a Windows host, apparently; due to the lack of support for symlinks. Sorry!

Advertisements

17 thoughts on “Running Meteor in a Vagrant (virtual)box

  1. Chris December 23, 2013 / 6:12 am

    Worked for me, but I had to ln ‘local’ rather than ‘db’. Many thanks.

    • Steve D.V. (@sdvim) February 19, 2014 / 1:50 pm

      I’ve been stuck on this problem for hours. I saw this blog post but no luck; then I tried your suggestion and it works! Thanks a ton to you and Graham!!

  2. Diogo Alves April 3, 2014 / 6:33 pm

    Here dont work it. I’m trying in Centos 6.4 (64), local folder dont exists in “/home/vagrant/.meteor”. Any idea? Thank you.

    • Graham Hay April 3, 2014 / 8:08 pm

      It’s in /vagrant, when you’re ssh’d in to the box

      • Graham Hay April 3, 2014 / 8:51 pm

        that db file doesn’t look like a symlink. it should be like this:

        lrwxrwxrwx 1 vagrant vagrant 17 Jun 17 2013 db -> /home/vagrant/db/

      • Diogo Alves April 3, 2014 / 9:30 pm

        I belive that i cant create symlinks:

        [vagrant@meteor local]$ ln -s /home/vagrant/db/ db
        ln: creating symbolic link `db’: Protocol error

        Vagrant is the shared folder. Are you using Windows with Vagrant?

      • Graham Hay April 3, 2014 / 9:52 pm

        No, I’m using linux as both guest and host.

  3. pascoual April 24, 2014 / 4:10 pm

    Thanks a lot !

  4. Jessica June 9, 2014 / 2:47 am

    Worked for me. Thank you!

  5. rocknroll113 September 9, 2014 / 2:12 pm

    You can use the rsync option and ignore the `local` directory and avoid manually creating a symbolic link, e.g., in your Vagrantfile

    config.vm.synced_folder ‘.’, ‘/vagrant’, type: ‘rsync’, rsync__exclude: [‘.meteor/local’, ‘packages’]

    N.b. I had to also excluded the packages directory too as rsync was not happy about symbolic links in that.

    The to automatically sync your edits you will need to run

    vagrant rsync-auto

  6. Ankur October 17, 2014 / 5:50 am

    Sir Its not working for me…
    When I am executing ln -s ~/db/ an error : cannot overwritethe directory occurs.
    help me out.

    • Graham Hay October 17, 2014 / 7:50 am

      does the ~/db/ folder already exist?

  7. Rune October 17, 2014 / 11:42 am

    Could you please write exactly what I am supposed to write in order to symlink?

  8. Graham Hay October 17, 2014 / 11:50 am

    as stated above: if you’re in the “/vagrant/.meteor/local” folder, then you need to run “ln -s ~/db/”; which should create a symlink to the vagrant home dir (/home/vagrant/db).

  9. Callum November 20, 2014 / 2:18 pm

    Genius, thanks. :-)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s