新 Rails 3.2.8 项目出错 - `require': 无法加载此类文件 -- sqlite3/sqlite3_native (LoadError) [英] Error with new Rails 3.2.8 project - `require': cannot load such file -- sqlite3/sqlite3_native (LoadError)

查看:44
本文介绍了新 Rails 3.2.8 项目出错 - `require': 无法加载此类文件 -- sqlite3/sqlite3_native (LoadError)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚创建了一个新的 amazon Linux 实例并安装了 ruby​​ 1.9.3 和 rails 3.2.8.

I've just created a new amazon Linux instance and installed ruby 1.9.3 and rails 3.2.8.

创建新项目后,我立即收到由于 sqlite3 导致的失败.错误是:

Upon creating a new project I immediately receive failures due to sqlite3. The error is:

[root@xxxxx fun]# rails server
/usr/local/share/gems/gems/sqlite3-1.3.6/lib/sqlite3.rb:6:in `require': cannot load such file -- sqlite3/sqlite3_native (LoadError)
    from /usr/local/share/gems/gems/sqlite3-1.3.6/lib/sqlite3.rb:6:in `rescue in <top     (required)>'
    from /usr/local/share/gems/gems/sqlite3-1.3.6/lib/sqlite3.rb:2:in `<top     (required)>'

我已经确认 sqlite3 在 rails 之外工作得很好(即我成功创建了一个数据库,使用 ruby​​ 代码进行了插入/读取).下面是在 irb 中加载 sqlite3 的快速演示:

I have confirmed that sqlite3 is working just fine outside of rails (i.e. I successfully created a database, did inserts/reads using ruby code). Here is a quick show of loading sqlite3 in irb:

irb(main):001:0> require 'sqlite3'
=> true

我对捆绑安装都是最新的.sqlite3 版本为 1.3.6

I'm all up to date with bundle install. sqlite3 is at version 1.3.6

我安装了以下软件包:

ruby19-1.9.3.0-7.17.amzn1.i686
ruby19-devel-1.9.3.0-7.17.amzn1.i686
ruby19-irb-1.9.3.0-7.17.amzn1.noarch
ruby19-libs-1.9.3.0-7.17.amzn1.i686
rubygem19-io-console-0.3-7.17.amzn1.i686
rubygem19-rdoc-3.9.4-7.17.amzn1.i686
rubygems19-1.8.11-7.17.amzn1.noarch
sqlite-3.6.20-1.8.amzn1.i686
sqlite-devel-3.6.20-1.8.amzn1.i686

关于我可以尝试使事情正常进行的任何想法?谢谢!

Any ideas on what I could try to get things working? Thanks!

更新为了有趣",我从我的 Gemfile 中注释掉了 gem sqlite3 行并再次尝试了rails server".首先它抱怨没有 javascript 运行时(我可以修复),但随后它得到了以下信息.我的安装似乎出了点问题.

Update For "fun" I commented out the gem sqlite3 line from my Gemfile and tried "rails server" again. First it complained about not having a javascript runtime (which I could fix) but then it is getting the following. There seems to be something royally wrong with my install.

[root@xxxx fun]# rails server
/usr/local/share/gems/gems/railties-3.2.8/lib/rails/railtie/configuration.rb:85:in `method_missing': undefined method `active_record' for #<Rails::Application::Configuration:0x9e68f58> (NoMethodError)
    from /srv/rails/fun/config/application.rb:54:in `<class:Application>'
    from /srv/rails/fun/config/application.rb:13:in `<module:Fun>'
    from /srv/rails/fun/config/application.rb:12:in `<top (required)>'

推荐答案

您可能遇到了路径问题.

You may have a path problem.

要查看您是否安装了多个版本的 Ruby、Rails 或 gem:

To see if you have more than one version of Ruby, Rails, or gem installed:

find / | grep bin/ruby

查找/|grep bin/rails查找/|grep bin/gem

    find / | grep bin/rails     find / | grep bin/gem

在亚马逊服务器上,我通常保持系统 Ruby 原样,并使用优秀的 ruby​​-build 脚本(我认为比 RVM 更好)安装我自己当前的 Ruby.

On Amazon servers, I typically keep the system Ruby as is, and install my own current Ruby by using the excellent ruby-build script (better than RVM, in my opinon).

https://github.com/sstephenson/ruby-build

如果您有多个 Ruby,我建议您将环境设置为选择一个,例如使用 ruby-build 或在 .bashrc<中设置 PATH 文件或 /etc/environment 文件是这样的:

If you do have more than one Ruby, I suggest that you set your environment to choose one, for example by using ruby-build or by setting your PATH in your .bashrc file or /etc/environment file something like this:

PATH=/opt/ruby/1.9.1-p134/bin;$PATH

如果您使用的是 RVM,我建议您卸载它并更改为使用 ruby​​-build.

If you're using RVM, I suggest you uninstall it and change to use ruby-build.

要卸载 RVM,我使用以下脚本:

To uninstall RVM, I use this script:

https://github.com/SixArm/sixarm_unix_shell_scripts/blob/master/rvm-uninstall-danger

这篇关于新 Rails 3.2.8 项目出错 - `require': 无法加载此类文件 -- sqlite3/sqlite3_native (LoadError)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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