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

Fix uninitialized constant error when using Redis cache #375

Merged
merged 2 commits into from
Oct 8, 2023
Merged

Fix uninitialized constant error when using Redis cache #375

merged 2 commits into from
Oct 8, 2023

Conversation

chris72205
Copy link
Contributor

@chris72205 chris72205 commented Oct 6, 2023

Description:

This change adds RedisClient to the autoload list. Without this change, an uninitialized constant error is raised when running setup and entering the redis cache (example output below). I also updated the default Redis connection string since the following error is thrown without having a scheme provided:

Error checking cache: Invalid URL: "localhost:6379"

I started to add tests, but couldn't reproduce it there without possibly affecting all tests. Since this line loads lib/gemstash/cache.rb, Gemstash::RedisClient becomes initialized.

bin/gemstash setup --debug --redo
Where should files go? [~/.gemstash]
Cache with what? [MEMORY, memcached, redis] redis
What is the comma-separated list of Redis servers? [localhost:6379]
What database adapter? [SQLITE3, postgres, mysql, mysql2]
Use Protected Fetch for Private Gems? [y/N] y
How many seconds to wait when fetching a gem? [20]
Checking that the cache is available
Error checking cache: uninitialized constant Gemstash::RedisClient
  [...]/gemstash/lib/gemstash/env.rb:174:in `cache_client'
  [...]/gemstash/lib/gemstash/cli/setup.rb:134:in `block in check_cache'
  [...]/gemstash/lib/gemstash/cli/setup.rb:187:in `with_new_config'
  [...]/gemstash/lib/gemstash/cli/setup.rb:194:in `try'
  [...]/gemstash/lib/gemstash/cli/setup.rb:134:in `check_cache'
  [...]/gemstash/lib/gemstash/cli/setup.rb:29:in `run'
  [...]/gemstash/lib/gemstash/cli.rb:74:in `setup'
  [...]/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/thor-1.2.2/lib/thor/command.rb:27:in `run'
  [...]/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/thor-1.2.2/lib/thor/invocation.rb:127:in `invoke_command'
  [...]/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/thor-1.2.2/lib/thor.rb:392:in `dispatch'
  [...]/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/thor-1.2.2/lib/thor/base.rb:485:in `start'
  [...]/gemstash/lib/gemstash/cli.rb:34:in `start'
  bin/gemstash:4:in `<main>'
The cache is not available

I will abide by the code of conduct.

@th1agoalmeida
Copy link
Contributor

LGTM. Ran into the same issue locally. This fixes it.

@th1agoalmeida
Copy link
Contributor

@olleolleolle you might want to take a look at this one too :)

Copy link
Member

@olleolleolle olleolleolle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks 💯 and thanks for adding test coverage for it, and all. Thanks, @chris72205!

@olleolleolle olleolleolle merged commit c66fb7f into rubygems:main Oct 8, 2023
6 checks passed
olleolleolle added a commit that referenced this pull request Oct 8, 2023
@chris72205 chris72205 deleted the fix-redis-client-error branch October 9, 2023 23:26
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

Successfully merging this pull request may close these issues.

None yet

3 participants