Skip to content

Commit b359ea3

Browse files
Edouard-chinmatzbot
authored andcommitted
[ruby/rubygems] Skip checksum for the bundler gem if no bundler.gem exists on disk:
- ### Problem This change is purely to fix a problem when developing Bundler. When we tried to release Bundler 4.0.9, we bumped the VERSION from `4.1.0.dev` to `4.0.9`, this condition now evaluates to false https://github.com/ruby/rubygems/blob/34d19fa8a3f84c50e2ba65e0f39c80045e7cbfb8/bundler/lib/bundler/lockfile_generator.rb#L106. We then ended up with a CI crash. ``` Errno::ENOENT: No such file or directory @ rb_sysopen - /Users/runner/work/rubygems/rubygems/cache/bundler-4.0.9.gem ``` ### Context Computing a checksum for the `bundler` gem is only possible when the `bundler.gem` binary exists on disk. When a regular user interacts with `bundler`, the spec is loaded from disk and an associated cached `bundler.gem` should exists. However, when developing Bundler, the spec doesn't come from disk but from a fake spec https://github.com/ruby/rubygems/blob/34d19fa8a3f84c50e2ba65e0f39c80045e7cbfb8/bundler/lib/bundler/source/metadata.rb#L22-L28 that with no associated `bundler.gem`. ### Solution To prevent CI from breaking whenever we make a release, we have to skip computing a checksum if no `bundler.gem` exists. ruby/rubygems@01e0e61612
1 parent a08f547 commit b359ea3

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

lib/bundler/lockfile_generator.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,11 @@ def add_section(name, value)
105105
def bundler_checksum
106106
return [] if Bundler.gem_version.to_s.end_with?(".dev")
107107

108+
bundler_spec = definition.sources.metadata_source.specs.search(["bundler", Bundler.gem_version]).last
109+
return [] unless File.exist?(bundler_spec.cache_file)
110+
108111
require "rubygems/package"
109112

110-
bundler_spec = definition.sources.metadata_source.specs.search(["bundler", Bundler.gem_version]).last
111113
package = Gem::Package.new(bundler_spec.cache_file)
112114
definition.sources.metadata_source.checksum_store.register(bundler_spec, Checksum.from_gem_package(package))
113115

0 commit comments

Comments
 (0)