sqlite3-ruby gem: Failed to build gem native extension

后端 未结 6 1043
眼角桃花
眼角桃花 2020-12-02 20:59

Update: Check out this follow-up question: Gem Update on Windows - is it broken?


On Windows, when I do this:

gem install sqlit         


        
相关标签:
6条回答
  • 2020-12-02 21:32

    Is it possible that the newest version has not yet been ported to Win32 yet? Since this particular gem does have bindings to compiled code, it would require a platform-specific gem. If I force installation of version 1.2.3 rather than the current 1.2.4, the platform-specific version does install, but when I allow gem to try to install the current version, I get the generic 1.2.4 version (in the gems library folder, it lacks the -x86-mswin32 suffix that the other sqlite3-ruby folders have in their names.

    Maybe someone else can answer how gem handles platform specific gems. Are separate gems uploaded for each platform and the gem software selects which one to pull down?

    0 讨论(0)
  • 2020-12-02 21:33

    I had the same problem on Ubuntu, this solved the problem for me:

    http://newsgroups.derkeiler.com/Archive/Comp/comp.lang.ruby/2008-08/msg00339.html

    0 讨论(0)
  • 2020-12-02 21:33

    I had the same problem on Windows and I have installe MinGW http://sourceforge.net/projects/mingw/files/Automated%20MinGW%20Installer/MinGW%205.1.6/MinGW-5.1.6.exe/download and the problem has gone :-)

    C:>gem install hpricot Successfully installed hpricot-0.8.2-x86-mswin32 1 gem installed Installing ri documentation for hpricot-0.8.2-x86-mswin32... Installing RDoc documentation for hpricot-0.8.2-x86-mswin32...

    C:>gem install ruby-postgres Successfully installed ruby-postgres-0.7.1.2006.04.06-x86-mswin32 1 gem installed Installing ri documentation for ruby-postgres-0.7.1.2006.04.06-x86-mswin32... Installing RDoc documentation for ruby-postgres-0.7.1.2006.04.06-x86-mswin32...

    0 讨论(0)
  • 2020-12-02 21:36

    As Nathan suggests, this does appear to be related to the fact that the latest versions of the sqlite3-ruby and hpricot gems don't appear to have Windows versions. Here's what to do when faced with this situation (note, the name of the gem is automatically wildcarded, so you can type just sql and get a list of all gems beginning with sql):

    $ gem list --remote --all sqlite
    
    *** REMOTE GEMS ***
    
    sqlite (2.0.1, 2.0.0, 1.3.1, 1.3.0, 1.2.9.1, 1.2.0, 1.1.3, 1.1.2, 1.1.1, 1.1)
    sqlite-ruby (2.2.3, 2.2.2, 2.2.1, 2.2.0, 2.1.0, 2.0.3, 2.0.2)
    sqlite3-ruby (1.2.4, 1.2.3, 1.2.2, 1.2.1, 1.2.0, 1.1.0, 1.0.1, 1.0.0, 0.9.0, 0.6.0, 0.5.0)
    

    Then you can choose the version you would like to install:

    gem install sqlite3-ruby -v 1.2.3
    

    To successfully install hpricot, I did this:

    gem install hpricot -v 0.6
    

    Annoyingly, doing a gem update tries to update the gems to their latest, broken-on-Windows, versions. When the update routine encounters an error, it ditches you out of the whole process. There's a (hacky) solution to this problem here.

    So, is this issue a bug in gems? Should gems not automatically detect the platform and install the latest compatible version?

    0 讨论(0)
  • 2020-12-02 21:48

    first from sqlite.org(http://www.sqlite.org/download.html)
    download ->
    Precompiled Binaries: sqlite-dll-win32-x86-3071700.zip
    and Source Code: sqlite-autoconf-3071700.tar.gz
    then extract as:

    -include
        --sqlite3.h
        --sqlite3ext.h
    -lib
        --shell.c
        --sqlite3.c
        --sqlite3.def
        --sqlite3.dll
    

    last install gem like:

    gem install sqlite3 --platform=ruby -- --with-sqlite3-include=path\to\include  
     --with-sqlite3-lib=path\to\lib --no-ri --no-rdoc
    

    Good luck!

    0 讨论(0)
  • 2020-12-02 21:48

    I also ran into this problem. It's worth knowing that the difference between 1.2.3 and 1.2.4 is not significant. Here are the 1.2.4. release notes:

    Release Name: 1.2.4

    Notes: This release only updates the generated C file to reflect the compatibility changes that were made to the SWIG file. Binary builds (e.g., Windows) are not affected, and need no update. In general, you will not need this update unless you are using a version of Ruby prior to 1.8.6. (source: 1.2.4. release notes)

    Hope that helps others!

    0 讨论(0)
提交回复
热议问题