自制软件不能 运行 我自己的公式

homebrew can't run my own formula

我只是按照说明从 github 创建我的 "own" 自制软件公式,遵循本教程 http://formalfriday.club/2015/01/05/creating-your-own-homebrew-tap-and-formula.html, 实际上我只是想安装 mongodb 旧版本,所以我检查了自制软件 mongodb 源代码(因为我喜欢使用自制软件的所有东西,懒人呃...):

https://github.com/Homebrew/homebrew/blob/master/Library/Formula/mongodb.rb

我只想更改第 6 行:

 url "https://fastdl.mongodb.org/src/mongodb-src-r3.0.1.tar.gz"

进入:

 url "https://fastdl.mongodb.org/src/mongodb-src-r3.0.0.tar.gz"

仅此而已,只是版本号,所以我复制了所有的源代码,并创建了我自己的公式,但是当我 运行 brew 命令时,我得到了很多错误,包括:

/usr/local/bin/mongold: line 2: require: command not found
/usr/local/bin/mongold: line 3: require: command not found
/usr/local/bin/mongold: line 5: Formula: No such file or directory
/usr/local/bin/mongold: line 6: homepage: command not found
/usr/local/bin/mongold: line 7: url: command not found
/usr/local/bin/mongold: line 8: sha256: command not found
/usr/local/bin/mongold: line 12: depends_on: command not found
/usr/local/bin/mongold: line 13: go_resource: command not found
/usr/local/bin/mongold: line 14: url: command not found
/usr/local/bin/mongold: line 15: :tag: command not found
/usr/local/bin/mongold: line 16: :revision: command not found
/usr/local/bin/mongold: line 17: end: command not found
/usr/local/bin/mongold: line 19: bottle: command not found
/usr/local/bin/mongold: line 20: sha256: command not found
/usr/local/bin/mongold: line 21: sha256: command not found
/usr/local/bin/mongold: line 22: sha256: command not found
/usr/local/bin/mongold: line 23: end: command not found
/usr/local/bin/mongold: line 25: option: command not found
/usr/local/bin/mongold: line 27: depends_on: command not found
/usr/local/bin/mongold: line 28: depends_on: command not found
/usr/local/bin/mongold: line 29: depends_on: command not found
/usr/local/bin/mongold: line 30: depends_on: command not found
/usr/local/bin/mongold: line 32: def: command not found
/usr/local/bin/mongold: line 36: Language::Go.stage_deps: command not found
/usr/local/bin/mongold: line 38: cd: src/github.com/mongodb/mongo-tools: No such file or directory
/usr/local/bin/mongold: line 39: args: command not found
/usr/local/bin/mongold: line 134: syntax error: unexpected end of file

我做错了什么吗?我是 ruby 和 brew 的新手,谢谢

brew install ./mongo_old.rb安装(前面的./比较特殊);公式是 Ruby 代码,不能直接执行。

希望您解决了问题。添加此答案以供其他读者将来参考;

Formula-Cookbook is your friend. You may also refer https://medium.com/ballerina-techblog/how-to-create-your-own-homebrew-package-or-formula-8dfbf8e001d3 用于创建新公式(免责声明:我写的)。

尝试以下简单步骤;

  • 创建新公式; brew create <URLOfTheDistribution>
  • 然后调试; brew install --debug <NewFormula>