Mac OS 10.14 Mojave + qt5.5 + gem capybara-webkit

7

我的配置是MAC Mojave v10.14。

我尝试安装gem Capybara-webkit -v '1.15.0',它需要qt5.5,但homebrew已经移除了qt5.5,并且它与Xcode v10不兼容。

我尝试了以下步骤:

  • 卸载Xcode v10
  • 安装在developer.apple.com/上找到的Xcode 9.4.1
  • 安装qt5.5,在qt.io/存档中找到它
  • 运行bundle命令

但是它失败了,我的错误出现在gem capybara-webkit -v '1.15.0':

Fetching capybara-webkit 1.15.0
Installing capybara-webkit 1.15.0 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

current directory: 
/Users/thomas/.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0/gems/capybara- 
webkit-1.15.0
/Users/thomas/.rbenv/versions/2.4.4/bin/ruby -r ./siteconf20181005-763-1bppnfh.rb extconf.rb
Project ERROR: Xcode not set up properly. You may need to confirm the license agreement by running /usr/bin/xcodebuild.
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/Users/thomas/.rbenv/versions/2.4.4/bin/$(RUBY_BASE_NAME)
--with-gl-dir
--without-gl-dir
--with-gl-include
--without-gl-include=${gl-dir}/include
--with-gl-lib
--without-gl-lib=${gl-dir}/lib
--with-zlib-dir
--without-zlib-dir
--with-zlib-include
--without-zlib-include=${zlib-dir}/include
--with-zlib-lib
--without-zlib-lib=${zlib-dir}/lib
Command 'qmake ' failed

extconf failed, exit code 1

 Gem files will remain installed in 
/Users/thomas/.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0/gems/capybara-webkit-1.15.0 for inspection.
Results logged to /Users/thomas/.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0/extensions/x86_64- darwin-18/2.4.0-static/capybara-webkit-1.15.0/gem_make.out

An error occurred while installing capybara-webkit (1.15.0), and Bundler 
cannot continue.
Make sure that `gem install capybara-webkit -v '1.15.0' --source 
'https://rubygems.org/'` succeeds before bundling.

In Gemfile:
capybara-webkit

接下来,我执行了以下命令:

sudo xcodebuild -license agree

但错误仍然存在...

谢谢你的帮助!


请将您的解决方案发布为问题的答案。然后您可以接受自己的答案。这样,如果其他人遇到类似的问题,就更容易搜索到。 - Adam Richardson
5个回答

8
根据 capybara-webkit wiki 上的描述,capybara-webkit 依赖于 Qt 5.5。"Qt 5.5 是 capybara-webkit 将支持的最后一个版本。Qt 项目在 5.6 中从二进制版本中删除了 WebKit 绑定。"
要安装 Qt 5.5,请按照 wiki 上的说明进行操作。对于 Mojave,以下是说明。
brew update
cd $( brew --prefix )/Homebrew/Library/Taps/homebrew/homebrew-core
git checkout 9ba3d6ef8891e5c15dbdc9333f857b13711d4e97 Formula/qt@5.5.rb
brew install qt@5.5
echo 'export PATH="$(brew --prefix qt@5.5)/bin:$PATH"' >> ~/.bashrc

您可以通过运行以下命令来确认此步骤已完成:
$ which qmake
/usr/local/opt/qt@5.5/bin/qmake

接下来,您需要安装Xcode 9.4。 Xcode 10不兼容Qt 5.5。可以从Apple开发者门户网站下载Xcode 9.4。这是一个4GB的下载文件,需要大约30分钟下载和安装。您可以通过运行以下命令来验证它是否正确安装:

$ /usr/bin/xcodebuild -version
Xcode 9.4.1
Build version 9F2000

如果这不起作用,可能是因为您只安装了命令行工具而没有安装Xcode,此时您应该确保您下载了正确的Xcode版本。或者Xcode文件夹可能设置不正确。如果是这样,您可以使用xcode-select来修复,它将指定xcodebuild运行的文件夹:

sudo xcode-select -s /Applications/Xcode.app/Contents/Developer

当Xcode安装完成后,到应用程序文件夹找到它并打开,同意许可证。然后尝试重新安装capybara-webkit


免责声明:以上答案是我从多个问题和答案中编译而来,并尝试记住在本地计算机上运行命令的顺序。我可能会意外省略一些步骤。


完整的手册在这里 https://github.com/thoughtbot/capybara-webkit/wiki/Installing-Qt-and-compiling-capybara-webkit#homebrew。它有很有用的注释。帮助我在Mojave上安装了`capybara-webkit`。 - vctr
2
在OS X Mojave上运行brew install qt@5.5时出现错误:Error: qt@5.5: unknown version :mountain_lion - 根据这里的更新:https://dev59.com/nVQJ5IYBdhLWcg3wIiS5 似乎已经解决了这个问题。 - jec006

5
以下是我的做法,详见这里
  • 保留 xcode v10
  • 从Qt的网站上手动下载并安装Qt 5.5:下载链接
  • 将Qt的bin路径添加到你的PATH环境变量中。在.bashrc.zshrc或其他shell配置文件中添加以下内容:(请确保将/Applications/Qt/5.5/clang_64/bin替换为你实际的Qt bin路径)
export PATH="/Applications/Qt/5.5/clang_64/bin:$PATH" # Add Qt bin to path for capybara webkit to work
  • 运行gem install capybara-webkit

4
现在令人烦恼的是他们从网站上删除了Qt 5.5。链接已经失效。 - Bashar Abdullah
2
@BasharAbdullah,他们将其移动到https://download.qt.io/new_archive/qt/5.5/5.5.0/。 - Kiki Hakiem

2
我认为我的问题出在xcrun上。为了修复它,我做了以下操作:
  • sudo chown root:wheel /Applications/Xcode.app
  • sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
  • cd /Applications/Xcode.app/Contents/Developer/usr/bin/
  • sudo ln -s xcodebuild xcrun
这样就可以解决问题啦!

0
你需要 Xcode 9.4.1 来安装 qt@5.5,因为它不兼容 Xcode 10。Homebrew 已经从他们的核心 tap 中删除了 qt@5.5,所以在安装之前需要运行以下命令:
brew update
cd $( brew --prefix )/Homebrew/Library/Taps/homebrew/homebrew-core
git checkout 9ba3d6ef8891e5c15dbdc9333f857b13711d4e97 Formula/qt@5.5.rb
brew install qt@5.5

9ba3d6ef8891e5c15dbdc9333f857b13711d4e97360923286c0f1a6a1325ada578df030bf579009f 的父提交,他们在那里删除了 qt@5.5,因此此命令回滚到父提交并检出所需的配方文件。


2
我仍然无法安装Qt5.5。../src/corelib/global/qglobal.h:39:12: 致命错误:'cstddef'文件未找到 # include <cstddef> - alexventuraio
你在使用Homebrew吗? - Tarek N. Elsamni
是的,我已经从头重新安装了Mojave并安装了Xcode 9.4.1,并按照这些步骤进行了操作,但我仍然没有成功。我收到了Xcode和CommandLineTools过时的消息,因此我可以安装qt@5.5 - alexventuraio
1
注意:如果出现错误 fatal: reference is not a tree: 9ba3d6ef8891e5c15dbdc9333f857b13711d4e97,请使用 git fetch --unshallow 完成git历史记录。注意:如果出现错误 Error: qt@5.5: unknown version :mountain_lion,请注释 Formula/qt@5.5.rb 文件中第25行。更多详情请参考:https://github.com/thoughtbot/capybara-webkit/wiki/Installing-Qt-and-compiling-capybara-webkit#homebrew - vctr
无法解决Catalina错误:未知或不支持的macOS版本::mountain_lion - Gupta

0

我可以在Mojave上使用以下命令安装qt@5.5:

brew install qt@5.5 --force-bottle

对于capybara-webkit,我暂时使用以下命令:

gem "capybara-webkit", git: "https://github.com/emilyst/capybara-webkit.git", ref: "9c9af833656f095667e8522004dae017d423d37d"


1
这对我没用。错误:找不到名为“qt@5.5”的可用配方 ==>正在搜索以前删除的配方(在上个月)…… qt@5.5在提交360923286c中从homebrew/core中删除: qt@5.5: delete - beNjiox

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