雪豹升级->重新安装sqlite3-ruby gem问题

发布于 2024-08-16 02:49:36 字数 2040 浏览 5 评论 0 原文

我得到了 ruby​​ 1.8.7(本机编译)、rails 2.3.4、OSX 10.6.2 以及 sqlite3-ruby。

我在访问 Rails 应用程序时遇到的错误是

NameError:未初始化的常量 SQLite3::Driver::Native::Driver::API

历史记录:
我通过使用固件电缆将我的应用程序从旧 MacBook 迁移到新 MacBook 来升级到雪豹。一切都完美运行了几个月,但昨天我需要安装 watir,它依赖于 rb-appscript,由于 libsqlite3.dylib 中的“错误架构”错误而没有构建。我认为构建是在旧机器上进行的,所以我想重建 sqlite3-ruby:

$ sudo gem 卸载 sqlite3-ruby

$ sudo gem 安装 sqlite3-ruby

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

/usr/local/bin/ruby extconf.rb
检查 -lrt 中的 fdatasync()...否
检查 sqlite3.h...是
检查 -lsqlite3 中的 sqlite3_open()...否
* extconf.rb 失败 *
由于某种原因无法创建 Makefile,可能缺少
必要的库和/或标头。检查 mkmf.log 文件了解更多信息
细节。您可能需要配置选项。

sqlite3 库似乎无法正常工作。我尝试安装 macports sqlite3 (sudo port install sqlite3) 并使用它,但结果相同...所以我从头开始重建 sqlite3.. 下载->配置->make->make install。之后,gem 现在可以完美构建,但无法在 Rails 中工作,从而在本文顶部给出错误。

我不太确定从这里去哪里,因为我已经尝试了以下

  1. 从最新源重建 sqlite3 ( http://www.sqlite.org/download.html
  2. 重新安装了sqlite3-ruby(sudo gem uninstall sqlite3-ruby && sudo gem install sqlite3-ruby)
  3. 从macports使用了sqlite3(sudo port install sqlite3 & ;& sudo gem install sqlite3-ruby)
  4. 重新安装了 Rails (sudo gem install Rails sqlite3-ruby ) 并将environment.rb更新为rails 2.3.5。

没有用,我仍然收到此错误:

NameError:未初始化的常量 SQLite3::Driver::Native::Driver::AP
来自 /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependency.rb:105:in const_missing'
来自 /usr/local/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.5/lib/sqlite3/driver/native/driver.rb:76:in
open'
来自 /usr/local/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.5/lib/sqlite3/database.rb:76:in `初始化'

顺便说一句,我从 Snow Leopard CD 安装了 Xcode。

我可以做什么来解决这个问题?

I got ruby 1.8.7 (native compiled), rails 2.3.4, OSX 10.6.2 and also sqlite3-ruby.

The error I'm getting when accessing the rails app is

NameError: uninitialized constant SQLite3::Driver::Native::Driver::API

History:
I upgraded to snow leopard by migrating my apps with a FW-cable from my old macbook to the new one. Everything was running perfectly for months, but Yesterday I needed to install watir, which was dependant on rb-appscript, which didn't build due a "wrong architecture" error in libsqlite3.dylib. I figured the build was made on the old machine, so i wanted to rebuild sqlite3-ruby:

$ sudo gem uninstall sqlite3-ruby

$ sudo gem install sqlite3-ruby

Building native extensions. This could take a while...
ERROR: Error installing sqlite3-ruby:
ERROR: Failed to build gem native extension.

/usr/local/bin/ruby extconf.rb
checking for fdatasync() in -lrt... no
checking for sqlite3.h... yes
checking for sqlite3_open() in -lsqlite3... no
* 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.

It seems like the sqlite3 libs are not working properly. I've tried to install macports sqlite3 (sudo port install sqlite3) and use that instead, but with same result... so i rebuild sqlite3 from scratch.. download->configure->make->make install. After that, the gem now builds perfectly, but doesn't work in rails, giving the error in the top of this article.

I'm not really sure where to go from here because I've tried the following

  1. Rebuild sqlite3 from newest source (http://www.sqlite.org/download.html)
  2. Reinstalled sqlite3-ruby (sudo gem uninstall sqlite3-ruby && sudo gem install sqlite3-ruby)
  3. Used sqlite3 from macports (sudo port install sqlite3 && sudo gem install sqlite3-ruby)
  4. Reinstalled rails (sudo gem install rails sqlite3-ruby ) and updated environment.rb to rails 2.3.5.

No avail, I still get this error:

NameError: uninitialized constant SQLite3::Driver::Native::Driver::AP
from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:105:in const_missing'
from /usr/local/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.5/lib/sqlite3/driver/native/driver.rb:76:in
open'
from /usr/local/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.5/lib/sqlite3/database.rb:76:in `initialize'

Btw, I have Xcode installed from the Snow Leopard CD.

What can i do to solve the problem?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

伤痕我心 2024-08-23 02:49:36

我的问题略有不同,事实上我在网上找到的解决方案都不起作用。

当升级到 Snow Leopard 和 XCode 4.0 试用版后尝试安装 sqlite3-ruby 时,我收到消息,

checking for sqlite3.h... yes
checking for sqlite3_libversion_number() in -lsqlite3... no
sqlite3 is missing. Try 'port install sqlite3 +universal' or 'yum install sqlite3-devel'

但是 sqlite3 已安装,并且重新安装也没有帮助。我之前在 64 位和通用版本中就已经遇到过这个问题,但我也已经解决了。
事实上,我可以使用 sqlite3。

所以 gem install 也应该告诉你一些类似的事情:

Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/sqlite3-ruby-1.3.1 for inspection.

所以 cd 到该目录并在那里查找 extconf.rb,我的在 ./ext/sqlite3/extconf.rb
我发现 ruby​​ 正在使用检查 sqlite3 库,

asplode('sqlite3') unless find_library 'sqlite3', 'sqlite3_libversion_number'

所以我启动了 irb 并检查了为什么这不起作用:

  require 'mkmf'
   find_library 'sqlite3', 'sqlite3_libversion_number'

嗯,事实上这有效,我的 ruby​​ 找到了该库。
那么为什么它在设置时不起作用呢?
仔细检查 extconf.rb 显示以下行:

  sqlite = dir_config('sqlite3', ['/usr/local', '/opt/local', '/usr'])

当我在 irb 中执行此操作时:

require 'mkmf'
  sqlite = dir_config('sqlite3', ['/usr/local', '/opt/local', '/usr']) 
  find_library 'sqlite3', 'sqlite3_libversion_number'

我会惊讶地不再找到该库。事实上我不明白这是怎么回事,但事实就是这样。

所以这就是治疗方法:
注释掉

sqlite = dir_config('sqlite3', ['/usr/local', '/opt/local', '/usr'])

extconf.rb 中的

行然后从 /Library/Ruby/Gems/1.8/gems/sqlite3-ruby-1.3.1 我发出

 sudo ruby ./setup.rb

这没有任何问题(我在注释掉 sqlite= 行之前尝试过,并且确实如此)不起作用)

重新启动了存在 sqlite 问题的 ruby​​ 应用程序。
工作正常。

希望这会对某人有所帮助。

冰淇淋

My problem was slightly different, and in fact non of the solutions I found on-line worked.

When trying to install sqlite3-ruby after upgrading to Snow Leopard and XCode 4.0 trial, I got the message

checking for sqlite3.h... yes
checking for sqlite3_libversion_number() in -lsqlite3... no
sqlite3 is missing. Try 'port install sqlite3 +universal' or 'yum install sqlite3-devel'

however sqlite3 was installed, and also re-installing did not help. I already had the troub le before with 64-bit and universal versions, but that I had cleared as well.
In fact, I could work with sqlite3.

So gem install should also tell you something along these lines:

Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/sqlite3-ruby-1.3.1 for inspection.

So cd to that directory and there look for extconf.rb, mine was in ./ext/sqlite3/extconf.rb
I found that ruby was checking for the the sqlite3 library using

asplode('sqlite3') unless find_library 'sqlite3', 'sqlite3_libversion_number'

So I fired up irb and checked why this didn't work:

  require 'mkmf'
   find_library 'sqlite3', 'sqlite3_libversion_number'

Well, in fact this works and my ruby find the library.
So why doesn't it work from the setup?
Inspecting extconf.rb closely showed the following line:

  sqlite = dir_config('sqlite3', ['/usr/local', '/opt/local', '/usr'])

When I execute this in irb:

require 'mkmf'
  sqlite = dir_config('sqlite3', ['/usr/local', '/opt/local', '/usr']) 
  find_library 'sqlite3', 'sqlite3_libversion_number'

I will surprisingly not find the library anymore. In fact I do not understand how this can be, but that's what happens.

So this is the cure:
comment out the line

sqlite = dir_config('sqlite3', ['/usr/local', '/opt/local', '/usr'])

in extconf.rb

Then from /Library/Ruby/Gems/1.8/gems/sqlite3-ruby-1.3.1 I issued

 sudo ruby ./setup.rb

This went through with no problems (I tried before commenting out the sqlite= line, and it did not work)

Restarted the ruby application that had the problems with sqlite.
Works fine.

Hope this will help someone.

Icecream

擦肩而过的背影 2024-08-23 02:49:36

感谢您的回答。这是我解决问题的方法:

  1. 将 ruby​​1.8.7 完全重新安装到 /usr/local,请参阅此处:http://hivelogic.com/articles/ruby-rails-leopard

    注意:在我的 Mac 上重新编译 ruby​​ 时,readline 不起作用,因此我也必须从头开始构建它,并确保添加 --with-readline-dir 选项进行配置:

    <块引用>

    ./configure --enable-shared --enable-pthread CFLAGS=-D_XOPEN_SOURCE=1 --prefix=/usr/local --with-readline-dir=/usr/local

  2. 将 sqlite3 完全重新安装到 /usr/ local

  3. 使用 sudo gem install XXX 重建系统上的所有 gem,包括 sqlite3-ruby。这仅对于特定于平台的 gem 是必要的,但我发现将所有内容安装在 oneliner 中会更快:

    <块引用>

    sudo gem install gem1 gem2 ... gemN --no-ri --no-rdoc

我尝试使用 ruby​​1.9 但由于 gems 和插件中的依赖关系损坏,一切都停止工作,所以我不建议切换到 1.9,除非您已经准备好进行一些繁重的调试并知道如何恢复旧系统!

终于一切又恢复正常了!

Thanks for the answers. Here is what i did to solve the problem:

  1. Complete reinstall of ruby1.8.7 to /usr/local, see here: http://hivelogic.com/articles/ruby-rails-leopard

    Note: readline wasn't working when recompiling ruby on my mac, so i had to build that too from scratch and make sure to add the --with-readline-dir option to configure:

    ./configure --enable-shared --enable-pthread CFLAGS=-D_XOPEN_SOURCE=1 --prefix=/usr/local --with-readline-dir=/usr/local

  2. Complete reinstall of sqlite3 to /usr/local

  3. Rebuild all gems on the system with sudo gem install XXX, including sqlite3-ruby. This is only necessary with platform specific gems, but i found it to be faster just to install everything in a oneliner:

    sudo gem install gem1 gem2 ... gemN --no-ri --no-rdoc

I tried to go with ruby1.9 but everything stopped working due to broken dependencies in gems and plugins, so I wouldn't recommend switching to 1.9 unless you are up for some heavy debugging and know how to restore your old system!

Finally everything is running again!

迷你仙 2024-08-23 02:49:36

我在 Don Park 的博客中找到了一些相关指导:

http://blog.docuverse.com/2009/09/24/installing-sqlite3-ruby-gem-on-snow-leopard/

他的解决方案直接回到了 Stack Overflow,如下所示线程:

Snow Leopard, sqlite3-ruby

关于 ln 命令的答案似乎已经解决了我的问题。希望它也能帮助你。

I found some guidance on this at Don Park's blog at:

http://blog.docuverse.com/2009/09/24/installing-sqlite3-ruby-gem-on-snow-leopard/

His solution points right back to Stack Overflow at the following thread:

Snow Leopard, sqlite3-ruby

The answer about the ln command seems to have solved my problem. Hope it helps you too.

皓月长歌 2024-08-23 02:49:36

如果 gem 没有构建,并不是因为您需要从源代码重建 sqlite3,而是为了构建 gem,您将需要 sqlite3 开发人员库。

在大多数 Linux/Unix 系统上,您可以通过执行“sudo apt-get install sqlite3-dev”来安装它们,但是我不确定它如何与 Macports 一起使用 - 但请确保您拥有该软件包。您必须确保它们在您的路径中,或者在安装 gem 时传递它们所在的目录(请参阅 gem 的输出以获取有关执行此操作的选项的提示)。

我的 Mac 上有 sqlite3 运行得很好,无论是 1.8.7 还是现在更新的 1.9.1 Ruby。您可能需要确保还安装了 XCode 开发人员工具。

If the gem isn't building it's not because you need necessarily to rebuild sqlite3 from source, but to build the gem you will require the sqlite3 developer libraries.

On most Linux/Unix systems you can install them by doing 'sudo apt-get install sqlite3-dev', however I'm not sure how it works with Macports - but make sure you have that package. You have to make sure they're in your path or pass the dir they're in when you install the gem (see the gem's output for hints as to the options for doing that).

I have sqlite3 running on my Mac just fine, both with 1.8.7 and now my updated 1.9.1 Ruby. You might want to make sure you have the XCode Developer Tools installed as well.

风向决定发型 2024-08-23 02:49:36

对于那些使用 Snow Leopard 64 并遇到此问题的用户,安装此 macport 为我解决了这个问题。

sudo port install rb-sqlite3 +universal

For those on Snow Leopard 64 and having this issue installing this macport fixed the issue for me.

sudo port install rb-sqlite3 +universal
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文