用途:Bundler 用于管理 Ruby 项目的 gem 依赖,通过 Gemfile 声明所需 gem 及版本约束,通过 Gemfile.lock 锁定解析后的精确版本,保证团队与部署环境使用一致的依赖。
主要能力:支持精确版本、最低版本、悲观约束(如 ~> 7.1)及组合约束;支持按 group 分组(development、test、production 等)并可在安装时跳过;支持 rubygems.org、私有 gem 服务器、Git 仓库(github/branch/tag/ref)和本地 path 来源;支持平台限定(:ruby、:jruby、:mswin 等)与 Ruby 版本声明;可管理 lock 文件中的目标平台。
常用命令:bundle install 按 lock 安装;bundle update 更新全部或指定 gem,支持 --conservative、--patch、--minor;bundle info、bundle list、bundle outdated、bundle audit 查看依赖与安全信息;bundle exec 在依赖环境中执行命令;bundle binstubs 生成 binstub;bundle config set --local 配置本地路径、跳过分组、并行任务数等;bundle lock --add-platform/--remove-platform 管理平台。
适用场景:Ruby/Rails 项目依赖管理、CI/CD 中可复现安装(frozen、deployment 模式)、私有 gem 与 Git 依赖、多平台部署(如 aarch64 Linux)。
限制与注意:Gemfile 与 Gemfile.lock 都应提交;lock 文件由机器生成,应有意更新而非意外变更;版本冲突时需更新冲突 gem、放宽约束或查看依赖树;原生扩展失败可通过 bundle config build.<gem> 传入编译参数。资料未提供该技能的收费、价格或平台支持等额外信息。