brew services start [email protected] fails - uninitialized constant

This is an error with the mongodb-community formula. An issue has been filed with the maintainers, a solution found, and a pull request with the fix opened.

In the meantime, you can fix the error yourself. This line in the formula is throwing an exception:

Gem::Version.new(v['version'])

because the Gem class has not been imported. Adding the import:

require 'rubygems'

solves the problem. You can do this locally, by finding and editing the formula on your computer. It is probably in this file:

/usr/local/Homebrew/Library/Taps/mongodb/homebrew-brew/Formula/mongodb-community.rb

Update: A community contributor has fixed this upstream. If you are still experiencing this issue you might need to run brew update


I know it's not correct answer since we are talking about registering service using:

brew services start mongodb-community

But I've SOLVED service registration question this way:

sudo cp /usr/local/Cellar/mongodb-community/4.0.9/homebrew.mxcl.mongodb-community.plist /Library/LaunchAgents/

launchctl load -w /Library/LaunchAgents/homebrew.mxcl.mongodb-community.plist

launchctl start mongodb-community