无法启动Rails应用程序。 (qrencoder)

时间:2016-04-04 13:59:26

标签: rubygems

我需要处理现有项目,但是当我尝试启动服务器rails s时,它给了我以下错误:

  

https://github.com/pjaspers/mina.git(at   pj-write-sha-to-revision-file @ 5826023)尚未签出。跑   bundle install首先。

所以我跑了bundle install,过了一会儿就说:

Installing qrencoder 1.4.1 with native extensions

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

    current directory: C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/qrencoder-1.4.1/ext/qrencoder_ext
C:/RailsInstaller/Ruby2.2.0/bin/ruby.exe -r ./siteconf20160404-20756-46gi3z.rb extconf.rb
checking for qrencode.h... no
*** 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=C:/RailsInstaller/Ruby2.2.0/bin/$(RUBY_BASE_NAME)
        --with-qrencoder-dir
        --without-qrencoder-dir
        --with-qrencoder-include
        --without-qrencoder-include=${qrencoder-dir}/include
        --with-qrencoder-lib
        --without-qrencoder-lib=${qrencoder-dir}/lib

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/extensions/x86-mingw32/2.2.0/qrencoder-1.4.1/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/qrencoder-1.4.1 for inspection.
Results logged to C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/extensions/x86-mingw32/2.2.0/qrencoder-1.4.1/gem_make.out
Installing coffee-script 2.2.0
Installing rdoc 3.12.2
Installing uglifier 2.4.0
Installing less 2.4.0
Installing thin 1.6.1 with native extensions
Installing faraday 0.9.2
Installing rb-inotify 0.9.3
Installing foreman 0.63.0
Installing zeus 0.13.3 with native extensions
Installing pry 0.9.12.6
Installing mocha 1.0.0
Using mina 0.3.1 from https://github.com/pjaspers/mina.git (at pj-write-sha-to-revision-file@5826023)
Installing prawn 1.1.0
Installing remote_syslog_logger 1.0.3
Installing spreadsheet 0.9.7
Installing activemodel 3.2.13
Installing factory_girl 4.2.0
Installing whenever 0.8.2
Installing mail 2.5.4
Installing akami 1.2.1
Installing wasabi 2.5.1
Installing celluloid-io 0.15.0
An error occurred while installing qrencoder (1.4.1), and Bundler cannot
continue.
Make sure that `gem install qrencoder -v '1.4.1'` succeeds before bundling.

所以我跑gem install qrencoder -v '1.4.1'并得到以下消息

Temporarily enhancing PATH to include DevKit...
Building native extensions.  This could take a while...
ERROR:  Error installing qrencoder:
        ERROR: Failed to build gem native extension.

    current directory: C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/qrencoder-1.4.1/ext/qrencoder_ext
C:/RailsInstaller/Ruby2.2.0/bin/ruby.exe -r ./siteconf20160404-15392-b8moz7.rb extconf.rb
checking for qrencode.h... no
*** 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=C:/RailsInstaller/Ruby2.2.0/bin/$(RUBY_BASE_NAME)
        --with-qrencoder-dir
        --without-qrencoder-dir
        --with-qrencoder-include
        --without-qrencoder-include=${qrencoder-dir}/include
        --with-qrencoder-lib
        --without-qrencoder-lib=${qrencoder-dir}/lib

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/extensions/x86-mingw32/2.2.0/qrencoder-1.4.1/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/qrencoder-1.4.1 for inspection.
Results logged to C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/extensions/x86-mingw32/2.2.0/qrencoder-1.4.1/gem_make.out

然后日志给了我以下内容:

have_header: checking for qrencode.h... -------------------- no

"gcc -o conftest.exe -IC:/RailsInstaller/Ruby2.2.0/include/ruby-2.2.0/i386-mingw32 -IC:/RailsInstaller/Ruby2.2.0/include/ruby-2.2.0/ruby/backward -IC:/RailsInstaller/Ruby2.2.0/include/ruby-2.2.0 -I. -DFD_SETSIZE=2048 -D_WIN32_WINNT=0x0501 -D__MINGW_USE_VC2005_COMPAT -D_FILE_OFFSET_BITS=64   -O3 -fno-omit-frame-pointer -fno-fast-math -g -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat conftest.c  -L. -LC:/RailsInstaller/Ruby2.2.0/lib -L.      -lmsvcrt-ruby220  -lshell32 -lws2_32 -liphlpapi -limagehlp -lshlwapi  "
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: #include <winsock2.h>
4: #include <windows.h>
5: int main(int argc, char **argv)
6: {
7:   return 0;
8: }
/* end */

"gcc -E -IC:/RailsInstaller/Ruby2.2.0/include/ruby-2.2.0/i386-mingw32 -IC:/RailsInstaller/Ruby2.2.0/include/ruby-2.2.0/ruby/backward -IC:/RailsInstaller/Ruby2.2.0/include/ruby-2.2.0 -I. -DFD_SETSIZE=2048 -D_WIN32_WINNT=0x0501 -D__MINGW_USE_VC2005_COMPAT -D_FILE_OFFSET_BITS=64   -O3 -fno-omit-frame-pointer -fno-fast-math -g -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat  conftest.c -o conftest.i"
conftest.c:5:22: fatal error: qrencode.h: No such file or directory
compilation terminated.
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: #include <winsock2.h>
4: #include <windows.h>
5: #include <qrencode.h>
/* end */

--------------------

老实说,我不知道如何继续和/或如何安装这个gem /依赖,任何建议?

更新1

也尝试了以下内容:

  1. 下载了qrencoder.gem文件并运行了gem install --local C:\Users\Edward\Downloads\qrencoder-1.4.1.gem
  2. 从github下载qrencoder源并运行gem install qrencoder -- -- with-qrencoder-dir=C:\RailsInstaller\Ruby2.2.0\lib\ruby\gems\2.2.0\gems\qrencoder-1.4.1\libqrencode-master
  3. 但仍然遇到相同的错误:找不到.h文件

    更新2

    以下都没有奏效:

    gem install qrencoder -- --with-qrencoder-lib=C:\qrencode-win32\qrencode-win32
    
    gem install qrencoder -- --with-qrencoder-include=C:\qrencode-win32\qrencode-win32
    
    gem install qrencoder -- --with-qrencoder-dir=C:\qrencode-win32\qrencode-win32
    

    但以下问题解决了checking for qrencode.h... no问题,但提供了以下内容:checking for QRinput_new() in -lqrencode... no

    gem install qrencoder -- --with-qrencoder-dir=C:\qrencode-win32\qrencode-win32 --with-qrencoder-lib=C:\qrencode-win32\qrencode-win32 --with-qrencoder-include=C:\qrencode-win32\qrencode-win32
    

3 个答案:

答案 0 :(得分:0)

根据qrencode doc(http://fukuchi.org/works/qrencode/index.html.en):如果您尝试在MS-Windows上编译此库,则需要cygwin或某些类似UNIX的环境。

你至少应该使用cygwin,最好的选择是在Linux VM中运行你的rails环境。

答案 1 :(得分:0)

你需要以某种方式(我在OS X上)在你的Windows机器上安装/拥有libqrencode

答案 2 :(得分:0)

如果您按照宝石的自述文件,它会提到您需要一个库。 图书馆提到有一个Windows版本。尝试安装它并报告结果

https://code.google.com/archive/p/qrencode-win32/wikis/Downloads.wiki

我没有Windows计算机来检查它,但安装程序可能会包含一些信息。

作为一般说明,如果您学习阅读并理解安装宝石时可能遇到的异常,它将对您有所帮助。

在此示例中,您可以找到行checking for qrencode.h... no,这意味着编译器正在查找qrencode.h头文件但未找到它。然后你可以回去寻找宝石页面上的需求部分,并找到我上面提到的信息。