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

后端 未结 18 1600
遇见更好的自我
遇见更好的自我 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:47

    Since pull request #229 has been merged, sqlite3 can be installed per git: key. It's possible to use sqlite3 easily through this addition in your Gemfile :

    gem 'sqlite3', git: "https://github.com/sparklemotion/sqlite3-ruby"
    

    This works on RubyInstaller-2.4 and newer. It automatically installs the required pacman package mingw-w64-x86_64-sqlite3 when you run bundler install.

    There are some more hints for Rails on Windows in the RubyInstaller2 FAQ.

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

    For OSX users, this can result from using a ruby manager (e.g. rvm).

    If you edit your ~/.bash_profile and add this:

    [[ "$APP" = *"/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/"* ]] && {
      echo Xcode detected
      rvm use system
    }
    

    You can work around the issue. Restart Xcode before attempting to build again.

    The actual issue is tracked here: https://openradar.appspot.com/28726736).

    Full credit goes to: https://egeek.me/2018/04/14/ipa-export-error-in-xcode-and-ruby/

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

    BEST OFFICIAL INSTALL

    Im using rails 5.2.1p57, Windows 10 Just running following lines sloved the problem

    gem uninstall sqlite3
    

    and uninstall all installed versions. again execute following command

    gem install sqlite3 --platform=ruby
    

    You are now done. Let me know if problem persist.

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

    This is the only solution worked for me, derived from this GitHub issue post:

    1. Get autoconf version of sqlite3 sources from https://www.sqlite.org/download.html.
    2. Start MSYS shell.
    3. In unpacked location for your sqlite3, configure static version only to avoid keeping DLL on PATH: ./configure --disable-shared.
    4. Build and install it: make install DESTDIR=/c/dev/ruby/tmp. You can change the directory.
    5. Open command prompt of windows and run gem uninstall sqlite3 --all to remove all existing sqlite3 gems.
    6. Again on command prompt of windows, build and install sqlite3 gem: gem install sqlite3 --platform=ruby -- --with-sqlite3-include=C:\dev\ruby\tmp\usr\local\include --with-sqlite3-lib=C:\dev\ruby\tmp\usr\local\lib. Those include and lib directories may be different, so check at first.

    I am using Ruby version 2.5.1 and Rails version 5.2.0 on Windows 10.

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

    This worked for me:

    gem 'sqlite3', git: "https://github.com/larskanis/sqlite3-ruby", branch: "add-gemspec"
    
    0 讨论(0)
  • 2020-11-22 09:52

    To avoid this error, ensure that gem sqlite3 is added to your Gemfile. Then extract "exe"s and "dll"s from Sqlite download link to Ruby's bin folder. If problem still persists. Try this:

    bundle update

    gem uninstall sqlite3

    Given a choice between multiple versions of sqlite3, choose last option 'All versions'. Enter last number here

    Select gem to uninstall:
    1. sqlite3-1.3.13
    2. sqlite3-1.3.13-x64-mingw32
    3. All versions
    >3 .
    .
    If you remove this gem, these dependencies will not be met.
    Continue with Uninstall? [yN]
    > y

    gem install sqlite3 --platform=ruby

    rails s

    This should work.

    Read through this link for more explanation if above works for you.

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