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

如何启动已有Rails项目?GitHub项目运行sqlite3报错求助

Fixing the sqlite3 LoadError When Starting Rails on Windows

Hey, I’ve run into this exact cannot load such file -- sqlite3/sqlite3_native (LoadError) issue on Windows before—let me walk you through the most reliable fixes that have worked for me and other Rails devs:

1. Lock sqlite3 to a version compatible with your Ruby/Rails setup

Windows has weird compatibility quirks with newer sqlite3 gem versions, especially with older Ruby (like 2.5.x) and Rails combinations. Here’s what to do:

  • Open your project’s Gemfile and replace the line gem 'sqlite3' with:
    gem 'sqlite3', '~> 1.3.16'
    
    (This version is proven to play nice with Ruby 2.5.x on Windows)
  • Run this command to reinstall the gem with the correct version:
    bundle install
    

2. Manually install the Windows-compatible sqlite3 gem

Sometimes the default gem installer skips the native extensions needed for Windows. Try this:

  1. First, download the precompiled Windows SQLite3 binaries (make sure it includes the include and lib folders) and extract them to C:\sqlite.
  2. Then run this command to install the gem with the correct path:
gem install sqlite3 --platform=ruby -- --with-sqlite3-dir="C:\sqlite"
  1. Finally, run bundle install again to link it to your project.

3. Verify your Ruby DevKit is set up correctly

Windows requires the Ruby DevKit to compile native gem extensions. Double-check it’s configured properly:

  • Open a command prompt and navigate to your DevKit installation folder (usually something like C:\RubyDevKit).
  • Run these commands to initialize and install the DevKit:
    ruby dk.rb init
    ruby dk.rb install
    
  • Uninstall the broken sqlite3 gem first:
    gem uninstall sqlite3
    
  • Then run bundle install again to rebuild the gem with the correct environment.

4. Switch to a RubyInstaller build with bundled DevKit

If all else fails, uninstall your current Ruby version and reinstall using the RubyInstaller for Windows that includes the DevKit (look for the "Ruby+Devkit" package for Ruby 2.5.x). This sets up the native extension environment automatically, so you won’t have to mess with manual configurations. Once reinstalled, clone your project again (or run bundle install on your existing one) and try starting Rails with rails s again.

内容的提问来源于stack exchange,提问作者D. Matusik

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.19 03:34:25