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



我的配置是MAC Mojave v10.14。

我尝试安装需要 qt5.5 的 gem Capybara-webkit -v '1.15.0',但 qt5.5 已被从自制软件中删除,并且与 Xcode v10 不兼容。

我试试这个:

  • 卸载 Xcode v10
  • 安装 Xcode 9.4.1,developer.apple.com/
  • 安装qt5.5,我在 qt.io/的档案中找到了它
  • 运行捆绑包

但它失败了,我的错误在于宝石水豚网络套件 -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

但是错误仍然存在...

感谢您的帮助!

正如 capybara-webkit wiki 上描述的那样,capybara-webkit依赖于 Qt 5.5。"Qt 5.5是capybara-webkit将支持的Qt的最后一个版本。Qt项目在5.6中从二进制版本中删除了WebKit绑定。

要安装 Qt 5.5,请按照 wiki 中的说明进行操作。对于莫哈韦,说明如下。

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 不兼容。Xcode 9.4 可以从 Apple 开发者门户下载。这是一个 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


免责声明:我通过编译多个问题和答案并试图记住我在本地机器上运行命令的顺序得出了上述答案。我可能不小心省略了一些步骤。

以下是对我有用的方法,在这里找到:

  • 保持您的 xcode v10 安装
  • 从他们的网站手动下载并安装 Qt 5.5
  • 将Qt的bin路径添加到你的PATH环境变量中,方法是将其添加到你的.bashrc.zshrc或你拥有的任何其他shell配置中:(确保用你的Qt/Applications/Qt/5.5/clang_64/binbin path替换
  • (
export PATH="/Applications/Qt/5.5/clang_64/bin:$PATH" # Add Qt bin to path for capybara webkit to work
  • 运行gem install capybara-webkit

我认为我的问题出在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

它有效(y(!

您需要Xcode 9.4.1才能安装qt@5.5,因为它与Xcode 10不兼容。Homebrew 已从其核心水龙头中删除了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,因此此命令回滚到父提交并签出所需的公式文件。

我可以在Mojave上安装qt@5.5

brew install qt@5.5 --force-bottle

使用水豚网络套件,我暂时使用这个:

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

最新更新