cannot load such file — sqlite3/sqlite3_native (LoadError) on ruby on rails

后端 未结 18 1602
遇见更好的自我
遇见更好的自我 2020-11-22 09:39

When I try to setup basic installation and initiation of server using Rails 4.0.0 on Ruby 2.0.0, I\'m facing the following error message.

/usr/local/lib/ruby         


        
相关标签:
18条回答
  • 2020-11-22 09:56

    I had the same error when I upgrade my Ruby version to 2.5.X. I tracked with rails task --trace that the sqlite3 is not available to version 2.5, than I change my GemFile the gem "sqlite3" change to "sqlite3-ruby", after I uninstall the gem "sqlite3" and finally I run the bundle install.

    I don't know what is the reason... I read that "sqlite3" is not available for ruby 2.5 yet, but I'm not sure.

    0 讨论(0)
  • 2020-11-22 09:57

    Updated

    Adding the below to the Gemfile fixed for me: gem 'sqlite3', '1.4.0', platforms: :ruby

    0 讨论(0)
  • 2020-11-22 09:58

    If the top answer doesn't work, a fix that I discovered is simply going to your Gemfile and adding the version number 1.3.11 (instead of 1.3.9) right after sqlite3. So the line in your Gemfile should now read:

    # Use sqlite3 as the database for Active Record
    gem 'sqlite3',  '1.3.11'
    
    0 讨论(0)
  • 2020-11-22 09:58

    Change your sqlite3 gem in the Gemfile for this:

    gem 'sqlite3', git: "https://github.com/larskanis/sqlite3-ruby", branch: "add-gemspec"
    

    Then run:

    bundle install
    
    0 讨论(0)
  • 2020-11-22 10:00

    Just edit Gemfile and add gem 'sqlite3', platform: :ruby.

    0 讨论(0)
  • 2020-11-22 10:01

    see:https://stackoverflow.com/a/39136421/6755206

    fortunately, you don't have to switch to ruby 2.0
    there is a solution to this issue, after endless trying...

    https://github.com/hwding/sqlite3-ruby-win


    Steps

    Pre

    • gem uninstall sqlite3 --all

    Source

    • Download the latest sqlite3-ruby, https://github.com/sparklemotion/sqlite3-ruby
    • unzip the package

    Build

    • run command-line in the extracted dir
    • make sure you have your C compiler installed and added to PATH
    • gem install bundler
    • bundle install
    • rake native gem
    • you'll find a dir named 'pkg' generated

    Install

    • enter dir 'pkg'
    • gem install --local sqlite3-xxx.gem ('xxx' is version code)

    Check

    • irb
    • require 'sqlite3'
    0 讨论(0)
提交回复
热议问题