Ruby on Rails生成Scaffold时遇sqlite3-1.3.13 gem未找到问题求助
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
Update your Gemfile
Open your project’sGemfileand replace the linegem '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: :jrubyThis tells Bundler to use the JDBC version of SQLite when running on JRuby, which is fully JVM-compatible.
Reinstall your gems
Run this command to make sure Bundler picks up the new gem configuration:bundle installIf you hit leftover conflicts, first uninstall the incompatible sqlite3 gem with:
gem uninstall sqlite3Then run
bundle installagain.Retry the scaffold command
Now go ahead and re-run your generate command:rails generate scaffold User name:string email:stringThis 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

