Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
RobertDober opened this issue Jun 30, 2024 · 8 comments
Open

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

RobertDober opened this issue Jun 30, 2024 · 8 comments

Comments

@RobertDober
Copy link

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
Copy link

pimpin commented Jul 15, 2024

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
Copy link

pimpin commented Jul 15, 2024

I guess we get a clue here.

@pimpin
Copy link

pimpin commented Jul 15, 2024

I confirm I get links updated with metadata.

@deivid-rodriguez
Copy link
Member

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:

update_linkset! spec if version.reload.latest?
.

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:

def reorder_versions
bulk_reorder_versions
versions_of_platforms = versions
.release
.indexed
.group_by(&:platform)
Version.default_scoped.where(id: versions_of_platforms.values.map! { |v| v.max.id }).update_all(latest: true)
end

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:

AfterVersionWriteJob.new(version:).perform(version:)

Some potential ways to fix it:

  • Fix "is latest version?" condition to take into consideration the "not yet indexed" version that we're saving.
  • Make "Linkset" an attribute of each version, not of each gem, so that links gets saved everytime without having to check "is latest version". This is how "metadata" already works and why using metadata["homepage_uri"] instead works.

Transfering to rubygems.org!

@deivid-rodriguez deivid-rodriguez transferred this issue from rubygems/rubygems Jul 25, 2024
@deivid-rodriguez
Copy link
Member

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
Copy link
Member

simi commented Jul 25, 2024

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

@bkuhlmann
Copy link

ℹ️ 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
Copy link

bkuhlmann commented Aug 27, 2024

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

Gem::Specification.new do |spec|
  spec.name = "demo"
  spec.version = "0.0.0"
  spec.authors = ["Demo User"]
  spec.email = ["[email protected]"]
  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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants