【问题标题】:Ruby sqlite3 gem installation issue on Windows 10Windows 10 上的 Ruby sqlite3 gem 安装问题
【发布时间】:2019-07-11 07:19:30
【问题描述】:

我对 ruby​​ 和 rails 很陌生。我正在尝试安装到 sqlite3 以尝试教程并遇到问题。我在 Windows 10 上并使用 ruby 2.6.1p33 (2019-01-30 revision 66950) [x64-mingw32]

这是我在运行gem install sqlite3-ruby 时遇到的安装错误。我也试过运行gem install sqlite3 --platform=ruby -- --with-sqlite3-include=c:/sqlite3/include --with-sqlite3-lib=c:/sqlite3/lib

C:/Ruby26-x64/bin/ruby.exe -I C:/Ruby26-x64/lib/ruby/2.6.0 -r ./siteconf20190217-3116-1d59gcv.rb extconf.rb
checking for sqlite3.h... yes
checking for pthread_create() in -lpthread... yes
checking for -ldl... no
checking for dlopen()... no
missing function dlopen
*** 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:/Ruby26-x64/bin/$(RUBY_BASE_NAME)
    --with-sqlcipher
    --without-sqlcipher
    --with-sqlite3-config
    --without-sqlite3-config
    --with-pkg-config
    --without-pkg-config
    --with-sqlcipher
    --without-sqlcipher
    --with-sqlite3-dir
    --without-sqlite3-dir
    --with-sqlite3-include
    --without-sqlite3-include=${sqlite3-dir}/include
    --with-sqlite3-lib
    --without-sqlite3-lib=${sqlite3-dir}/lib
    --with-pthreadlib
    --without-pthreadlib
    --with-dllib
    --without-dllib

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

  C:/Ruby26-x64/lib/ruby/gems/2.6.0/extensions/x64-mingw32/2.6.0/sqlite3-1.4.0/mkmf.log

extconf failed, exit code 1

我从他们的网站下载了 sqlite3,这里是C:\sqlite3\的文件夹结构

sqldiff.exe
sqlite3.exe
sqlite3_analyzer.exe
include\shell.c
include\sqlite3.c
include\sqlite3.h
include\sqlite3ext.h
lib\sqlite3.def
lib\sqlite3.dll

我还复制了sqldiff.exe, sqlite3.exe and sqlite3_analyzer.exeC:\Ruby26-x64\bin。 在我的环境变量中,我已将C:\sqlite3\ 添加到PATH 并创建了一个新的环境变量sqlite3-dir 指向C:\sqlite3\

有人可以为这个安装问题提供一些帮助吗?

【问题讨论】:

  • 您需要最实际的版本吗?我在使用 sqlite3 1.4.0 时也遇到了问题,但 1.3.13 版对我来说效果很好。 gem install sqlite3 -v 1.3.13
  • 我能够使用此链接中的这些步骤解决该问题:github.com/sparklemotion/sqlite3-ruby/issues/241
  • 这个问题的最佳时机。我正在学习 Ruby on Rails,但在我的第一个项目中遇到了这个错误。
  • 有人将该链接放在评论中。不知道为什么那条评论被删除了。

标签: ruby sqlite rubygems


【解决方案1】:

在项目 Gemfile 文件中添加 gem 'sqlite3', git: "https://github.com/larskanis/sqlite3-ruby", branch: "add-gemspec" 有效。之后运行bundle install。确保在机器中安装 git。这是github link

【讨论】:

    【解决方案2】:

    为了解决所有项目的这个问题,我从https://rubygems.org/下载了gem文件并保存在本地,通过cmd安装了MinGW

    C:\Sites>ridk exec pacman -S mingw-w64-x86_64-dlfcn
    

    以及

    之后的 SQLite 3 gem
    C:\Sites>gem install --local C:\sqlite3-1.4.0.gem
    

    如果您需要修复已经创建的项目,尝试在这些行之后再次运行 bundle install,它适用于在站点文件夹中创建的所有下一个项目。

    我也尝试将 SQLite 3 文件包含到路径中,但对我也不起作用

    【讨论】:

      【解决方案3】:

      这是目前对我有用的方法,它是针对每个项目的修复; Samiul Alam Anik 的回答,但有一个补充。按照这些步骤操作后,您可能会收到一个requires Bundler 2,这通过gem update --system 为我解决了,感谢GitHub ticket

      【讨论】:

        【解决方案4】:

        确保您的计算机上安装了当前的 Ruby 版本,安装 node ja,安装 yarn,更新 npm,更新 gem Ruby。

        C:\Users\adilkemo>ruby --version 
        ruby 3.0.1p64 (2021-04-05 revision 0fb782ee38) [x64-mingw32]
        
        C:\Users\adilkemo>gem --version  
        3.2.15
        
        C:\Users\adilkemo>node --version  
        v16.4.2
        
        C:\Users\adilkemo>yarn --version  
        1.22.10
        
        C:\Users\adilkemo>npm --version   
        7.18.1
        
        C:\Users\adilkemo>sqlite3 --version  
        3.36.0 2021-06-18 18:36:39 5c9a6c06871cb9fe42814af9c039eb6da5427a6ec28f187af7ebfb62eafa66e5
        
        C:\Users\adilkemo>gem install rails 
        
        C:\Users\adilkemo>rails --version  
        Rails 6.1.4
        
        C:\Users\adilkemo>cd Desktop  
        
        C:\Users\adilkemo\Desktop>rails new blog  
        
        C:\Users\adilkemo\Desktop>cd blog  
        
        C:\Users\adilkemo\Desktop\blog>bin/rails server - Goodbye!
        Exiting
        Terminate batch job (Y/N)? y  
        
        C:\Users\adilkemo\Desktop\blog>
        

        https://rubyinstaller.org/
        https://guides.rubygems.org/rubygems-basics/
        https://nodejs.org/en/
        https://classic.yarnpkg.com/en/docs/install/#windows-stable
        https://www.sqlite.org/download.html
        https://guides.rubyonrails.org/v5.0/getting_started.html

        【讨论】:

        • 请阅读stackoverflow.com/editing-help。请了解编辑通知字段的用途。请仔细检查我没有破坏您帖子中的任何内容,我的意图只是将您的信息转换成正确的形状,而不是参与此社区 wiki 帖子(因为我很惊讶您选择制作此帖子)。
        猜你喜欢
        • 2010-12-29
        • 2017-10-20
        • 2011-04-01
        • 1970-01-01
        • 2013-05-06
        • 2011-08-26
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多