Windows/Ruby/Rails Install --- .Cannot Load Such File -- SQLite3/Sqlite3_Native Windows

Windows/Ruby/Rails install --- .cannot load such file -- sqlite3/sqlite3_native windows

The issue is that binary sqlite3 gem do not include pre-compiled versions for Ruby 2.1.3

This is mentioned in the sqlite3-ruby mailing list here.

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

Find your sqlite3 gemspec file. One example is /usr/local/share/gem/specifications/sqlite3-1.3.7.gemspec

Windows:
C:\Ruby21\lib\ruby\gems\2.1.0\specifications.

You should adjust according with your Rubygem path and sqlite3 version.
Edit the file above and look for the following line

s.require_paths=["lib"]

change it to

s.require_paths= ["lib/sqlite3_native"]

How do I install sqlite3 for Ruby on Windows?

Even though the question has been answered, I want to post my research to help others. I found a lot of information online, but being a Ruby newbie I had a tough time following all. The basic answer comes from the following post https://github.com/luislavena/sqlite3-ruby/issues/82 with instructions by "paulwis" on how to properly install sqlite3 for ruby 2.0.0-p0 and some comments on https://github.com/rails/rails/issues/10150 . So here it is:

  1. Install the Ruby Devkit for your setup (DevKit-mingw64-64-4.7.2-20130224-1432-sfx.exe for me since I use a x64 machine)
  2. Download and extract the autoconf package from Sqlite.org
  3. Run msys.bat (it is inside the ruby devkit root folder)
  4. cd into the path where you downloaded the sqlite source (for example: "cd /c/dev/sqlite3" for path "c:\dev\sqlite3" if you are new to MSYS/MINGW32)
  5. Run "./configure"
  6. Run "make"
  7. Run "make install"
  8. Get the sqlite3 gem again, this time specifying the platform and the path to the newly compiled binaries:

    gem install sqlite3 --platform=ruby -- --with-sqlite3-include=[path\to\sqlite3.h] --with-sqlite3-lib=[path\to\sqlite3.o]

    For example:

    gem install sqlite3 --platform=ruby -- --with-sqlite3-include=/c:/dev/sqlite3/ --with-sqlite3-lib=/c:/dev/sqlite3/.libs/

    (from the paths given in step 4)

  9. Check the Gemfile.lock of your rails app and make sure that it points to the correct sqlite3 version. Mine was "sqlite3 (1.3.7-x86-mingw32)" and manually changed it to "sqlite3 (1.3.7-x64-mingw32)". Removing the platform also works: "sqlite3 (1.3.7)".

Hope this helps someone.

cannot load such file sqlite3 - Rails Tutorial

Looks like this post solves my problem. I need to use sqlite 1.3.10 which includes support for Ruby 2.1. Sqlite 1.3.9 does not.

SqLite3 LoadError: incompatible library version

Need to use lower version of sqlite3 gem (1.3.10) instead v. 1.3.11
Before if needed uninstall all gems
and write to Gemfile:

gem 'sqlite3', '~> 1.3', '>= 1.3.10'

and use $ bundle install

It's helps me

Opening file with write throws No implicit conversion of String into Integer

As per the docs, the second argument for File.read is the length of bytes to be read from the given file which is meant to be an integer.

Opens the file, optionally seeks to the given offset, then returns length bytes (defaulting to the rest of the file). read ensures the file is closed before returning.

So, in your case the error happens because you're passing an argument which must be an integer. It doesn't state this per-se in the docs for File.read, but it does it for File#read:

Reads length bytes from the I/O stream.

length must be a non-negative integer or nil.

If you want to specify the mode, you can use the mode option for that:

File.read("filename", mode: "r") # "r" or any other
# or
File.new("filename", mode: "r").read(1)

RubyMine, how to write a message to RSpec log?

I found it:

Rails.logger.info('My message ...')


Related Topics



Leave a reply



Submit