ruby/rubygems · error · ProductionError

Frozen mode is set, but there's no lockfile

Error message

Frozen mode is set, but there's no lockfile

What it means

Under frozen mode (Bundler.frozen_bundle?) Definition#ensure_equivalent_gemfile_and_lockfile first requires that a lockfile exists at all, raising ProductionError when it does not (lib/bundler/definition.rb:484). Frozen and deployment installs are lockfile-driven: bundler installs exactly the versions recorded in Gemfile.lock, so with no lockfile there is nothing to install from and bundler refuses instead of resolving freely. The check runs on the install, Bundler.setup and inject paths.

Source

Thrown at lib/bundler/definition.rb:484

            "Try running bundle update --ruby to resolve this."
        end
        version
      end
    end

    def bundler_version_to_lock
      @resolved_bundler_version || Bundler.gem_version
    end

    def to_lock
      require_relative "lockfile_generator"
      LockfileGenerator.generate(self)
    end

    def ensure_equivalent_gemfile_and_lockfile(explicit_flag = false)
      return unless Bundler.frozen_bundle?

      raise ProductionError, "Frozen mode is set, but there's no lockfile" unless lockfile_exists?

      msg = lockfile_changes_summary("frozen mode is set")
      return unless msg

      unless explicit_flag
        suggested_command = unless Bundler.settings.locations("frozen").keys.include?(:env)
          "bundle config set frozen false"
        end
        msg << "\n\nIf this is a development machine, remove the #{SharedHelpers.relative_lockfile_path} " \
               "freeze by running `#{suggested_command}`." if suggested_command
      end

      raise ProductionError, msg
    end

    def validate_runtime!
      validate_ruby!
      validate_platforms!

View on GitHub (pinned to 86cbb817a3)

Solutions

  1. Generate and commit the lockfile: run `bundle install` on a dev machine, `git add Gemfile.lock`, push, then redeploy
  2. If Gemfile.lock is gitignored, remove it from .gitignore; frozen deploys require the lockfile in version control
  3. If freezing was not intended, turn it off: `bundle config set frozen false`, unset BUNDLE_FROZEN, or drop --deployment
  4. In Dockerfiles, COPY Gemfile.lock together with Gemfile before RUN bundle install

Example fix

# before
$ bundle install --deployment
# => Frozen mode is set, but there's no lockfile

# after
$ bundle install && git add Gemfile.lock && git commit -m "add lockfile" && git push
$ bundle install --deployment
Defensive patterns

Strategy: validation

Validate before calling

frozen = %w[1 true].include?(ENV["BUNDLE_FROZEN"]) || Bundler.settings["frozen"]
if frozen && !Bundler.default_lockfile.exist?
  abort "frozen install needs a committed Gemfile.lock"
end

Prevention

When it happens

Trigger: `bundle install --deployment` or BUNDLE_FROZEN=true in a tree with no Gemfile.lock (fresh clone of a repo that never committed one); a Docker image that COPYies Gemfile but not Gemfile.lock before a frozen install; Bundler.setup under a frozen env in a freshly generated app.

Common situations: Gemfile.lock gitignored by a misconfigured template while CI or a PaaS sets frozen or deployment; deploy tooling defaulting to --deployment; a new service bootstrapped without ever generating the lockfile.

Related errors


AI-assisted analysis of ruby/rubygems@86cbb817a3 (2026-08-23). Data as JSON: /api/errors/f8e366c00bf797c7. Report an issue: GitHub.