You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Windows10下Ruby2.5.0+Rails5.1.5无法启动服务器、执行rake db:migrate求助

Fixing "cannot load such file sqlite3native" Error on Windows 10 for Rails Projects

Hey there! I’ve run into this exact sqlite3 native extension issue on Windows before—let’s walk through the most reliable fixes step by step, since generic solutions sometimes miss Windows-specific quirks.

First, Let’s Confirm the Basics

Make sure you’re using a compatible combination of:

  • Ruby 2.5.x (since you mentioned C:/Ruby25-x64)
  • Rails version that works with Ruby 2.5 (stick to Rails 6.1 or earlier; Rails 7+ has stricter compatibility requirements for older Ruby versions)
  • Sqlite3 gem version that supports both your Ruby and Rails setup

Step 1: Uninstall and Reinstall the Sqlite3 Gem with Windows-Specific Options

First, clean up any broken or mismatched installations:

gem uninstall sqlite3 --all

Try installing the precompiled Windows binary first—it’s the quickest fix for most cases:

gem install sqlite3 --platform=mswin64

If that fails (common with older Ruby versions), grab the official Sqlite3 precompiled binaries for Windows 64-bit:

  • Extract the files to a simple, space-free path like C:/sqlite (avoid Chinese characters or special symbols!)
  • Ensure the folder has include and lib subdirectories
  • Run this command to install the gem with explicit path references:
gem install sqlite3 --platform=ruby -- --with-sqlite3-dir="C:/sqlite" --with-sqlite3-lib="C:/sqlite/lib" --with-sqlite3-include="C:/sqlite/include"

Step 2: Lock the Sqlite3 Version in Your Gemfile

Open your project’s Gemfile and update the sqlite3 line to a version proven to work with Ruby 2.5 on Windows:

gem 'sqlite3', '~> 1.4.2'

Then run:

bundle install

This ensures your project uses a stable, compatible version instead of pulling the latest (which might not support your Ruby setup).

Step 3: Fix Your Local Compilation Environment (If Binary Installs Fail)

If you still hit errors, you need to set up the DevKit for Ruby 2.5:

  1. Download the DevKit matching your Ruby 2.5 x64 installation from the RubyInstaller website
  2. Extract it to C:/DevKit (no spaces or special characters!)
  3. Open a command prompt in the DevKit folder and run:
ruby dk.rb init
ruby dk.rb install

This links the DevKit to your Ruby installation, enabling native gem compilation.

You might also need to install Visual C++ Build Tools (the 2017 version works best for Ruby 2.5) to get the necessary compilers for native extensions.

Step 4: Verify the Fix

Navigate back to your Rails project folder and test either command:

rails s
# or
rake db:migrate

If everything worked, you shouldn’t see the sqlite3native load error anymore.

Quick Troubleshooting Tip

Double-check that your project path doesn’t have spaces or non-ASCII characters—Windows and Ruby native extensions often throw weird errors when paths aren’t simple and straightforward.

内容的提问来源于stack exchange,提问作者ima_prog

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.20 11:49:46