如何在 Windows 上为 Ruby 安装 sqlite3? [英] How do I install sqlite3 for Ruby on Windows?

查看:73
本文介绍了如何在 Windows 上为 Ruby 安装 sqlite3?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 Ruby/Rails 的新手,在本周末尝试自己解决问题后,我试图在这里寻求建议.

Being really new to Ruby/Rails, and after attempting to resolve the issue myself this weekend I'm making an attempt to seek advice here.

我在 FreeBSD 上完成了完整的 Ruby/Apache/Passenger 设置,我正在尝试完成使用 Windows 作为 Ruby 开发环境的任务.

I have a complete Ruby/Apache/Passenger setup done on FreeBSD, and I'm trying to accomplish the task of using Windows as a Ruby development environment.

到目前为止:

  • Ruby 已安装,v2.0.0p0 (2013-02-24) [x64-ming32]
  • Rails 已安装,v.3.2.12
  • 我已经安装并注册了 Ruby 开发工具包.
  • 我已将 sqlite3 dll/exe 复制到 Rubybin"文件夹(使用使用 Ruby 启动命令提示符"控制台也在我的路径中.)
  • 我可以成功启动 Rails 服务器,并继续使用 http://guides.rubyonrails.org/Getting_started.html 3.3 教程.
  • ">rake db:create" 告诉我:

  • Ruby is installed, v2.0.0p0 (2013-02-24) [x64-ming32]
  • Rails is installed, v.3.2.12
  • I have the Ruby dev kit installed and registered.
  • I have the sqlite3 dll/exe copied to the Ruby "bin" folder (which is also in my path using the "Start Command Prompt with Ruby" console.)
  • I can start a rails server successfully, and continuing with the http://guides.rubyonrails.org/getting_started.html tutorial to 3.3.
  • ">rake db:create" tells me:

请安装 sqlite3 适配器:gem install activerecord-sqlite3-adapter (sqlite3 不是捆绑包的一部分.将其添加到 Gemfile.)

Please install the sqlite3 adapter: gem install activerecord-sqlite3-adapter ( sqlite3 is not part of the bundle. Add it to Gemfile.)

我没有了解".尝试安装 activerecord-sqlite3-adapter 给我一个找不到有效的 gem..."

which I have no "understanding" of. Trying to install activerecord-sqlite3-adapter gives me a "Could not find a valid gem..."

  • ">gem install sqlite3" 返回:

  • ">gem install sqlite3" returns:

构建原生扩展.这可能需要一段时间...错误:安装 sqlite3 时出错:错误:无法构建 gem 本机扩展.

D:/Development/Ruby200-x64/bin/ruby.exe extconf.rb正在检查 sqlite3.h... *** extconf.rb 失败 ***

现在我陷入了困境,我什至不知道我的 Ruby on Windows 安装处于什么状态.我正在尝试遵循主要的 Rails 教程,但它没有指定任何这些问题(可能是因为 Ruby on Windows 对很多人来说似乎是一种自然的痛苦.)

Right now I'm stuck at the point where I don't even know what state my Ruby on Windows installation is in. I'm trying to follow the main Rails tutorial and it doesn't specify any of these issues (probably because Ruby on Windows seems to be a natural pain for a lot of people.)

我错过了什么?!?我只是想在 Windows 上为 Ruby 安装 sqlite3,看起来很简单吧?

What am I missing?!? I'm just trying to install sqlite3 for Ruby on Windows, seems simple right?

如果我执行 ">rais db" 将显示 SQLite shell:

If I do ">rais db" the SQLite shell is presented:

SQLite 版本 3.7.15.2 2013-01-09 11:53:05

带有无法解决我的问题的步骤的类似问题:在 Windows 7 上安装 SQLite 3.6

Similar questions with steps that do not resolve my issue: Installing SQLite 3.6 On Windows 7

推荐答案

即使问题已经得到解答,我还是想发布我的研究来帮助他人.我在网上找到了很多信息,但作为一个 Ruby 新手,我很难理解.基本答案来自以下帖子 https://github.com/luislavena/sqlite3-ruby/issues/82 包含paulwis"关于如何为 ruby​​ 2.0.0-p0 正确安装 sqlite3 的说明以及对 https://github.com/rails/rails/issues/10150.所以这里是:

Even though the question has been answered, I want to post my research to help others. I found a lot of information online, but being a Ruby newbie I had a tough time following all. The basic answer comes from the following post https://github.com/luislavena/sqlite3-ruby/issues/82 with instructions by "paulwis" on how to properly install sqlite3 for ruby 2.0.0-p0 and some comments on https://github.com/rails/rails/issues/10150 . So here it is:

  1. 为您的设置安装 Ruby Devkit(DevKit-mingw64-64-4.7.2-20130224-1432-sfx.exe,因为我使用的是 x64 机器)
  2. 从 Sqlite.org 下载并解压 autoconf 包
  3. 运行 msys.bat(它在 ruby​​ devkit 根文件夹中)
  4. cd 到您下载 sqlite 源代码的路径(例如:如果您不熟悉 MSYS/MINGW32,则路径c:\dev\sqlite3"的cd/c/dev/sqlite3")
  5. 运行./configure"
  6. 运行make"
  7. 运行make install"
  8. 再次获取 sqlite3 gem,这次指定平台和新编译的二进制文件的路径:

  1. Install the Ruby Devkit for your setup (DevKit-mingw64-64-4.7.2-20130224-1432-sfx.exe for me since I use a x64 machine)
  2. Download and extract the autoconf package from Sqlite.org
  3. Run msys.bat (it is inside the ruby devkit root folder)
  4. cd into the path where you downloaded the sqlite source (for example: "cd /c/dev/sqlite3" for path "c:\dev\sqlite3" if you are new to MSYS/MINGW32)
  5. Run "./configure"
  6. Run "make"
  7. Run "make install"
  8. Get the sqlite3 gem again, this time specifying the platform and the path to the newly compiled binaries:

gem install sqlite3 --platform=ruby -- --with-sqlite3-include=[path\to\sqlite3.h] --with-sqlite3-lib=[path\to\sqlite3.o]

例如:

gem install sqlite3 --platform=ruby -- --with-sqlite3-include=/c:/dev/sqlite3/ --with-sqlite3-lib=/c:/dev/sqlite3/.libs/

(来自步骤 4 中给出的路径)

(from the paths given in step 4)

希望这对某人有所帮助.

Hope this helps someone.

这篇关于如何在 Windows 上为 Ruby 安装 sqlite3?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆