5

I have looked at several other posts on this and tried the solutions without success.

The question is marked as a duplicate of this solution cannot load such file -- sqlite3/sqlite3_native (LoadError) on ruby on rails but the answer given didn't work for me. I simply got the same error

I have just installed rails so everything is up-to-date I am using the following: Windows 10, ruby version 2.5.1, rails version 5.2.0

have also tried updating SQLite gem with bundle update.

here is the error:

C:\proje>rails s

Traceback (most recent call last):

        43: from bin/rails:4:in `<main>'

        42: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:283:in `require'

        41: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:249:in `load_dependency'

        40: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:283:in `block in require'

        39: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29:in `require'

        38: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20:in `require_with_bootsnap_lfi'

        37: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/loaded_features_index.rb:65:in `register'

        36: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `block in require_with_bootsnap_lfi'

        35: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require'

        34: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/railties-5.2.0/lib/rails/commands.rb:18:in `<top (required)>'

        33: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/railties-5.2.0/lib/rails/command.rb:46:in `invoke'

        32: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/railties-5.2.0/lib/rails/command/base.rb:65:in `perform'

        31: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/thor-0.20.0/lib/thor.rb:387:in `dispatch'

        30: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/thor-0.20.0/lib/thor/invocation.rb:126:in `invoke_command'

        29: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/thor-0.20.0/lib/thor/command.rb:27:in `run'

        28: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/railties-5.2.0/lib/rails/commands/server/server_command.rb:142:in `perform'

        27: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/railties-5.2.0/lib/rails/commands/server/server_command.rb:142:in `tap'

        26: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/railties-5.2.0/lib/rails/commands/server/server_command.rb:145:in `block in perform'

        25: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:283:in `require'

        24: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:249:in `load_dependency'

        23: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:283:in `block in require'

        22: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29:in `require'

        21: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20:in `require_with_bootsnap_lfi'

        20: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/loaded_features_index.rb:65:in `register'

        19: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `block in require_with_bootsnap_lfi'

        18: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require'

        17: from C:/proje/config/application.rb:7:in `<top (required)>'

        16: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bundler-1.16.1/lib/bundler.rb:114:in `require'

        15: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bundler-1.16.1/lib/bundler/runtime.rb:65:in `require'

        14: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bundler-1.16.1/lib/bundler/runtime.rb:65:in `each'

        13: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bundler-1.16.1/lib/bundler/runtime.rb:76:in `block in require'

        12: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bundler-1.16.1/lib/bundler/runtime.rb:76:in `each'

        11: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bundler-1.16.1/lib/bundler/runtime.rb:81:in `block (2 levels) in require'

        10: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:79:in `require'

         9: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:70:in `require_with_bootsnap_lfi'

         8: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/loaded_features_index.rb:65:in `register'

         7: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:71:in `block in require_with_bootsnap_lfi'

         6: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:71:in `require'

         5: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/sqlite3-1.3.13-x64-mingw32/lib/sqlite3.rb:2:in `<top (required)>'

         4: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/sqlite3-1.3.13-x64-mingw32/lib/sqlite3.rb:6:in `rescue in <top (required)>'

         3: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:283:in `require'

         2: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:249:in `load_dependency'

         1: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:283:in `block in require'

C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require': cannot load such file -- sqlite3/sqlite3_native (LoadError)



C:\proje>

How can I proceed?

EDIT: add Gemfile

source 'https://rubygems.org'

    git_source(:github) do |repo_name|
      repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
      "https://github.com/#{repo_name}.git"
    end


    # Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
    gem 'rails', '~> 5.0.7'
    # Use sqlite3 as the database for Active Record
    gem 'sqlite3'
    # Use Puma as the app server
    gem 'puma', '~> 3.0'
    # Use SCSS for stylesheets
    gem 'sass-rails', '~> 5.0'
    # Use Uglifier as compressor for JavaScript assets
    gem 'uglifier', '>= 1.3.0'
    # Use CoffeeScript for .coffee assets and views
    gem 'coffee-rails', '~> 4.2'
    # See https://github.com/rails/execjs#readme for more supported runtimes
    # gem 'therubyracer', platforms: :ruby

    # Use jquery as the JavaScript library
    gem 'jquery-rails'
    # Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
    gem 'turbolinks', '~> 5'
    # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
    gem 'jbuilder', '~> 2.5'
    # Use Redis adapter to run Action Cable in production
    # gem 'redis', '~> 3.0'
    # Use ActiveModel has_secure_password
    # gem 'bcrypt', '~> 3.1.7'

    # Use Capistrano for deployment
    # gem 'capistrano-rails', group: :development

    group :development, :test do
      # Call 'byebug' anywhere in the code to stop execution and get a debugger console
      gem 'byebug', platform: :mri
    end

    group :development do
      # Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
      gem 'web-console', '>= 3.3.0'
    end

    # Windows does not include zoneinfo files, so bundle the tzinfo-data gem
    gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
Sachin Singh
  • 7,107
  • 6
  • 40
  • 80
Owen
  • 361
  • 1
  • 5
  • 16
  • By default `Rails` comes in bundled with `Sqllite` only so it should not cause any problem. Can you search your `Gemfile.lock` for `Sqllite` gem and post the current installed version? – Swaps May 09 '18 at 09:08
  • Possible duplicate of [cannot load such file -- sqlite3/sqlite3\_native (LoadError) on ruby on rails](https://stackoverflow.com/questions/17643897/cannot-load-such-file-sqlite3-sqlite3-native-loaderror-on-ruby-on-rails) – Swaps May 09 '18 at 09:10
  • The question is a duplicate, yes, but as I stated in my post I have already looked at that answer and it didn't work – Owen May 09 '18 at 09:14
  • In your gem file add the line `ruby '2.5.1'`. It may work. Even it works, its not the permanent fix. Try this and let me know. We proceed further. – Akash Pinnaka May 09 '18 at 09:19
  • Try to run command prompt on `run as a administrator` mode then try – Velusamy Venkatraman May 09 '18 at 09:34
  • @Swaps sqlite3 gem is version number 1.3.13 – Owen May 09 '18 at 13:09
  • i have the same this problem: version install: Ruby+Devkit 2.5.1-1 (x64) at https://rubyinstaller.org/downloads/ – D T May 21 '18 at 03:44
  • Please add your Gemfile. – Sachin Singh May 21 '18 at 07:55
  • @SachinSingh Gemfile added – Owen May 21 '18 at 13:08
  • Try `bundle exec rails s`. – Amin Shah Gilani May 21 '18 at 18:18
  • @owen it does not seem to complete Gemfile, because the exception is coming from `bootsnap` gem, which is not present in Gemfile. – Sachin Singh May 22 '18 at 06:16
  • People do not get this error? the problem : it can't load sqlite3. i changed s.require_paths= ["lib/sqlite3_native"] or reinstall sqlite3, but it still not working. if i create a Rails app and connect to Postgresql, It is ok. – D T May 23 '18 at 10:56

3 Answers3

16

This should work for you since I had the exact same issue. Make sure you have this in your gemfile:

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

At the time of writing this post I can confirm this works for me.

EDIT: For ref & to keep track of the issue keep an eye on this: https://github.com/sparklemotion/sqlite3-ruby/pull/229

As you see, they merged the fix like 6 days ago, but I think the CD/CI tag on the repo says build failing hence they are yet to release the fix in the gem. For now just refer the branch as the source & you should be good.

Aaditya Maheshwari
  • 714
  • 1
  • 5
  • 16
0

on windows with chefdk 1) download sqlite3.h/sqlite3.dll from original site 2) gem install sqlite3 --platform ruby -- --with-opt-include=C:/sqlitedir --with-sqlite3-dir=C:/sqlitedir --with-sqlite3-lib=C:/sqlitedir

se_pavel
  • 2,181
  • 1
  • 28
  • 42
-5

Don't complicate your life in Windows 10.

Install bash:

  1. Open Microsoft Store.
  2. Find and install Ubuntu.
  3. Run it and then you can install ruby/rails etc.

So you can use all features without Windows-specific problems.

N0xFF
  • 126
  • 1
  • 5
  • 2
    Running the Linux subsystem comes with it's own caveats and problems (especially if the poster isn't familiar with Linux). It also may not be an option, because we don't know the posters requirements. – Jay Dorsey May 23 '18 at 18:54