Snow Leopard upgrade -> reinstalling sqlite3-ruby gem problem

后端 未结 5 1924
时光说笑
时光说笑 2021-01-07 07:35

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

Name

5条回答
  •  醉梦人生
    2021-01-07 08:27

    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

提交回复
热议问题