Skip to content

Print the final content of the Gemfile.lock #783

Closed

Description

@Fryguy

Feature request: Print the final content of the Gemfile.lock.

From a diagnostics point of view, it is very useful to see exactly what versions of gems were installed from run to run.

In our particular case, we had a corrupted cache which caused the list of gems to be rebuilt, and the new run failed our CI. While I could see the newly installed gems as they were installed, when I went to the previous green run, I couldn't see what was installed.

The request is simply, at the end of installation, print the Gemfile.lock into the log in a collapsed section.

I am willing to make a PR for this feature but wanted to discuss first.

Activity

  1. eregon commented on Jul 24, 2025

    @eregon
    Member

    setup-ruby runs bundle install and that used to print the list of all gems, even if they are already installed:
    https://github.com/ruby/setup-ruby/actions/runs/16427759281/job/46422252372#step:3:33

    It seems bundle install doesn't do this by default anymore for recent Bundler unfortunately:
    https://github.com/ruby/setup-ruby/actions/runs/16427759281/job/46422252395#step:3:40

    Could you find out if bundle install has an option to list all gems in that Gemfile?

    If not, we could run bundle show but that would be slow, or print the Gemfile.lock, which is faster but also quite a bit longer output, and redundant for repositories which check in their Gemfile.lock.

  2. Fryguy commented on Jul 24, 2025

    @Fryguy
    ContributorAuthor

    There used to be a setting, and then they removed it in ruby/rubygems#6804 to never print it. The workaround is to use --verbose or DEBUG-1 env var, but IMO that swings too far in the other direction as that also shows the HTTP traffic.

  3. eregon commented on Jul 24, 2025

    @eregon
    Member

    I tried --verbose/DEBUG=1 and yeah that looks too messy:

    $ bundle install --verbose
    Running `bundle install --verbose` with bundler 2.6.4
    Found no changes, using resolution from the lockfile
    Using bundler 2.6.4
    0:  bundler (2.6.4) from /home/eregon/.rubies/ruby-3.4.2/lib/ruby/gems/3.4.0/specifications/bundler-2.6.4.gemspec
    Using json 2.2.0
    0:  json (2.2.0) from /home/eregon/tmp/bundler-gemfile/vendor/bundle/ruby/3.4.0/specifications/json-2.2.0.gemspec
    Using path 2.1.0
    0:  path (2.1.0) from /home/eregon/tmp/bundler-gemfile/vendor/bundle/ruby/3.4.0/specifications/path-2.1.0.gemspec
    Bundle complete! 2 Gemfile dependencies, 3 gems now installed.
    Bundled gems are installed into `./vendor/bundle`
    
    $ bundle show
    Gems included by the bundle:
      * bundler (2.6.4)
      * json (2.2.0)
      * path (2.1.0)
    
    $ cat Gemfile.lock 
    GEM
      remote: https://rubygems.org/
      specs:
        json (2.2.0)
        path (2.1.0)
    
    PLATFORMS
      ruby
      x86_64-linux
    
    DEPENDENCIES
      json (= 2.2.0)
      path
    
    BUNDLED WITH
       2.6.4
    

    bundle show is nicest, but I'm concerned it would increase the runtime of every job, especially on non-CRuby and for Gemfile with many gems.
    Maybe you could file a Bundler feature for a bundle install flag or env var to print the same as bundle show?

    In the meanwhile, I agree printing Gemfile.lock in a collapsed section is the best, could you make a PR?

  4. Fryguy commented on Jul 24, 2025

    @Fryguy
    ContributorAuthor

    Will do!

  5. added 2 commits that reference this issue on Jul 24, 2025
    23ee4ef
    0f7db01
  6. added a commit that references this issue on Jul 25, 2025
    7a77259
  7. added a commit that references this issue on Jul 25, 2025
    e8621f0
  8. added a commit that references this issue on Jul 25, 2025
    6284f69
  9. added a commit that references this issue on Jul 26, 2025
    ba9e71c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions