Snow Leopard upgrade -> reinstalling sqlite3-ruby gem problem

后端 未结 5 1929
时光说笑
时光说笑 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:17

    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.

    0 讨论(0)
  • 2021-01-07 08:20

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

    sudo port install rb-sqlite3 +universal
    
    0 讨论(0)
  • 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

    0 讨论(0)
  • 2021-01-07 08:29

    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.

    0 讨论(0)
  • 2021-01-07 08:31

    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!

    0 讨论(0)
提交回复
热议问题