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

Error importing gems for local development #4494

Open
bradly opened this issue Feb 26, 2024 · 2 comments
Open

Error importing gems for local development #4494

bradly opened this issue Feb 26, 2024 · 2 comments

Comments

@bradly
Copy link
Contributor

bradly commented Feb 26, 2024

Trying to import gems locally is throwing an error:

NoMethodError: undefined method `owner' for an instance of User (NoMethodError)
/Users/bradly/code/archive/rubygems.org/app/models/pusher.rb:11:in `initialize'
/Users/bradly/code/archive/rubygems.org/lib/tasks/gemcutter.rake:21:in `new'

In the rake take we pass a new user instance to the Pusher initializer:

cutter = Pusher.new(User.new, File.open(path))

But in the Pusher class we are expecting an api_key and calling owner on it.

def initialize(api_key, body, request: nil)
@api_key = api_key
@owner = api_key.owner

Steps to Reproduce

  1. bundle exec rake "gemcutter:import:process[$gem_install_path]"

Expected Behavior

Gems should be imported

Current Behavior

Error calling .owner on a User instance

Possible Solution

Change the rake task to pass an api key instance instead of a user instance

The following worked but felt a little sketchy. Is there a better solution?

        api_key = ApiKey.first
        api_key.owner ||= User.new
        cutter = Pusher.new(ApiKey.first, File.open(path))

Environment

RubyGems version: latest code frommaster

@bradly bradly added the bug label Feb 26, 2024
@simi
Copy link
Member

simi commented Feb 26, 2024

Thanks for the report @bradly. Today it is recommended to use seed instead (which creates gems also). Would you mind to open PR to check for the users from seed to be present (for example gem owner one) and raise with friendly message explaining please first run the seed. And use the seed data to push the gems?

@bradly
Copy link
Contributor Author

bradly commented Feb 27, 2024

@simi Yes, let me just run through the contributing guide from a fresh db and open a pr with code/doc updates.

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

No branches or pull requests

3 participants