Can't install Ruby gem after publishing to Github Package Registry

I’m using the standard template ( for publishing a Ruby gem to the package registry. I commented out the part of publishing to RubyGems, since this gem is private for now. After successfully publishing the gem, I am unable to install it locally. The error I’m getting is a 401 after copying the install command from the packages page.

gem install my_gem --version "0.1.0" --source ""
ERROR: Could not find a valid gem 'my_gem' (= 0.1.0), here is why:
          Unable to download data from - bad response Unauthorized 401 (

Some notes:

The repository ‘my_gem’ is a private repo I mantain. 

The OWNER environment variable in the action is jer-k

The GPR_AUTH_TOKEN environment variable has package:write package:read repo permissions.

I added the same token to my .gem/credentials following the instructions from

I’m must be missing something about how to authenticate. I was also trying to search how to distinguish between publishing public and private packages (this is a feature the package registry talks about) but I couldn’t find anything to indicate how to do it; maybe that is based on whether or not the repository is private?


Sorry to hear that.  Just to clarify a few things:  you’re using the same GPR_AUTH_TOKEN that you set up as a secret in your Actions workflow?  When you created the file, did you use a text editor?  Are you on Windows?  (That may change the line endings).

If you open bash (Git Bash if you’re on Windows) and run:

printf -- "---\n:github: Bearer ${GPR_AUTH_TOKEN}\n" > $HOME/.gem/credentials

Is there any change in behavior?

Yes, I’m using the same token in the action and the command line. I’m on OSX and I had set it up through vim originally. I just used that command and the result was the same.

Having the same issue (Linux).

~/.gem/credentials is configured properly.

The same token works with bundler on the same machine, but gem install xyz --source \<github\> fails with Unauthorized 401 ([](

1 Like

Also having the same issue, but only for some gems. Bundle install / update simply refuses to find a gem which is clearly published to Github Packages. Downloading the binary of the gem into vendor cache resolves the issue, but that is definitely a suboptimal solution. We’ve transitioned from Gemfury to Github Packages, and I’ve seen had an issue like this occur on Gemfury. Very confusing.

We’ve given up on Github Packages now and gone back to Gemfury. I think this one needs a bit more baking before it’s ready. We’re super keen to come back and use it once it’s done.

I believe I had the same issue as the original post, in that the command line given by github to install the gem gave that error.  As far as I can tell, gem install does not use the credentials file.  But the command worked when I changed the github URL to include user name and token, as per basic authentication.

–source “https://{username}:{token}…”


Finally circled back to this and I’m accepting this as the solution. It is not optimal, but it works for now!

Also just don’t forget to remove the {} around the input of your username and token. Was blankly staring at a non descriptive error like ‘why isn’t this working’ for 5 minutes…

Thanks for this. I’ve filed a feature request with RubyGems to have all commands support stored credentials consistently.