Skip to content

chore: make gemspecs compatible with Dependabot Bundler sanitizer - #28925

Open
amanda-tarafa wants to merge 1 commit into
googleapis:mainfrom
amanda-tarafa:fix-gemspec-dependabot
Open

amanda-tarafa wants to merge 1 commit into
googleapis:mainfrom
amanda-tarafa:fix-gemspec-dependabot

Conversation

@amanda-tarafa

Copy link
Copy Markdown

Switch from require File.expand_path(..., __dir__) to require_relative so Dependabot's IncludedPathFinder can resolve and fetch the version file without requiring $LOAD_PATH setup.

Remove the top-level gem_version = ... local variable assignment and assign gem.version directly to the version constant (interpolating #{gem.version} in documentation_uri). Dependabot's GemspecSanitizer rewrites gem.version = ... (on_send) and strips gem.metadata, but does not rewrite top-level local variable assignments (on_lvasgn), which caused Bundler::GemspecError: uninitialized constant Google when the version file was absent.

Switch from `require File.expand_path(..., __dir__)` to `require_relative` so Dependabot's `IncludedPathFinder` can resolve and fetch the version file without requiring `$LOAD_PATH` setup.

Remove the top-level `gem_version = ...` local variable assignment and assign `gem.version` directly to the version constant (interpolating `#{gem.version}` in `documentation_uri`). Dependabot's `GemspecSanitizer` rewrites `gem.version = ...` (`on_send`) and strips `gem.metadata`, but does not rewrite top-level local variable assignments (`on_lvasgn`), which caused `Bundler::GemspecError: uninitialized constant Google` when the version file was absent.
@amanda-tarafa
amanda-tarafa requested a review from a team as a code owner December 3, 2026 03:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant