Skip to content

resolving dependency confusion: views, scopes, canonical gem URIs, and gem author verification #12

@duckinator

Description

@duckinator

Alright, time to try to turn a monster of a Slack thread into something actionable. Let's do this.

Based on that discussion, this is the list of tools I'm interested in for fighting dependency confusion.

  1. scopes: a common name grouping a collection of gems. In gem name references, they're prefixed with an @.
    • Example: I could have the @duckinator scope, and maybe have @duckinator/boop and @duckinator/jim.
    • PURPOSE: gem names no longer have to be unique across a given server.
  2. canonical gem URIs: treating the gem server you upload to as the "canonical" host, the canonical URI would be ${CANONICAL_HOST}/${SCOPE}/${GEMNAME}.
    • Example: If I upload jim in the @duckinator scope to gem.coop, the canonical gem URI would be https://gem.coop/@duckinator/jim
    • PURPOSE: scopes no longer have to be unique across all gem servers.
  3. views: using alternative URLs to change what collections of gems RubyGems and Bundler can "see".
    • Idea: If gem.coop does not populate the unscoped namespace by default, we can use views to populate it.
    • Example: https://some-company.gem.coop could only allow access to gems some-company has authorized.
    • Example: https://rgo.gem.coop could show only things mirrored from RubyGems.org.
    • PURPOSE: Provides a more formal mechanism for private mirrors that override certain gem names.
  4. gem author verification: I don't know anything about this, I defer to more knowledgeable folks. ❤️

I have a proof of concept adding Bundler support for scopes and canonical gem URIs. GitHub Packages has "namespaces" that are just a GitHub username or organization name, and it works very similar to my idea for scopes. However, since their "namespaces" don't have a leading @, my proof-of-concept has a kludge for the GitHub Packages hosts specifically. This means it can be tested in the real world, against a production-quality server, right now.


I think my rationale is best explained with (this slightly-cleaned-up version of) something I said earlier today:

I think we should be taking this as an opportunity to decentralize, not create a new Pillar Of Truth™️.
I'd rather see a larger number of smaller gem servers, and make our tooling support that idea.
Especially since to my knowledge we have never, at any point, had just one gem server.

Gemspecs are inherently lying to you by claiming there's only One Source Of Truth.

Or, to put it another way: We always had multiple gem servers in the wild. Starting gem.coop didn't create new problems, it highlighted ones people have known about for over 20 years. We should use this as an opportunity to address those problems.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions