brew services start mongodb-community@4.0 失败 - 未初始化常量

12

我按照MongoDB文档中的指示,使用Homebrew在Mac上安装了MongoDB:

brew tap mongodb/brew
brew install mongodb-community@4.0

然后我可以使用以下方式在前台运行它:

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

但是,当尝试使用以下命令将其作为服务启动时:

brew services start mongodb-community@4.0

我遇到了这个错误:

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

当我运行brew doctor时,也会遇到这个错误:


I also get this error when running brew doctor:
Warning: Some installed formulae are not readable:
  mongodb-community: uninitialized constant #<Class:0x00007ffd903152a0>::Gem

为什么会发生这种情况?我该如何修复它?

谢谢!


请问您能否检查一下它是否可以在不作为Mac OS服务运行的情况下正常运行?打开终端并运行命令mongod。 - Sathiraumesh
你的 MacOS 具体版本是什么?(可以通过终端输入 sw_vers -productVersion 进行检查) - Stennie
MacOS 版本:10.14.4 - RyanDay
3
有人解决了这个问题吗?我也遇到了同样的问题,现在已经纠结了好几个小时了。 - Will de la Vega
我也遇到了同样的问题。 - num8er
显示剩余4条评论
2个回答

10

这是mongodb-community配方的一个错误。维护人员已经提交了问题,找到了解决方法并且打开了修复补丁的拉取请求

与此同时,您可以自己修复这个错误。在公式中这一行会引发异常。

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

因为 Gem 类没有被导入。添加导入:

require 'rubygems'

解决问题。你可以在本地完成,通过找到并编辑计算公式。这个文件很可能在这里:

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

更新: 社区贡献者已经在上游修复了此问题。如果你仍然遇到此问题,您可能需要运行 brew update。


1
很好的研究,谢谢 (: - num8er

4

我知道这不是正确的答案,因为我们正在讨论使用以下方式注册服务:

brew services start mongodb-community

但我用以下方法解决了服务注册的问题:SOLVED

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

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接