I ran the rails server command on windows10, Ruby2.6.6 and got "cannot load such file --sqlite3 / sqlite3_native"

Introduction

If you follow @ shuhey's article, it will be almost solved. It didn't work when I did it with Ruby 2.6.6, so it's just a memo ...

environment

windows10 Home Ruby+Devkit 2.6.6-1 (x64) Rails 5.1.6

I should have fixed it, but I got an error

Ruby on Rails Tutorial and Rails Girls Installation Recipe (Windows Setup (for those who cannot use WSL)) When I built the environment according to / install # setup_for_windows_without_wsl) and executed the rails server command, the following error occurred. (@ Shuhey's article has changed to Ruby26-x64-> Ruby25-x64, 2.6.0-> 2.5.0)

C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sqlite3-1.3.13-x64-mingw32/lib/sqlite3.rb:6:in `require': cannot load such file -- sqlite3/sqlite3_native (LoadError)

Here, following @ shuhey's article C: \ Ruby26-x64 \ lib \ ruby \ gems \ 2.6.0 \ gems \ sqlite3-1.3 Create a new 2.5 directory in .13-x64-mingw32 \ lib \ sqlite3, copy sqlite3_native.so into it, and execute the rails server command again!

I thought this would solve it, but I still got the same error ...

Solution

Take a look at the error message C: /Ruby26-x64/lib/ruby/gems/2.6.0/gems/sqlite3-1.3.13-x64-mingw32/lib/sqlite3.rb. Then, on the 3rd and 4th lines

sqlite3.rb


  RUBY_VERSION =~ /(\d+\.\d+)/
  require "sqlite3/#{$1}/sqlite3_native"

I see. Did the 2.5 directory mean the version of Ruby! (Why didn't you notice it lol)

So create a new 2.6 directory, copy sqlite3_native.so and run the rails server command. Finally succeeded in starting the Rails application.

=> Booting Puma
=> Rails 5.1.6 application starting in development
=> Run `rails server -h` for more startup options
*** SIGUSR2 not implemented, signal based restart unavailable!
*** SIGUSR1 not implemented, signal based restart unavailable!
*** SIGHUP not implemented, signal based logs reopening unavailable!
Puma starting in single mode...
* Version 3.9.1 (ruby 2.6.6-p146), codename: Private Caller
* Min threads: 5, max threads: 5
* Environment: development
* Listening on tcp://0.0.0.0:3000
Use Ctrl-C to stop

Access localhost: 3000 with a browser and check the operation

キャプチャ.PNG

Recommended Posts

I ran the rails server command on windows10, Ruby2.6.6 and got "cannot load such file --sqlite3 / sqlite3_native"
Difficulties in building a Ruby on Rails environment (Windows 10) (SQLite3)
(Ruby on Rails6) Display of the database that got the id of the database
How to run React and Rails on the same server
Create a large number of records with one command using the Ruby on Rails seeds.rb file
I got a warning message with the rails _6.0.3_ new hello_myapp command
I summarized the flow until implementing simple_calendar in Ruby on Rails.
Things to remember and concepts in the Ruby on Rails tutorial
Why I have 10 years of experience in Ruby and don't run the [absolutely] gem install rails command
[Ruby On Rails] In the create action and destroy action, emergency measures when redirect_to action:: show cannot be (cannot be used)
I want to download a file on the Internet using Ruby and save it locally (with caution)
Ruby on Rails DB Tips for creating methods to reduce the load
When you get LoadError (cannot load such file --ruby_file) when you require in Ruby
Do your best with gRPC with ruby ​​on the server and PHP on the client