Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Copilot Lvl 2
Message 1 of 4

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

I'm using the standard template (https://github.com/actions/starter-workflows/blob/master/ci/gem-push.yml) 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 "https://rubygems.pkg.github.com/jer-k"
ERROR:  Could not find a valid gem 'my_gem' (= 0.1.0), here is why:
          Unable to download data from https://rubygems.pkg.github.com/jer-k/ - bad response Unauthorized 401 (https://rubygems.pkg.github.com/jer-k/specs.4.8.gz)

 

 

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 https://help.github.com/en/articles/configuring-rubygems-for-use-with-github-package-registry#authen...

 

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?

 

 

3 Replies
GitHub Staff
Message 2 of 4

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

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?

Copilot Lvl 2
Message 3 of 4

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

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.

Ground Controller Lvl 1
Message 4 of 4

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

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 (https://rubygems.pkg.github.com/ruby-next/specs.4.8.gz)`.