在使用OS X 10.10 Yosemite Beta时,使用Homebrew重新安装MongoDB遇到了问题。

29

重申一下,我正在运行第一个OS X 10.10测试版,并尝试使用Homebrew重新安装MongoDB。

运行$ brew install mongodb后,输出如下:

==> Downloading http://downloads.mongodb.org/src/mongodb-src-r2.6.1.tar.gz
==> /usr/local/opt/scons/bin/scons install --prefix=/usr/local/Cellar/mongodb/2.6.1 -j8 --cc=/usr/bin/clang --cxx=/usr/bin/clang++ --osx-version-min=10.10 --full --64
scons: Reading SConscript files ...
Mkdir(".scons/Darwin/nohost")
usage: scons [OPTION] [TARGET] ...

SCons Error: option --osx-version-min: invalid choice: '10.10' (choose from '10.6', '10.7', '10.8', '10.9')

显然安装包未针对10.10进行配置,因为它尚未发布给公众。

在构建过程中是否有手动绕过此问题的方法?

4个回答

88

这个问题很可能会在MongoDB的较新版本中得到修复(https://jira.mongodb.org/browse/SERVER-14204),目前只需打补丁即可。

brew edit mongodb

找到长这样的区块:

args = %W[
  --prefix=#{prefix}
  -j#{ENV.make_jobs}
  --cc=#{ENV.cc}
  --cxx=#{ENV.cxx}
  --osx-version-min=#{MacOS.version}
]

将 OS X 版本最低要求更改为 10.9,如下所示:

args = %W[
  --prefix=#{prefix}
  -j#{ENV.make_jobs}
  --cc=#{ENV.cc}
  --cxx=#{ENV.cxx}
  --osx-version-min=10.9
]

编辑:DP3、DP4、PB1需要额外步骤

在文件中仍然保留以下三行,放置在 def install 代码块的上方。

  def patches
    { :p1 => 'https://gist.githubusercontent.com/LinusU/a1771562fec0201c54cd/raw/98825f9fbe93b8cc524e05a9c0e99864e8301731/mongodb.diff' }
  end

然后执行升级:

brew upgrade mongodb

3
这个对我没帮助。生成了2个错误。 scons: *** [build/darwin/64/cc__usr_bin_clang/cxx__usr_bin_clang++/osx-version-min_10.9/third_party/s2/s2cellid.o] 错误1 scons: 因为有错误,构建被终止。 - Anton Danilchenko
1
@isal 你是否使用了最新版本的Homebrew?请执行brew update命令更新。此外,该帖子表明这只是一个警告,可以忽略:https://github.com/Homebrew/homebrew/issues/29988 - Linus Unnebäck
尝试了一下,虽然升级时间比平常长,但是成功了。当我尝试通过 launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mongodb.plist 启动mongodb时,出现了“服务已禁用”的消息。我通过 brew services restart mongodb 重新启动,虽然出现了“brew services不支持”的提示,但是它成功启动了,一切都很好。 - Angel S. Moreno
在执行 brew upgrade mongodb 后,我遇到了一个错误:Error: MongoDB not installed - user101289
@user101289 这意味着你需要运行 brew install mongodb 而不是 brew upgrade mongodb - Lunf
显示剩余8条评论

4

仅提一下 - 这个问题已经解决。
于今天(2014年10月13日)通过$ brew install mongodb构建和安装完成。

==> Summary
  /usr/local/Cellar/mongodb/2.6.5: 17 files, 331M, built in 21.6 minutes

3
如果Linus描述的步骤不足够,请执行以下额外步骤(10.10 beta 3 和 beta 4):
  1. cd /Library/Caches/Homebrew/
  2. tar xvfz mongodb-2.6.3.tar.gz
  3. cd mongodb-src-r2.6.3
  4. vi src/third_party/s2/util/endian/endian.h
  5. Uncomment lines 181-189

    // This one is safe to take as it's an extension
    //#define htonll(x) ghtonll(x)
    //
    // ntoh* and hton* are the same thing for any size and bytesex,
    // since the function is an involution, i.e., its own inverse.
    //#define gntohl(x) ghtonl(x)
    //#define gntohs(x) ghtons(x)
    //#define gntohll(x) ghtonll(x)
    //#define ntohll(x) htonll(x)
    
  6. cd ..
  7. rm mongodb-2.6.3.tar.gz
  8. tar cvfz mongodb-2.6.3.tar.gz mongodb-src-r2.6.3
  9. brew install mongodb

    ==> Downloading http://downloads.mongodb.org/src/mongodb-src-r2.6.3.tar.gz
    Already downloaded: /Library/Caches/Homebrew/mongodb-2.6.3.tar.gz
    Error: SHA1 mismatch
    Expected: 226ab45e3a2e4d4a749271f1bce393ea8358d3dd
    Actual: 593bbe9cb7e0b1d2368b3b6487893e8ba459acfb
    Archive: /Library/Caches/Homebrew/mongodb-2.6.3.tar.gz
    
  10. Copy the actual SHA1
  11. brew edit mongodb
  12. Replace the expected SHA1 value with the actual one.
  13. brew install mongodb
  14. rm -rf mongodb-src-r2.6.3

1
我已经更新了我的答案,加入了你的补丁,谢谢!为了避免修改源代码,我将其添加到公式中,这样brew本身就可以下载并进行实际的修补。 - Linus Unnebäck

1

对我来说有效。当前的GIT仓库与Yosemite兼容。但在安装mongodb之前,我需要pymongo。很容易 sudo pip install pymongo - iraycd

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