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

Ruby on Rails生成Scaffold时遇sqlite3-1.3.13 gem未找到问题求助

Fixing the Bundler::GemNotFound Error for sqlite3 in JRuby + Rails

Hey there! I see you're hitting a snag with your first Rails app on JRuby—let's get this sorted out quickly.

The Root Cause

JRuby runs on the JVM, which doesn’t play nice with the native C-based sqlite3 gem that regular Ruby uses. The error you’re seeing happens because Bundler can’t locate that native gem in your JRuby environment, and for good reason—it’s not compatible here.

Step-by-Step Fix

  1. Update your Gemfile
    Open your project’s Gemfile and replace the line gem 'sqlite3' with this platform-specific configuration (it’ll automatically use the right gem for Ruby vs. JRuby):

    gem 'sqlite3', platforms: :ruby
    gem 'jdbc-sqlite3', platforms: :jruby
    

    This tells Bundler to use the JDBC version of SQLite when running on JRuby, which is fully JVM-compatible.

  2. Reinstall your gems
    Run this command to make sure Bundler picks up the new gem configuration:

    bundle install
    

    If you hit leftover conflicts, first uninstall the incompatible sqlite3 gem with:

    gem uninstall sqlite3
    

    Then run bundle install again.

  3. Retry the scaffold command
    Now go ahead and re-run your generate command:

    rails generate scaffold User name:string email:string
    

    This should execute without the GemNotFound error now.

Quick Check

If you’re still stuck, double-check that your Rails version is compatible with your JRuby version (JRuby 9.1.x works smoothly with Rails 5.x, for example). Mismatched versions can sometimes cause odd gem conflicts too.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.25 07:43:43