Troubleshooting for Ruby gems

This document explains why certain errors may occur when working with Ruby gems in an Artifact Registry repository, and possible remedies for those situations.

Expired push credentials

You made a push request but received the following error message:

Pushinggemtohttps://LOCATION-ruby.pkg.devPROJECT/REPOSITORY..
Therequestdoesnothavevalidauthenticationcredentials.

To refresh your credentials, generate a new token by running the following command:

exportGEM_HOST_API_KEY="Bearer $(gcloudauthprint-access-token)"
exportHOST="https://LOCATION-ruby.pkg.dev/PROJECT/REPOSITORY"
bundleconfig$HOST$GEM_HOST_API_KEY

Where:

  • LOCATION is the regional or multi-regional location for the repository.
  • PROJECT is the project ID. If this flag is omitted, then the current or default project is used.
  • REPOSITORY is the ID of the repository. If you configured a default Artifact Registry repository, then that default repository is used when this flag is omitted from the command.

Login prompt when pushing

You made a push request but received received a message requesting your ruby.pkg.dev credentials:

Enter your https://us-ruby.pkg.dev/REPOSITORY/GEM_NAME credentials.
Don't have an account yet? Create one at https://us-ruby.pkg.dev/REPOSITORY/GEM_NAME/sign_up
 Email:

Try running the following:

GEM_HOST_API_KEY="Bearer $(gcloudauthprint-access-token)"

Expired pull credentials

You made a pull request but received the following error message:

Unabletodownloaddatafromhttps://oauth2accesstoken:REDACTED@LOCATION-ruby.pkg.dev/PROJECT/REPOSITORY/-badresponseUnauthorized401(https://oauth2accesstoken:REDACTED@LOCATION-ruby.pkg.dev/PROJECT/REPOSITORY/latest_specs.4.8.gz)

To refresh your credentials, remove the expired credential source from gem sources. Next, generate a new token by running the following command:

exportGEM_HOST_API_KEY="Bearer $(gcloudauthprint-access-token)"
exportHOST="https://LOCATION-ruby.pkg.dev/PROJECT/REPOSITORY"
bundleconfig$HOST$GEM_HOST_API_KEY

Where:

  • LOCATION is the location of your repository.
  • PROJECT is the project ID. If this flag is omitted, then the current or default project is used.
  • REPOSITORY is the name of your repository in Artifact Registry.

Pull request error: Could not fetch specs

You made a pull request but received the following error message:

Retrying fetcher due to error (2/4): Bundler::HTTPError Could not fetch specs from https://LOCATION-ruby.pkg.dev/PROJECT/REPOSITORY/ due to underlying error <bad response Not Found 404 (https://LOCATION-ruby.pkg.dev/PROJECT/REPOSITORY/specs.4.8.gz)>

This error may incorrectly appear even though the pull request was successful. Use a verbose command to verify that your pull request succeeded, such as bundle install --verbose.

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025年11月04日 UTC.