Snow Leopard & Ruby on Rails - SQLite3 issue

前端 未结 9 675
难免孤独
难免孤独 2020-12-11 08:35

I just upgraded to snow leopard. Before, I had everything running fine, but now when I start the server from the terminal I get:

=> Booting WEBrick
=>          


        
相关标签:
9条回答
  • 2020-12-11 09:17

    I had a similar issue. If you look at the stack backtrace, you can see that the file throwing the error is within sqlite-ruby itself:

    def open( filename, utf16=false )
      API.send( utf16 ? :sqlite3_open16 : :sqlite3_open, filename )
    end
    

    So the API class is missing. At top of this file is the following code which suggests that the API class comes from requiring the sqlite3_api file:

    begin
      require 'sqlite3_api'
    rescue LoadError
      if RUBY_PLATFORM =~ /mingw|mswin/ then
        RUBY_VERSION =~ /(\d+.\d+)/
        require "#{$1}/sqlite3_api"
      end
    end
    

    As you can see, this code will ignore a LoadError on platforms other than mingw/mswin. This is bad, and something I would consider a bug in the sqlite3-ruby gem. To figure out what's wrong, try requiring sqlite3_api in irb:

    $ irb
    irb(main):001:0> require 'sqlite3_api'
    LoadError: Unable to find library 'libsqlite3.so.8'. - /path/to/ruby/lib/ruby/gems/1.9.1/gems/sqlite3-ruby-1.2.5/lib/sqlite3_api.sl
            from (irb):1:in `require'
            from (irb):1
            from /path/to/ruby/bin/irb:12:in `<main>'
    irb(main):002:0>
    

    YMMV, but for me, I realised that I was missing something in my shared-library path. Once I corrected that, everything worked.

    0 讨论(0)
  • 2020-12-11 09:18

    If you upgraded from Leopard, then you will need to reinstall the sqlite3-ruby gem. First install XCode, then run:

    sudo gem install sqlite3-ruby
    
    0 讨论(0)
  • 2020-12-11 09:21

    For some reason, this didn't work too well for me.

    I had to basically start from scratch, following these instructions: http://hivelogic.com/articles/ruby-rails-leopard from the "Setting Up" stage.

    • Install XCode
    • Download Ruby 1.8.7
    • Recompile and install (I think this was the magic step I was missing)
    • Download Rubygems 1.3.5 (1.3.6 has some things deprecated that I didn't want to deal with)
    • Recompile and install Rubygems
    • THEN uninstall sqlite3: sudo gem uninstall sqlite3-ruby
    • Reinstall it: sudo gem install sqlite3-ruby

    To be clear, I tried the steps above. I tried installing XCode. I tried recompiling Rubygems...Only when I recompiled Ruby itself, THEN Rubygems, THEN uninstall and reinstall sqlite3-ruby did things clear up.

    I hope this helps.

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