【问题标题】:Rails - Trouble installing capybara-webkitRails - 安装 capybara-webkit 时遇到问题
【发布时间】:2018-01-11 10:41:54
【问题描述】:

我有一个 Rails 5 应用程序,它在引导模式中包含多个表单。 Capybara 无法阅读模态内容。从阅读其他几篇堆栈溢出文章来看,我似乎需要安装 capybara-webkit gem。但是,我无法安装它。

在我的初始安装中,我收到一条错误消息:

Command 'qmake ' not available

extconf failed, exit code 1

Gem files will remain installed in
/Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/capybara-webkit-1.14.0 for inspection.
Results logged to

An error occurred while installing capybara-webkit (1.14.0), and Bundler cannot continue.
Make sure that `gem install capybara-webkit -v '1.14.0'` succeeds before bundling.

看了一圈,好像需要安装QT。所以我尝试使用本文中的说明进行安装:https://github.com/thoughtbot/capybara-webkit/wiki/Installing-Qt-and-compiling-capybara-webkit

我在 OS X El Capitan 上,所以我跑了:

brew install qt@5.5

然后我按照说明在命令行中输入了这个(我相信。这可能是我搞砸的地方):

echo 'export PATH="$(brew --prefix qt@5.5)/bin:$PATH"' >> ~/.bashrc

我尝试再次安装 gem,但遇到了完全相同的问题:

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

current directory: 
/Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/capybara-webkit-1.14.0
/Users/johnseabolt/.rbenv/versions/2.3.1/bin/ruby -r ./siteconf20170803-82842-1br8b1h.rb extconf.rb
*** 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/johnseabolt/.rbenv/versions/2.3.1/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 ' not available

extconf failed, exit code 1

Gem files will remain installed in
/Users/johnseabolt/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/capybara-webkit-1.14.0 for inspection.
Results logged to


An error occurred while installing capybara-webkit (1.14.0), and Bundler cannot continue.
Make sure that `gem install capybara-webkit -v '1.14.0'` succeeds before bundling.

我不能让它工作?救命!

【问题讨论】:

    标签: ruby-on-rails macos qt rspec-rails capybara-webkit


    【解决方案1】:

    使用echo 示例,您刚刚将导出添加到您的 .bashrc - 不过,您仍然需要确保将其加载到当前的 PATH 环境变量中。最简单的方法是关闭当前 shell 并打开一个新 shell,但是我通常发现使用

    brew link --force qt@5.5
    

    话虽如此,capybara-webkit 的 JS 支持已经过时,需要转译和 polyfill 来测试大多数现代应用程序。作为使用 Capybara 测试 JS 依赖应用程序的初学者,您最好使用 selenium 和 chrome - https://github.com/teamcapybara/capybara#configuring-and-adding-drivers - 而不是capybara-webkit

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-08-12
      • 2015-02-20
      • 2012-07-29
      • 2014-06-28
      • 1970-01-01
      • 2012-01-12
      相关资源
      最近更新 更多