(Ruby 2.5.1) Windows Fix – "You can not load this file – Sqlite3 / Sqlite3_native (LoadError)"

If you are using Windows, you need to be aware that there are more gems for which external libraries are needed to be "properly" built.

These external directories are usually not on your system and need to be installed (and referenced) to work. That's why MYSQL2 and RMagick jewelry are "hard" to install.

If you use SQLite3, things are slightly different.

This gem contains many "builds" that provide functionality on many platforms (under Windows). Although this works in earlier versions of Ruby, Ruby 2.5.1+ does not work – since the error …

can not load – sqlite3 / sqlite3_native (LoadError)

mingw32 "version and experiments. This version of the gem prepares SQLite core files in advance, but it also has problems with later versions of Ruby.

The solution is to install the ruby ​​platform (which still works well under Windows):

install gem install sqlite3 –platform = rubin

install the gem "with all the appropriate files, etc., but does not use platform-specific functionality similar to the mingw32 version.

This will work 100% from the box.

However, there is another problem. If you use bundle, it often overrides native gem installation for a platform-specific benefit. This means that if you run the bundle update / batch install, you probably install sqlite3 gem on the mingw32 platform.

In this case, you must remove * all * references from the last using the "gem uninstall". Here is what is typically happening (for us):

  • package update [installs sqlite3]
  • gem uninstall sqlite3 [shows selection]
  • uninstall "mingw32" version
  • rails s [should work 100%]

This system works with gem.

The big problem is that when you use the "mingw32" version of the gem, you will have references / calls that specifically refer to certain elements of the gem.

Ruby 2.5.1+ – For whatever reason, these calls are not strictly used to ensure that the system is able to get the most out of it because you see the error. To solve this, it is essential to "force" the system to use only the "ruby" version.

Obviously, if you like Linux or Mac as a development environment, this sort of thing can be reliably prevented. But where is the fun in case it's easy? Use Windows!

Source by Richard Peck

Leave a Reply

Your email address will not be published. Required fields are marked *