ruby MongoDB通过Brew Services“undefined method `plist_startup '”

rkttyhzu  于 9个月前  发布在  Ruby
关注(0)|答案(6)|浏览(200)

当我运行MongoDB时,我通常手动启动它(即它不是我登录启动项目的一部分),并且我擅长在关闭之前停止服务。
我最近重新启动了我的笔记本电脑,并在运行时收到一个错误:

brew services run mongodb/brew/mongodb-community

字符串
错误消息如下:
错误:Undefined method `plist_startup' for #<Formula mongodb-community(stable)/usr/local/Homebrew/Library/Taps/mongodb/homebrew-brew/Formula/mongodb-community.rb>
我不完全确定发生了什么。我没有安装任何重大更新或对我的环境进行任何修改。

What I've Tried

在重新安装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

当前安装

第一个月

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

可能是家酿.?

老实说,有时候在这些深夜,我处于自动驾驶状态。我可能在某个时候运行了brew upgrade,也可能没有。我会检查一下是否发生了这种情况。同时,当我在Homebrew中获得MongoDB的日志时,我甚至没有看到会影响我的提交:

brew log mongodb/brew/mongodb-community

# Yields...

commit f33a59b6642f6a9f47f84b390dd71c386998cce6
Author: Zack Winter <[email protected]>
Date:   Wed Oct 4 23:24:26 2023 +0000

    Update paths with mr script

commit 7f3db6dbe9231300cc61645c68686a970b575f1f
Author: Zack Winter <[email protected]>
Date:   Tue Oct 3 20:00:06 2023 +0000

    SERVER-80537 update formulas for 7.0.1 release

commit 5055c34131148681885ea2241abccfc603596295
Author: Alexander Neben <[email protected]>
Date:   Fri Aug 18 10:54:02 2023 -0700

fdx2calv

fdx2calv1#

这个肮脏的黑客为我工作:
编辑此文件:
第一个月
更改线路:
@service_startup ||= formula.plist_startup.present?

@service_startup ||= formula.plist_name.present?

fbcarpbf

fbcarpbf2#

最近Homebrew更新到了4.2,这改变了它启动服务的方式。它要求mongodb公式显式定义一个服务块,即使只是指向服务文件。
修复程序已合并到https://github.com/mongodb/homebrew-brew/commit/2d0bfe19214d1f5071decd238b29306a6e82fff2

twh00eeo

twh00eeo3#

我最近遇到了这个问题,并浏览了上面的整个列表。这是我和我的Mac工作。我去了MongoDB,发现MongoDB。当我点击应用程序时,它表明我的计算机认为它是恶意的。我必须右键单击并手动允许它打开。然后当我回到指南针时,我能够连接。

vsdwdz23

vsdwdz234#

启动脚本更改

FAIL...see [UPDATE] at the bottom

我不知道是怎么回事,也不知道为什么,但似乎启动脚本必须改变。下面是我让MongoDB重新启动并重新运行的步骤,尽管我建议先跳过尝试启动MongoDB的替代方案。

使用MongoDB

我第一次尝试通过Homebrew强制重新安装MongoDB。当然,我的努力是徒劳的:

brew reinstall mongodb/brew/mongodb-community

字符串

已卸载Homebrew

这是恼人的,因为它基本上断开了自己与任何它曾经安装过的东西的连接。如果你想像往常一样快速更新,你必须重新安装所有东西。很容易列出一个列表并运行批量安装:

brew leaves

但是,要小心:这并不包括你所有的桶。我忘了做我的清单,并检查了两次这个假期。如果你想有一个 Package 精美的家酿,一定要运行这个:

brew list --cask   #add the "-1" to the end if you want a vertical list.

重新安装旧版Homebrew

我回去找到了Homebrew-4.1.23.pkg的安装程序包,当我不知道如何从脚本安装以前的版本时,就通过GUI安装了。
不幸的是,在运行任何类型的brew install ...命令之前,我忘记设置这个变量:

export HOMEBREW_NO_AUTO_UPDATE=1;


.soooooo,ya.一旦我运行任何brew命令,它就会将我升级到我开始认为有问题的地方。* 你不高兴跳到最后而不是按照这些步骤吗?*

替代方法

FWIW-当重新安装MongoDB时,我遵循了一个与我习惯的不同的路径; * 与我为系统设置编写的脚本不同 *。我使用了MongoDB文档中描述的方法:

brew install [email protected]

更改MongoDB启动方式

在我的配置文件脚本中,我有一些函数用于管理MongoDB的启动/停止。例如,我的run MongoDB脚本如下所示:

function mongo-run {
    pid=$(ps -A | grep '[mon]god' | awk '{printf "%d", $1}');
    if [[ -z $pid ]];then
        brew services run mongodb/brew/mongodb-community;
    else
        printf "
        ${txtblu}Mongo is already running with process ID ${bldblu}$pid${txtrst}\n";
    fi
}


...我所做的就是变成这样:

function mongo-run {
    pid=$(ps -A | grep '[mon]god' | awk '{printf "%d", $1}');
    if [[ -z $pid ]];then
        brew services run mongodb-community;
    else
        printf "
        ${txtblu}Mongo is already running with process ID ${bldblu}$pid${txtrst}\n";
    fi
}


如果你错过了:

# This...
brew services run mongodb/brew/mongodb-community;

# changed to this...
brew services run mongodb-community;

Pretty ridiculous, right?

哦,好吧。现在一切都恢复正常了。

更新

我不知道我做了什么,确切地说,但我再次遇到了最初的错误消息。
奇怪的是,在我运行Homebrew命令来删除和清理MongoDB相关的东西之后,我运行brew services run mongodb-community命令并得到了 * 错误 * 错误消息.好像在我运行卸载和清理命令之后.rb脚本没有被删除一样。
我最终完全重新安装了它(MongoDB,不是Homebrew),仍然看到错误。

  • 我还确保我的Mac上没有其他Ruby安装,只有默认的v2.6
3vpjnl9f

3vpjnl9f5#

在mac m1上,我做的一个修复是添加手动启动数据库的命令。

自动运行

第一步:找到你的mongod.conf在哪里,它应该在etc文件夹中,但取决于你有哪种芯片。所以做brew --prefix检查。我在m1中,所以我的是在上述,但你可能会说/usr/local在这种情况下检查/usr/local/etc
步骤2.打开你的.zshrc文件。这应该在你的主目录下。如果你不在zsh上,那么检查一个.bashrc文件。
步骤3.在rc文件add.mongod --config /opt/homebrew/etc/mongod.conf &的末尾,这将在每次打开终端时运行手动启动数据库的命令。末尾的&是为了确保它在后台运行。
这似乎是工作,它可以得到恼人的,如果你想使用指南针,你需要打开一个终端来启动数据库。然而,我认为这是一个解决方案,在此期间,直到开发人员推动更新。

eivgtgni

eivgtgni6#

另一种选择

目前,这已经被证明是有用的。我想删除root作为服务的执行用户。我不确定它对其他人有多大用处,但是(使用任何程序员可能说出的最糟糕的短语)“它在我的机器上工作:“

# Be sure to insert your user name in the next line...
sudo brew services run mongodb-community --sudo-service-user <your.user.name>
brew services ls
sudo brew services stop mongodb-community
brew services start mongodb-community

字符串

分解

在运行第一个命令后,我看到服务下面有我的用户名,即使它没有运行。在以前的尝试中,这总是说root

brew services ls
# Yields...
Name              Status  User       File
docker-machine    none               
mongodb-community started <your.user.name>


出于迷信,我跑了第三条线,希望需要清理的东西得到清理。
当我运行最后一个命令,start服务,并重新启动我的机器,一切正常。我今天有一对夫妇重新启动,到目前为止一切顺利。

brew services ls
# After rebooting this yields...
Name              Status  User       File
docker-machine    none               
mongodb-community started <your.user.name> ~/Library/LaunchAgents/homebrew.mxcl.mongodb-community.plist


<$*()*/<$

相关问题