rubygems icon indicating copy to clipboard operation
rubygems copied to clipboard

Could the "Access Denied." message be made more informative, after trying "gem push *.gem" and failing at that?

Open rubyFeedback opened this issue 1 year ago • 9 comments

I am currently testing a few things via a new account.

So I built a local .gem file successfully, for a new gem; then I am trying to push it, via:

gem push *.gem

I then get this message:

Pushing gem to https://rubygems.org...
Access Denied. Please sign up for an account at https://rubygems.org

I am, however had, logged in with that test account at rubygems.org, so the message "sign up for an account" is confusing. I assume there may be some other issue, be it cache-related or some data that is conflicting or missing. (I did, however had, remove ~/.gem and then recompiled ruby from source, and also cleared all old cookies etc...)

Either way what this is, the message "Access Denied", and then the "Please sign up for an account" is confusing, because I have a new account at rubygems.org, so signing up for yet-another account makes no sense in my situation here, which makes the commandline notification a bit awkward; it seems whoever wrote this did not consider that such an account may already exist. Thus I assume there is some other problem to be the culprit here.

Would it be possible to provide more useful information than merely the "Access Denied" message? The "Access Denied" does not tell me much at all. I don't have a good alternative suggestion for a message because I do not know what the real issue is. Also, I have not been able to find a commandline option to specify additional data, e. g. email or something.

In the past, rubygems always asked me to provide e. g. my email before I would push a gem, but I do not seem to be able to specify this via the commandline, or I have not found how that can be done. Would be nice to have this available via the commandline too, to avoid ambiguity; and if it already exists or is added, to perhaps also add this to the "gem help examples", which is, by the way, rather useful (could need some more examples too).

rubyFeedback avatar Apr 22 '24 03:04 rubyFeedback

Hello, most likely you need to login again using gem signin (or logout with gem signout to get the login prompt).

simi avatar Apr 22 '24 09:04 simi

The only situation I can find where you get this message from the client is when you:

  1. Sign in with the gem command (via one of gem signin, during a gem push, etc).
  2. Revoke the key that was generated in step 1.
  3. Try gem push.

The text is not defined in the gem client, but returned by rubygems.org. The exact string is defined at https://github.com/rubygems/rubygems.org/blob/master/config/locales/en.yml#L30 and returned by https://github.com/rubygems/rubygems.org/blob/master/app/controllers/api/base_controller.rb#L101.

It might make sense to have it mention gem signin, since that's the fix.

duckinator avatar Apr 29 '24 01:04 duckinator

Should we move this to the rubygems.org repo then?

deivid-rodriguez avatar Apr 29 '24 08:04 deivid-rodriguez

@deivid-rodriguez yup, we can probably make error message more informational to suggest next steps. On the other side, on unathorized, maybe gem push can offer to login again and remove old non-working key? :thinking:

simi avatar Apr 29 '24 10:04 simi

Yes, that makes sense to me. I'll leave this opened to track that improvement.

deivid-rodriguez avatar Apr 29 '24 15:04 deivid-rodriguez

@deivid-rodriguez I think this makes sense to move to the rubygems.org repo, although I don't have permissions on the rubygems.org repo myself — would you mind moving it?

duckinator avatar Apr 29 '24 15:04 duckinator

I don't mind moving it but @simi was suggesting that changes in the client could also be useful, like automatically deleting the non working key, and prompting the user again for login directly.

deivid-rodriguez avatar Apr 29 '24 15:04 deivid-rodriguez

Ah, that's a fair point. :+1: I opened rubygems/rubygems.org#4663 for the rubygems.org side of this.

duckinator avatar Apr 29 '24 22:04 duckinator

Opened https://github.com/rubygems/guides/pull/390 so that the solution is more discoverable, for now.

duckinator avatar Apr 30 '25 01:04 duckinator

https://github.com/rubygems/guides/pull/390/ is enough to resolve this issue.

hsbt avatar Oct 23 '25 03:10 hsbt