rubygems / rubygems.org

The Ruby community's gem hosting service.
https://rubygems.org
MIT License
2.31k stars 915 forks source link

Codeberg homepage urls are not shown on the Rubygems page #4924

Open RobertDober opened 2 months ago

RobertDober commented 2 months ago

Describe the problem as clearly as you can

When I specify a codeberg url in the homepage entry of my gemspec as in the simple_args gem

then it cannot be seen on the gem's page

Did you try upgrading RubyGems?

indeed

Post steps to reproduce the problem

just use a codeberg url for the homepage entry see example above and run....

Which command did you run?

gem build gem push

What were you expecting to happen?

What actually happened?

See above

Run gem env and paste the output below

 Environment:
  - RUBYGEMS VERSION: 3.5.14
  - RUBY VERSION: 3.3.3 (2024-06-12 patchlevel 89) [x86_64-darwin21]
  - INSTALLATION DIRECTORY: /Users/robert/.asdf/installs/ruby/3.3.3/lib/ruby/gems/3.3.0
  - USER INSTALLATION DIRECTORY: /Users/robert/.gem/ruby/3.3.0
  - RUBY EXECUTABLE: /Users/robert/.asdf/installs/ruby/3.3.3/bin/ruby
  - GIT EXECUTABLE: /usr/local/bin/git
  - EXECUTABLE DIRECTORY: /Users/robert/.asdf/installs/ruby/3.3.3/bin
  - SPEC CACHE DIRECTORY: /Users/robert/.gem/specs
  - SYSTEM CONFIGURATION DIRECTORY: /Users/robert/.asdf/installs/ruby/3.3.3/etc
  - RUBYGEMS PLATFORMS:
     - ruby
     - x86_64-darwin-21
  - GEM PATHS:
     - /Users/robert/.asdf/installs/ruby/3.3.3/lib/ruby/gems/3.3.0
     - /Users/robert/.gem/ruby/3.3.0
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => true
     - :bulk_threshold => 1000
     - "gem" => "--no-document"
  - REMOTE SOURCES:
     - https://rubygems.org/
  - SHELL PATH:
     - /Users/robert/.asdf/installs/ruby/3.3.3/bin
     - /Users/robert/.opam/5.0.0/bin
     - /Users/robert/.asdf/installs/opam/2.1.4/bin
     - /Users/robert/.emacs.d/bin
     - /Users/robert/.asdf/shims
     - /usr/local/opt/asdf/libexec/bin
     - /Users/robert/bin
     - /Applications/factor
     - /usr/local/bin
     - /usr/bin
     - /bin
     - /usr/sbin
     - /sbin
     - /opt/X11/bin
     - /Users/robert/.opam/5.0.0/bin
     - /Users/robert/.asdf/installs/opam/2.1.4/bin
     - /Users/robert/.emacs.d/bin
     - /Users/robert/bin
     - /Applications/factor
     - /Users/robert/.cabal/bin
     - /Users/robert/.ghcup/bin
     - /Applications/iTerm.app/Contents/Resources/utilities
     - /usr/local/sbin
     - /usr/games
     - /usr/local/games
     - /Users/robert/etc/lab42-myzsh/bin
     - /Users/robert/.local/bin
     - /Users/robert/bin
     - /usr/local/sbin
     - /usr/local/bin
     - /usr/sbin
     - /usr/bin
     - /sbin
     - /bin
     - /usr/games
     - /usr/local/games
     - /Users/robert/etc/lab42-myzsh/bin
     - /Users/robert/.local/bin
     - /usr/bin
pimpin commented 2 months ago

Hello, we have also issues around homepage link : We updated the homepage link in a gem and, after build and publish, the change is not reflecting on the Rubygems page. The homepage still point to https://github.com/cotag/couchbase-orm whereas the gemspec point to https://github.com/Couchbase-Ecosystem/couchbase-ruby-orm .

pimpin commented 2 months ago

I guess we get a clue here.

pimpin commented 2 months ago

I confirm I get links updated with metadata.

deivid-rodriguez commented 1 month ago

I looked into this and I think it's a rubygems.org bug. My investigation shows that the line that it's supposed to update this field is this one:

https://github.com/rubygems/rubygems.org/blob/e1ae15703c70f0db17c1524bee7b8f25cb9e7c27/app/models/rubygem.rb#L294.

However, it never runs because version.reload.latest? is never true. The gem is supposed to get latest: true thanks to an after_save :reorder_versions hook in the Version model that runs this code here:

https://github.com/rubygems/rubygems.org/blob/e1ae15703c70f0db17c1524bee7b8f25cb9e7c27/app/models/rubygem.rb#L304-L313

However, that only updates versions that have already been indexed, and that's done by the AfterVersionWrite job which has not even been enqueued yet:

https://github.com/rubygems/rubygems.org/blob/e1ae15703c70f0db17c1524bee7b8f25cb9e7c27/app/models/pusher.rb#L157

Some potential ways to fix it:

Transfering to rubygems.org!

deivid-rodriguez commented 1 month ago

Also this comment by @sonalkr132 explains the motivation for the current state of things. Linkset was previously set by a UI form, so it makes sense that it was linked to the whole gem, not to specific versions.

Not super trivial but I think the best way forward would be to migrate Linkset table to be linked to a specific version instead of being linked to the gem. Actually, we may not even need to fill in a separate table anymore at all if there are no longer any views/controllers/etc using it, and we can instead backfill version metadata with fallbacks if not explicitly present in the specification?

simi commented 1 month ago

@deivid-rodriguez indeed this is caused by never finished migration.

bkuhlmann commented 2 weeks ago

:information_source: In case it's of interest, I'm hitting the problem too. The source code for my Pipeable gem is correct but the RubyGems homepage link is not.

bkuhlmann commented 2 weeks ago

In looking at this problem more, I have few more questions/concerns that are semi-related to what Samual brought up in this issue (mentioned above) in terms of confusing UI and what's being discussed in this current issue in terms of confusing gemspec attributes because the use of homepage and homepage_uri metadata is still confusing. For illustration purposes, I'm going to focus on gem building since that's the fastest way to illustrate what I'm seeing. Consider the following demo.gemspec:

Demo Gem Specification ``` ruby# frozen_string_literal: true Gem::Specification.new do |spec| spec.name = "demo" spec.version = "0.0.0" spec.authors = ["Demo User"] spec.email = ["demo@demo.io"] spec.homepage = "https://demo.io/projects/demo" spec.summary = "A demonstration." spec.license = "Hippocratic-2.1" spec.metadata = { "bug_tracker_uri" => "https://github.com/bkuhlmann/demo/issues", "changelog_uri" => "https://demo.io/projects/demo/versions", "documentation_uri" => "https://demo.io/projects/demo", "funding_uri" => "https://github.com/sponsors/bkuhlmann", "label" => "Demo", "rubygems_mfa_required" => "true", "source_code_uri" => "https://github.com/bkuhlmann/demo" } spec.required_ruby_version = "~> 3.3" spec.extra_rdoc_files = Dir["README*", "LICENSE*"] spec.files = Dir["*.gemspec", "lib/**/*"] end ```

Running gem build demo.gemspec results in no warnings:

  Successfully built RubyGem
  Name: demo
  Version: 0.0.0
  File: demo-0.0.0.gem

If you delete spec.homepage and define homepage_uri metadata instead and then run gem build demo.gemspec, you'll get:

WARNING:  no homepage specified
WARNING:  You have specified the uri:
  https://demo.io/projects/demo
for all of the following keys:
  homepage_uri
  documentation_uri
Only the first one will be shown on rubygems.org

If you delete spec.homepage and documentation_uri metadata but keep the homepage_uri metadata and run gem build demo.gemspec, you'll get:

WARNING:  no homepage specified

In all the above, your gem will be built but the only way to not get warnings is to specify spec.homepage but then you end up with the RubyGems UI not being update appropriately. All of this is to say, that it seems like two problems are at play here:

  1. The RubyGems page should handle updating the homepage link for homepage but, I guess allow, homepage_uri to override? This seems confusing and feels like an error should be raised if both homepage and homepage_uri are present where use of homepage should be encouraged.
  2. Allow the same or different URI for documentation_uri and homepage/homepage_uri since it's reasonable to have the same and/or different URIs but it might be worth denoting, visually, that they are the same with a "SAME" badge next to the URIs within the RubyGems page so folks aren't confused?

Anyway, some thoughts. If this should be broken into a separate issue, I can do that too.