当我运行MongoDB时,我通常手动启动它(即它不是我登录启动项目的一部分),我很擅长在关闭之前停止服务.

我最近重新启动了我的笔记本电脑,并在运行时收到一个错误:

brew services run mongodb/brew/mongodb-community

错误消息如下:

错误:#<公式mongodb-Community(STRATE)/usr/local/Homebrew/Library/Taps/mongodb/homebrew-brew/Formula/mongodb-community.rb>的方法`plist_start‘未定义

我不完全确定发生了什么.我还没有安装任何重大更新,也没有对我的环境进行任何修改.

我try 了什么

我完全卸载了MongoDB,然后才重新安装:

# Uninstall each component of mongodb-community...
brew uninstall mongodb/brew/mongodb-community
brew uninstall mongodb/brew/mongodb-database-tools
brew uninstall mongosh

# Reinstall all of the above...
brew install mongodb/brew/mongodb-community

Current Install

mongod --version

db version v7.0.2
Build Info: {
    "version": "7.0.2",
    "gitVersion": "02b3c655e1302209ef046da6ba3ef6749dd0b62a",
    "modules": [],
    "allocator": "system",
    "environment": {
        "distarch": "x86_64",
        "target_arch": "x86_64"
    }
}

Could be Homebrew...?

老实说,有时在这些深夜,我处于自动驾驶状态.在某种程度上,我可能跑过brew upgrade分,也可能没有跑过.我会调查这件事是否发生过.同时,当我在Homebrew中获得MongoDB的日志(log)时,我甚至没有看到会影响我的提交:

brew log mongodb/brew/mongodb-community

# Yields...

commit f33a59b6642f6a9f47f84b390dd71c386998cce6
Author: Zack Winter <zack.winter@mongodb.com>
Date:   Wed Oct 4 23:24:26 2023 +0000

    Update paths with mr script

commit 7f3db6dbe9231300cc61645c68686a970b575f1f
Author: Zack Winter <zack.winter@mongodb.com>
Date:   Tue Oct 3 20:00:06 2023 +0000

    SERVER-80537 update formulas for 7.0.1 release

commit 5055c34131148681885ea2241abccfc603596295
Author: Alexander Neben <alexander.neben@mongodb.com>
Date:   Fri Aug 18 10:54:02 2023 -0700

推荐答案

最近,Homebrew更新到了4.2,这改变了它启动服务的方式.它需要MongoDB公式来显式定义服务块,即使只是指向服务文件.

修复程序在https://github.com/mongodb/homebrew-brew/commit/2d0bfe19214d1f5071decd238b29306a6e82fff2年被合并

Ruby相关问答推荐

Ruby Case语句和固定,不适用于attr_reader

方法应该以 (?问号)结尾吗?只返回一个布尔值?

如何从 Ruby 中的线程返回值?

在 gem 中放置/访问配置文件的位置?

Ruby 对象打印为指针

Ruby:将unix时间戳转换为日期

Ruby 中的关联数组

如何在 Ruby 中临时重定向标准错误?

如何使用 Ruby 2.3 中引入的 Array#dig 和 Hash#dig?

如何从 SystemStackError 中获取回溯:堆栈级别太深?

迭代一个数组,一次 n 项

使用 for each 时识别最后一个循环

从类对象获取类位置

Sinatra 登录?

是否可以使用 Ruby 读取文件的修改日期?

使用 RSpec 判断某物是否是另一个对象的实例

如何判断变量是数字还是字符串?

以小时为单位的时差

使用 Liquid 标记在 Jekyll 中获取今天的日期

传递块时 Array#sort 如何工作?