What this thread does
Do first: run ruby -v and bundle config list, then compare the active interpreter and Bundler selection with the Gemfile and BUNDLED WITH before changing the lockfile.
Short answer
As of November 2026, the release reference is Ruby 4.0.9, October 23; the command reference targets Bundler 4.1.0, November 16. Use these as references; choose the application's target Ruby branch deliberately. Prepare a compatible lockfile on the target Ruby with all deployment platforms, rebuild native gems there, then require an unchanged lockfile in deployment. An install alone does not establish that an extension can load.
Choose / don't choose
- Keep the locked versions: choose when gem requirements and artifacts support the new interpreter; don't discard the lockfile to repair compiled files.
bundle installpreserves unchanged dependencies (install reference). - Source compilation: choose when no compatible binary exists; don't enable it merely because Ruby changed. Nokogiri recommends compatible precompiled gems (maintainer guide).
- Selective dependency update: choose when a locked gem cannot support the target Ruby; don't expect recompilation to fix incompatible Ruby APIs. Use
bundle update nokogiri --conservativefor that gem rather than updating the entire bundle (update reference).
Not for: Ruby regexp security patch selection; see ruby-regexp-compiler-gitlab-cves-upgrade-rbenv-asdf-docker.
Settings that matter
Rows apply to Bundler 4.1.0 docs as of November 2026 (package requirements).
| Setting or flag | Value / default | Applies to | Source |
|---|---|---|---|
frozen / BUNDLE_FROZEN | Disallow automatic changes to Gemfile.lock; commands are blocked unless it can be installed exactly as written | Current Bundler docs | config |
force_ruby_platform / BUNDLE_FORCE_RUBY_PLATFORM | Ignore the machine platform and install only ruby platform gems | Current Bundler docs | config |
version / BUNDLE_VERSION | Default lockfile; retain it to select the version in Gemfile.lock. system selects the system Bundler; an exact version overrides selection | Current Bundler docs | config |
bundle lock --add-platform | Before freezing, add each target, e.g. bundle lock --add-platform x86_64-linux-gnu; re-resolves for the added platform | Current Bundler docs; replace example with target platform | lock, platform example |
bundle update --ruby | Refresh locked Ruby metadata to the active interpreter after aligning the Gemfile Ruby requirement | Current Bundler docs | update |
bundle install --force | Reinstall every gem even if already installed; use when an existing installation cannot be repaired | Current Bundler docs | install |
Local configuration takes precedence over environment variables, then global configuration, then defaults; inspect bundle config get <name> when deployment does not enforce the intended policy (config).
Order of operations
1. Activate the target Ruby; inspect ruby -v, gem --version, bundle --version, the Gemfile and BUNDLED WITH. Keep the recorded Bundler only if compatible. Bundler 4.1.0 requires Ruby >= 3.2.0 and RubyGems >= 3.4.1. For another recorded release, inspect its registry requirements. 2. Allow intentional lock changes in development: bundle config set --local frozen false; also remove deployment mode there if enabled. Align the Gemfile Ruby requirement, then use bundle update --ruby. If changing Bundler deliberately, bundle update --bundler=4.1.0 records the compatible reference release (update). 3. Before freezing, run bundle lock --add-platform PLATFORM for each target. Use force_ruby_platform before resolution only if source builds are needed. Run bundle install and inspect the lockfile diff (lock). 4. Run bundle pristine for installed gems in the active bundle: restore installed gems to pristine condition using the local gem cache. It overwrites gem edits and forces git checkouts; it excludes Bundler and path gems. If gems are absent under the new Ruby, install them first (pristine, RubyGems rebuild semantics). 5. Before rebuilding, supply matching Ruby headers, a C compiler, make and required library headers. Debian/Ubuntu's distro-Ruby example is sudo apt-get install build-essential ruby-dev; a version-managed Ruby needs its matching headers. macOS needs xcode-select --install. Nokogiri also needs zlib/lzma development packages and patch (compiler prerequisites). 6. Commit Gemfile/lockfile changes, install cleanly on each target, and load an affected gem, e.g. bundle exec ruby -rnokogiri -e 'puts Nokogiri::VERSION'. Run application checks. (deployment contract).
Known failures and fixes
| Error (short quote) | Cause | Fix | Source |
|---|---|---|---|
Your lockfile needs to be updated, but it can't be because frozen mode is set. | Frozen mode prevents a required lockfile update | Prepare and commit the revised lockfile outside frozen deployment; retain frozen deployment policy | Bundler source |
cannot load such file -- nokogiri/nokogiri (LoadError) | An extension installed for another Ruby is reused by an unsupported interpreter | In an isolated target environment, remove the stale Nokogiri installation and resolve/install a compatible artifact; source compilation only if needed | Nokogiri troubleshooting |
Diagnostic: cannot load such file -- nokogiri/nokogiri (LoadError)
Identify the interpreter and installation first. Taladar's April 1, 2021 report describes unusable native gems after changing Ruby build configuration despite an uneventful install. This is historical evidence.
Missing
- The linked source does not confirm: returning BUNDLE_VERSION to lockfile in the update procedure.
- The application's old Ruby, locked gem versions and deployment platforms are unspecified; no exact compatible Bundler pin or complete Ruby API migration can be selected from those inputs.
Checked
2026-11-12; Ruby release and Bundler registry pages, config/install/update/lock/pristine references, RubyGems pristine reference, Nokogiri installation guide and Taladar report read. No Ruby install, rebuild or application commands executed.
Started from a post by @RubyGems maintainers, packaged by the editor. Original post