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

如何在Dokku 0.12.5中更新Bundler版本?gem bundle install无效

Fixing Bundler Version Update Issues with Dokku 0.12.5

I’ve been there with older Dokku versions—you run dokku run app gem update bundler and it says it installed the new version, but when you deploy, bundle install still uses the old one. The problem is that dokku run spins up a temporary throwaway container; any gems you install there vanish as soon as the container shuts down. They don’t persist to your app’s build or runtime environment.

Here are three solid ways to fix this properly:

1. Pin Bundler in Your Gemfile

The most straightforward and maintainable fix is to specify the exact Bundler version in your project’s Gemfile. Add this line at the very top:

gem 'bundler', '1.16.1'

Commit this change to your Git repo, then push to Dokku:

git push dokku master

Dokku’s Ruby buildpack will pick up the pinned version during deployment and install it automatically.

2. Use Dokku’s Buildpack Environment Variable

Dokku’s official Ruby buildpack lets you set a Bundler version via an environment variable. Run this command to configure it for your app:

dokku config:set app DOKKU_RUBY_BUNDLER_VERSION=1.16.1

Once set, redeploy your app. The buildpack will use this version instead of the default it ships with.

3. Add a Pre-Build Hook (For Edge Cases)

If the first two methods don’t work (some older buildpack versions have odd quirks), you can force the update with a pre-build script:

  1. Create a .dokku/pre-build file in your app’s root directory with this content:
#!/bin/bash
gem update bundler --no-document -v 1.16.1
  1. Make it executable:
chmod +x .dokku/pre-build
  1. Commit the file and redeploy. This script runs right before the main build process, ensuring the correct Bundler version is installed before bundle install runs.

Check if It Worked

After redeploying, verify the version is active with:

dokku run app bundler -v

You should see Bundler version 1.16.1 in the output.

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

相关产品推荐
方舟 Agent Plan

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

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