Ruby on Rails - “将 'gem sqlite3'' 添加到您的 Gemfile" [英] Ruby on Rails - "Add 'gem sqlite3'' to your Gemfile"

查看:41
本文介绍了Ruby on Rails - “将 'gem sqlite3'' 添加到您的 Gemfile"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在学习 Rails 教程,但是当它说在博客目录中键入 rails server 时我被卡住了.它指出

I was following the Rails tutorial, but I got stuck when it said to type rails server in the blog directory. It states

为数据库适配器指定了sqlite3",但未加载 gem.将 gem 'sqlite3' 添加到您的 Gemfile.

Specified 'sqlite3' for database adapter, but the gem is not loaded. Add gem 'sqlite3' to your Gemfile.

我退出了服务器,安装了 sqlite3,恢复了服务器,结果又收到了这条消息.当我执行 gem list 时,sqlite3 没有出现,但我确实在我的 Root Ruby 目录中看到了该文件夹.

I quit the server, installed sqlite3, reinstated the server, only to get this message again. sqlite3 doesn't show up when I do gem list, but I do see the folder in my Root Ruby directory.

我该如何解决这个错误?

How can I fix this error?

我使用的是 Ruby 2.0、Rails 4.0、sqlite3 1.3.7.

I'm using Ruby 2.0, Rails 4.0, sqlite3 1.3.7.

推荐答案

问题解决!

事实证明,这是几个不同的问题:

Turns out, it was several different problems:

  1. 我之前忽略了需要安装 sqlite3 才能运行,如 ruby​​onrails.org 的入门指南中所述.该指南给了我一个到 sqlite.com 的链接,我需要从中下载命令外壳和 dll,两者都在Windows 预编译二进制文件"下.详情请见下文.

  1. I previously overlooked that sqlite3 needed to be installed in order to run, as stated in rubyonrails.org's Getting Started guide. The guide gave me a link to sqlite.com, from which I needed to download the command shell and the dll, both are under "Precompiled Binaries for Windows". More on this below.

gem 安装给了我一个错误,指出它无法从 ruby​​gems.org 下载任何东西.事实证明,有一个我不知道的新版本的 ruby​​gems.修复了 gem update --system.

The gem install gave me an error that stated it couldn't download anything from rubygems.org. Turns out, there was a new version of rubygems I wasn't aware of. Fixed with gem update --system.

我试过 gem install sqlite3 --platform=ruby,但无济于事.它无法构建本机扩展,也无法找到 sqlite3.h.

I tried gem install sqlite3 --platform=ruby, but to no avail. It couldn't build a native extension and couldn't find sqlite3.h.

我也在 ruby​​ 论坛上问过我的问题.http://www.ruby-forum.com/topic/4415126在这里,Joel Pearson(virtuoso)通过附件提供了我需要的丢失文件,因为 sqlite.com 中没有提供这些文件.我遵循了他的指示,包括将 shell 和 dll 文件放在我的 Ruby 根目录中的 bin 目录中……它奏效了!

I had asked my question also on ruby-forums. http://www.ruby-forum.com/topic/4415126 Here, a Joel Pearson(virtuoso) provided the missing files that I needed via attachment, since these files are not provided in sqlite.com. I followed his instructions, including putting the shell and dll files in my root Ruby's bin directory...and it worked!

所以基本上,我可以在不修改任何 Gemfile 或 Gemfile.lock 的情况下安装 sqlite3.我的 gem 列表显示 sqlite3 (1.3.7) 并且 Rails 的欢迎屏幕现在出现在入门指南中!我使用 Windows 7-64 位、Ruby 2.0、Rails 4.0,现在我得到了 sqlite3 1.3.7.

So basically, I was able to install sqlite3 without modifying any Gemfile or Gemfile.lock. My gem list shows sqlite3 (1.3.7) and Rails's Welcome screen now appears as the Getting Started guide shows! I use Windows 7-64 bit, Ruby 2.0, Rails 4.0 and I now got sqlite3 1.3.7.

非常感谢大家给这个 n00b 建议和方向.我发现在探索了 Gemfiles 以及我的 Ruby 根目录之后,我明白了 Ruby 和 Rails 如何更好地适应我的计算机.

Thank you very much everyone for giving this n00b advice and direction. I find that having explored the Gemfiles as well as my root Ruby directory, I understand how Ruby and Rails are fit into my computer better.

作为初学者,我建议您能够在 ruby​​onrails.org 的入门指南和 sqlite.com 上下载在 Windows 上安装所需的 sqlite3 文件和文件夹.

As a beginner, I would recommend being able to download the sqlite3 files and folders needed to install it on Windows both on rubyonrails.org's Getting Started guide and in sqlite.com.

再次感谢!他来了

这篇关于Ruby on Rails - “将 'gem sqlite3'' 添加到您的 Gemfile"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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