Tiven

Tiven

博观而约取,厚积而薄发

天问的个人网站(天问博客),专注于Node.js、Vue.js、React、Vite、Npm、Nginx等大前端技术。不断学习新技术,记录日常开发问题,持续分享coding,极客开源,共同进步。生命不息,奋斗不止... [ hexo blog ]

mongo启动报错Error: uninitialized constant Homebrew::Service::System


在 Mac M1 系统上安装 MongoDB,启动报错:Error: uninitialized constant Homebrew::Service::System

Brew & MongoDB

问题复现

  1. brew tap mongodb/brew
  2. 使用 brew install mongodb-community (6.0.6) 安装 MongoDB,安装成功
  3. 使用 brew services start mongodb-community 启动 MongoDB,完整报错如下:
tiven@bogon ~ % brew services stop mongodb-community    
Error: uninitialized constant Homebrew::Service::System
/opt/homebrew/Library/Homebrew/macos_version.rb:150:in `const_missing'
/opt/homebrew/Library/Taps/homebrew/homebrew-services/cmd/services.rb:61:in `services'
/opt/homebrew/Library/Homebrew/brew.rb:94:in `<main>'

解决方案

  1. cd /opt/homebrew/Library/Taps/homebrew
  2. rm -rf ./homebrew-services
  3. brew tap homebrew/services

再次使用 brew services start mongodb-community 启动 MongoDB 就正常了。

# 启动
tiven@bogon homebrew % brew services start mongodb-community  
==> Successfully started `mongodb-community` (label: homebrew.mxcl.mongodb-commu

# 停止
tiven@bogon homebrew % brew services stop mongodb-community

欢迎访问:天问博客