A non-destructive solution for "Unexpected mongo exit code 100"

Just going through the tutorial, got to the iOS part. Am running OS X 10.10.5 with dev tools. Was already running Meteor on port 3000 so did this, got:

$ meteor run ios --port 3001
[[[[[ ~/projects/simple-todos ]]]]]           

=> Started proxy.                             
Unexpected mongo exit code 100. Restarting.   
Unexpected mongo exit code 100. Restarting.   
Unexpected mongo exit code 100. Restarting.   
Can't start Mongo server.                     
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.

I read up about the error, tried the fixes that aren’t a complete and convoluted pain (deleting mongo lock file, resetting and losing all the data, etc.) but got nowhere, so am stuck. Best result was the iOS emulator started up with the app, but trying to launch it there just showed a default Meteor screen.

Since Meteor appears to have been developed on OS X machines, there JUST HAS to be a better way of handling this issue than all the workarounds and fixes on >= Yosemite (none of which worked for me)!

Port 3001 is the default MongoDB port (1 more than the Meteor port), so it looks like you’re trying to run meteor ios on the same port that your pre-existing instance of meteor is using for its MongoDB connection.

Try meteor run ios --port 3010 (or similar).

You can back up the db directory before you delete local directory, and then just put it back in the new local once it’s created. That usually works for me.

remove mongo.lock file from .local dir

Well-spotted, but the same error persists on that (any?) port. Tried again after removing the Mongo lock file at .meteor/local/db/mongod.lock, same error.

Tried this with my working app, (backed up db, deleted local, put db back in new local after doing run ios --port 3010) got:

[[[[[ ~/projects/simple-todos ]]]]]           

=> Started proxy.                             
=> Started MongoDB.                           
=> Errors prevented startup:                  
   
   While processing files with templating (for target web.browser):
   local copy/build/programs/web.browser/head.html:1: Expected one of: <body>, <head>, <template>
   local copy/build/programs/web.cordova/head.html:1: Expected one of: <body>, <head>, <template>
   
   While processing files with templating (for target web.cordova):
   local copy/build/programs/web.browser/head.html:1: Expected one of: <body>, <head>, <template>
   local copy/build/programs/web.cordova/head.html:1: Expected one of: <body>, <head>, <template>
   
=> Your application has errors. Waiting for file change.

I can only hope that someone looks into this and at least adds a note of caution in the tutorial

My solution was:

  1. move .meteor/local/
  2. meteor run ios --port 3010
  3. wait for the errors
  4. move .meteor/local/ back again

The app then eventually appeared in the iOS Simulator.

I’m not happy at having to jump through hoops to get there. The first warning suggested:

Check that you have permissions to write to .meteor/local. MongoDB does
not support filesystems like NFS that do not allow file locking.

And since my move of .meteor/local/ permissions look like this:

drwxr-xr-x@ 11 admin  staff   374  3 Mar 21:17 .
drwxr-xr-x@  7 admin  staff   238  3 Mar 16:14 ..
-rw-r--r--@  1 admin  staff   368 21 Feb 21:57 .finished-upgraders
-rw-r--r--@  1 admin  staff     6 21 Feb 21:57 .gitignore
-rw-r--r--@  1 admin  staff   322 21 Feb 21:57 .id
drwxr-xr-x  10 admin  staff   340  4 Mar 08:23 local
-rw-r--r--   1 admin  staff  1107  3 Mar 21:17 packages
-rw-r--r--@  1 admin  staff    19 22 Feb 16:18 platforms
-rw-r--r--@  1 admin  staff    13 21 Feb 21:57 release
-rw-r--r--   1 admin  staff  1466  3 Mar 21:17 versions
$ cd local;ls -al
total 16
drwxr-xr-x  10 admin  staff   340  4 Mar 08:23 .
drwxr-xr-x@ 11 admin  staff   374  3 Mar 21:17 ..
drwxr-xr-x   8 admin  staff   272  4 Mar 08:23 build
drwxr-xr-x   3 admin  staff   102  1 Mar 09:47 bundler-cache
drwxr-xr-x   8 admin  staff   272  3 Mar 16:17 cordova-build
drwxr-xr-x@  6 admin  staff   204  1 Mar 09:34 db
drwxr-xr-x   2 admin  staff    68  1 Mar 09:47 isopacks
drwxr-xr-x  86 admin  staff  2924  3 Mar 21:17 plugin-cache
drwxr-xr-x   3 admin  staff   102  4 Mar 08:23 shell

Which seems okay - be interesting to see what others on Yosemite have on initialising a Meteor app, as moving the local folder may have changed things.