2

I am working in .rbs files in ruby and I and everything were working inside my app until I decided to declare the Redis type in the .rbs file.

I am using the gemfile redis

and then I have this function:

  def redis_connect
    Redis.new(host: REDIS_HOST, port: REDIS_PORT, password: REDIS_PASSWORD)
  end

which in the .rbs file looks like the next:

def redis_connect: () -> Redis

But I am getting the error cannot find Redis

is it possible to "type" Redis? or do I need to leave it untyped?

Thanks

TiGreX
  • 1,602
  • 3
  • 26
  • 41
  • not very familiar with RBS, but can't you just declare `class Redis` in the rbs file to tell it that's a class? – Max Jun 22 '22 at 13:53
  • @Max no, that does not work. as the new `Redis` class is not the one generated by `Redis.new ...` – TiGreX Jun 22 '22 at 22:45
  • `rbs -r redis ...` to include the gem in your RBS prototyping or validation. – Todd A. Jacobs Jun 23 '22 at 07:50
  • @ToddA.Jacobs that command seems not to be working (it triggers the hep) and when I ran any other I get a message like the next `.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/rbs-2.0.0/lib/rbs/environment_loader.rb:87:in 'block in each_dir': Cannot find type definitions for library: Redis ([nil]) (RBS::EnvironmentLoader::UnknownLibraryError)` any idea? – TiGreX Jun 23 '22 at 09:04

0 Answers0