Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

brew services start [email protected] fails - uninitialized constant

I've followed the directions on the MongoDB docs to install MongoDB on Mac using homebrew:

brew tap mongodb/brew
brew install [email protected]

Then I can run it in the foreground using:

mongod --config /usr/local/etc/mongod.conf

But, when trying to start it as a service using:

brew services start [email protected]

I get this error:

Error: mongodb-community: uninitialized constant #<Class:0x00007ff189061008>::Gem

I also get this error when running brew doctor:

Warning: Some installed formulae are not readable:
  mongodb-community: uninitialized constant #<Class:0x00007ffd903152a0>::Gem

Why this is happening? How do I fix it?

Thank you!

like image 434
RyanDay Avatar asked May 05 '19 03:05

RyanDay


2 Answers

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

like image 54
Lincoln Bergeson Avatar answered Nov 04 '22 21:11

Lincoln Bergeson


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
like image 27
num8er Avatar answered Nov 04 '22 20:11

num8er