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

Ubuntu环境下安装bundle时sqlite3 gem原生扩展编译失败求助

解决Rails 3.2.0升级后Ubuntu下sqlite3 gem安装失败问题

问题核心

从错误日志中可明确定位关键原因:

Could not configure the build properly (pkg_config). Please install either the pkg-config utility or the pkg-config rubygem.

系统缺少pkg-config工具,同时可能缺失sqlite3开发依赖库,导致gem无法构建原生扩展。

解决方案

1. 安装系统级pkg-config工具

执行命令更新包列表并安装pkg-config:

sudo apt update && sudo apt install pkg-config

2. 安装sqlite3开发依赖库

原生扩展编译需要sqlite3的头文件与库文件,安装对应开发包:

sudo apt install libsqlite3-dev

3. 清理残留并重新安装gem

先卸载之前失败安装的sqlite3 gem:

gem uninstall sqlite3

再重新执行bundle安装:

bundle install

或直接指定错误日志中的版本安装:

gem install sqlite3 -v 1.5.4

4. (可选)强制使用系统本地sqlite3版本

若gem默认打包的sqlite3(3.40.0)与本地3.37.2存在冲突,可指定调用系统自带版本:

bundle config build.sqlite3 --with-sqlite3-lib=/usr/lib/x86_64-linux-gnu --with-sqlite3-include=/usr/include/sqlite3
bundle install

或直接通过gem命令指定:

gem install sqlite3 -v 1.5.4 -- --with-sqlite3-lib=/usr/lib/x86_64-linux-gnu --with-sqlite3-include=/usr/include/sqlite3

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.07 11:10:13